From 47d9bf9fbfa426f80e47156f49de1b99a2483050 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 7 Jan 2025 21:40:25 +0000 Subject: [PATCH] feat(client): add various convenience setters to models (#420) feat(client): allow setting arbitrary JSON for top-level body params feat(client): expose getters for `JsonField` of body params fix(client): consistently throw on omitting required fields fix(client): convert `JsonField` containing list type to mutable in builder style(internal): simplify existing convenience setters on params style(internal): move headers and query params setters below others style(internal): explicitly add some method return types --- .../com/lithic/api/core/ClientOptions.kt | 20 +- .../kotlin/com/lithic/api/models/Account.kt | 145 ++- .../com/lithic/api/models/AccountHolder.kt | 322 ++++-- .../api/models/AccountHolderCreateResponse.kt | 77 +- .../AccountHolderListDocumentsResponse.kt | 23 +- ...rSimulateEnrollmentDocumentReviewParams.kt | 191 ++- ...untHolderSimulateEnrollmentReviewParams.kt | 165 ++- ...tHolderSimulateEnrollmentReviewResponse.kt | 345 ++++-- .../api/models/AccountHolderUpdateParams.kt | 180 ++- .../api/models/AccountHolderUpdateResponse.kt | 10 +- .../AccountHolderUploadDocumentParams.kt | 105 +- .../lithic/api/models/AccountSpendLimits.kt | 34 +- .../lithic/api/models/AccountUpdateParams.kt | 351 ++++-- .../kotlin/com/lithic/api/models/Address.kt | 32 +- .../com/lithic/api/models/AggregateBalance.kt | 72 +- .../models/AggregateBalanceListResponse.kt | 64 +- .../kotlin/com/lithic/api/models/ApiStatus.kt | 2 +- .../kotlin/com/lithic/api/models/AuthRule.kt | 176 ++- .../api/models/AuthRuleV2ApplyParams.kt | 154 ++- .../models/AuthRuleV2BacktestCreateParams.kt | 102 +- .../api/models/AuthRuleV2CreateParams.kt | 1030 ++++++++++++++--- .../api/models/AuthRuleV2DraftParams.kt | 311 ++++- .../api/models/AuthRuleV2UpdateParams.kt | 123 +- .../com/lithic/api/models/AuthStreamSecret.kt | 2 +- .../models/AuthenticationRetrieveResponse.kt | 406 ++++--- .../models/AuthenticationSimulateResponse.kt | 2 +- .../api/models/BacktestCreateResponse.kt | 4 +- .../com/lithic/api/models/BacktestResults.kt | 89 +- .../kotlin/com/lithic/api/models/Balance.kt | 72 +- .../lithic/api/models/BalanceListResponse.kt | 68 +- .../api/models/BookTransferCreateParams.kt | 295 ++++- .../lithic/api/models/BookTransferResponse.kt | 184 +-- .../api/models/BookTransferReverseParams.kt | 77 +- .../main/kotlin/com/lithic/api/models/Card.kt | 190 +-- .../api/models/CardConvertPhysicalParams.kt | 215 +++- .../com/lithic/api/models/CardCreateParams.kt | 824 +++++++++++-- .../com/lithic/api/models/CardProgram.kt | 61 +- .../lithic/api/models/CardProvisionParams.kt | 294 ++++- .../api/models/CardProvisionResponse.kt | 2 +- .../lithic/api/models/CardReissueParams.kt | 217 +++- .../com/lithic/api/models/CardRenewParams.kt | 289 ++++- .../api/models/CardSearchByPanParams.kt | 73 +- .../com/lithic/api/models/CardSpendLimits.kt | 34 +- .../com/lithic/api/models/CardUpdateParams.kt | 358 +++++- .../kotlin/com/lithic/api/models/Carrier.kt | 2 +- .../lithic/api/models/ChallengeResponse.kt | 16 +- .../CreditProductPrimeRateCreateParams.kt | 102 +- .../DecisioningRetrieveSecretResponse.kt | 2 +- .../DecisioningSimulateChallengeResponse.kt | 2 +- .../com/lithic/api/models/DigitalCardArt.kt | 40 +- .../kotlin/com/lithic/api/models/Dispute.kt | 212 ++-- .../lithic/api/models/DisputeCreateParams.kt | 186 ++- .../com/lithic/api/models/DisputeEvidence.kt | 36 +- .../DisputeInitiateEvidenceUploadParams.kt | 77 +- .../lithic/api/models/DisputeUpdateParams.kt | 160 ++- .../kotlin/com/lithic/api/models/Document.kt | 185 ++- .../EnhancedCommercialDataRetrieveResponse.kt | 24 +- .../com/lithic/api/models/EnhancedData.kt | 158 ++- .../kotlin/com/lithic/api/models/Event.kt | 24 +- .../lithic/api/models/EventSubscription.kt | 49 +- .../models/EventSubscriptionCreateParams.kt | 180 ++- ...tSubscriptionSendSimulatedExampleParams.kt | 78 +- .../models/EventSubscriptionUpdateParams.kt | 180 ++- .../com/lithic/api/models/ExtendedCredit.kt | 11 +- .../api/models/ExternalBankAccountAddress.kt | 32 +- .../models/ExternalBankAccountCreateParams.kt | 853 +++++++++++--- .../ExternalBankAccountCreateResponse.kt | 114 +- .../models/ExternalBankAccountListResponse.kt | 114 +- ...rnalBankAccountMicroDepositCreateParams.kt | 93 +- .../ExternalBankAccountRetrieveResponse.kt | 114 +- ...rnalBankAccountRetryMicroDepositsParams.kt | 78 +- ...alBankAccountRetryMicroDepositsResponse.kt | 114 +- .../ExternalBankAccountRetryPrenoteParams.kt | 78 +- ...ExternalBankAccountRetryPrenoteResponse.kt | 114 +- .../models/ExternalBankAccountUpdateParams.kt | 283 ++++- .../ExternalBankAccountUpdateResponse.kt | 114 +- .../com/lithic/api/models/ExternalPayment.kt | 178 +-- .../api/models/ExternalPaymentCancelParams.kt | 96 +- .../api/models/ExternalPaymentCreateParams.kt | 261 ++++- .../models/ExternalPaymentReleaseParams.kt | 96 +- .../models/ExternalPaymentReverseParams.kt | 96 +- .../api/models/ExternalPaymentSettleParams.kt | 121 +- .../com/lithic/api/models/FinancialAccount.kt | 152 ++- .../models/FinancialAccountChargeOffParams.kt | 74 +- .../models/FinancialAccountCreateParams.kt | 142 ++- .../models/FinancialAccountCreditConfig.kt | 78 +- ...lAccountCreditConfigurationUpdateParams.kt | 156 ++- .../models/FinancialAccountUpdateParams.kt | 73 +- .../lithic/api/models/FinancialTransaction.kt | 99 +- .../main/kotlin/com/lithic/api/models/Kyb.kt | 208 +++- .../main/kotlin/com/lithic/api/models/Kyc.kt | 72 +- .../kotlin/com/lithic/api/models/KycExempt.kt | 50 +- .../lithic/api/models/LineItemListResponse.kt | 76 +- .../kotlin/com/lithic/api/models/LoanTape.kt | 426 ++++--- .../models/ManagementOperationCreateParams.kt | 280 +++-- .../ManagementOperationReverseParams.kt | 96 +- .../models/ManagementOperationTransaction.kt | 179 +-- .../com/lithic/api/models/MessageAttempt.kt | 52 +- .../api/models/MicroDepositCreateResponse.kt | 114 +- .../kotlin/com/lithic/api/models/Payment.kt | 272 +++-- .../lithic/api/models/PaymentCreateParams.kt | 290 +++-- .../api/models/PaymentCreateResponse.kt | 154 ++- .../lithic/api/models/PaymentRetryResponse.kt | 154 ++- .../api/models/PaymentSimulateActionParams.kt | 138 ++- .../models/PaymentSimulateActionResponse.kt | 22 +- .../models/PaymentSimulateReceiptParams.kt | 179 ++- .../models/PaymentSimulateReceiptResponse.kt | 22 +- .../models/PaymentSimulateReleaseParams.kt | 81 +- .../models/PaymentSimulateReleaseResponse.kt | 22 +- .../api/models/PaymentSimulateReturnParams.kt | 111 +- .../models/PaymentSimulateReturnResponse.kt | 22 +- .../api/models/PrimeRateRetrieveResponse.kt | 45 +- .../com/lithic/api/models/RequiredDocument.kt | 64 +- .../models/ResponderEndpointCreateParams.kt | 97 +- .../models/ResponderEndpointCreateResponse.kt | 2 +- .../api/models/ResponderEndpointStatus.kt | 6 +- .../com/lithic/api/models/SettlementDetail.kt | 165 ++- .../com/lithic/api/models/SettlementReport.kt | 94 +- .../api/models/SettlementSummaryDetails.kt | 18 +- .../com/lithic/api/models/ShippingAddress.kt | 52 +- .../kotlin/com/lithic/api/models/Statement.kt | 344 +++--- .../lithic/api/models/StatementLineItems.kt | 110 +- .../com/lithic/api/models/Statements.kt | 30 +- .../SubscriptionRetrieveSecretResponse.kt | 2 +- .../ThreeDSAuthenticationSimulateParams.kt | 291 ++++- ...reeDSDecisioningChallengeResponseParams.kt | 119 +- ...reeDSDecisioningSimulateChallengeParams.kt | 89 +- ...isioningSimulateChallengeResponseParams.kt | 119 +- .../com/lithic/api/models/Tokenization.kt | 104 +- ...nizationDecisioningRotateSecretResponse.kt | 2 +- .../TokenizationResendActivationCodeParams.kt | 101 +- .../models/TokenizationRetrieveResponse.kt | 2 +- .../lithic/api/models/TokenizationSecret.kt | 2 +- .../api/models/TokenizationSimulateParams.kt | 288 ++++- .../models/TokenizationSimulateResponse.kt | 23 +- .../TokenizationUpdateDigitalCardArtParams.kt | 102 +- ...okenizationUpdateDigitalCardArtResponse.kt | 2 +- .../com/lithic/api/models/Transaction.kt | 908 +++++++++------ ...actionSimulateAuthorizationAdviceParams.kt | 110 +- ...tionSimulateAuthorizationAdviceResponse.kt | 4 +- .../TransactionSimulateAuthorizationParams.kt | 431 +++++-- ...ransactionSimulateAuthorizationResponse.kt | 4 +- .../TransactionSimulateClearingParams.kt | 117 +- .../TransactionSimulateClearingResponse.kt | 2 +- ...actionSimulateCreditAuthorizationParams.kt | 206 +++- ...tionSimulateCreditAuthorizationResponse.kt | 4 +- .../models/TransactionSimulateReturnParams.kt | 121 +- .../TransactionSimulateReturnResponse.kt | 4 +- ...TransactionSimulateReturnReversalParams.kt | 75 +- ...ansactionSimulateReturnReversalResponse.kt | 2 +- .../models/TransactionSimulateVoidParams.kt | 143 ++- .../models/TransactionSimulateVoidResponse.kt | 2 +- .../kotlin/com/lithic/api/models/Transfer.kt | 108 +- .../lithic/api/models/TransferCreateParams.kt | 217 +++- .../com/lithic/api/models/V2ApplyResponse.kt | 259 +++-- .../com/lithic/api/models/V2CreateResponse.kt | 259 +++-- .../com/lithic/api/models/V2DraftResponse.kt | 259 +++-- .../com/lithic/api/models/V2ListResponse.kt | 259 +++-- .../lithic/api/models/V2PromoteResponse.kt | 259 +++-- .../com/lithic/api/models/V2ReportResponse.kt | 4 +- .../lithic/api/models/V2RetrieveResponse.kt | 259 +++-- .../com/lithic/api/models/V2UpdateResponse.kt | 259 +++-- .../lithic/api/models/VelocityLimitParams.kt | 115 +- .../com/lithic/api/models/TransactionTest.kt | 8 + 164 files changed, 16476 insertions(+), 6452 deletions(-) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/core/ClientOptions.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/core/ClientOptions.kt index 7f7c06b9..dd2c0efd 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/core/ClientOptions.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/core/ClientOptions.kt @@ -72,6 +72,16 @@ private constructor( fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } + + fun webhookSecret(webhookSecret: String?) = apply { this.webhookSecret = webhookSecret } + fun headers(headers: Headers) = apply { this.headers.clear() putAllHeaders(headers) @@ -152,16 +162,6 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun responseValidation(responseValidation: Boolean) = apply { - this.responseValidation = responseValidation - } - - fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } - - fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } - - fun webhookSecret(webhookSecret: String?) = apply { this.webhookSecret = webhookSecret } - fun fromEnv() = apply { System.getenv("LITHIC_API_KEY")?.let { apiKey(it) } System.getenv("LITHIC_WEBHOOK_SECRET")?.let { webhookSecret(it) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Account.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Account.kt index 936aef65..15fb3fbe 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Account.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Account.kt @@ -97,13 +97,13 @@ private constructor( * Globally unique identifier for the account. This is the same as the account_token returned by * the enroll endpoint. If using this parameter, do not include pagination. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * Timestamp of when the account was created. For accounts created before 2023-05-11, this field * will be null. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** * Spend limit information for the user containing the daily, monthly, and lifetime spend limit @@ -111,7 +111,9 @@ private constructor( * transaction volume has surpassed the value in the applicable time limit (rolling). A lifetime * limit of 0 indicates that the lifetime limit feature is disabled. */ - @JsonProperty("spend_limit") @ExcludeMissing fun _spendLimit() = spendLimit + @JsonProperty("spend_limit") + @ExcludeMissing + fun _spendLimit(): JsonField = spendLimit /** * Account state: @@ -123,9 +125,11 @@ private constructor( * from failing to pass KYB/KYC or Lithic closing for risk/compliance reasons. Please contact * [support@lithic.com](mailto:support@lithic.com) if you believe this was in error. */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - @JsonProperty("account_holder") @ExcludeMissing fun _accountHolder() = accountHolder + @JsonProperty("account_holder") + @ExcludeMissing + fun _accountHolder(): JsonField = accountHolder /** * List of identifiers for the Auth Rule(s) that are applied on the account. This field is @@ -133,16 +137,18 @@ private constructor( * removed from the schema in a future release. Use the `/auth_rules` endpoints to fetch Auth * Rule information instead. */ - @JsonProperty("auth_rule_tokens") @ExcludeMissing fun _authRuleTokens() = authRuleTokens + @JsonProperty("auth_rule_tokens") + @ExcludeMissing + fun _authRuleTokens(): JsonField> = authRuleTokens /** 3-digit alphabetic ISO 4217 code for the currency of the cardholder. */ @JsonProperty("cardholder_currency") @ExcludeMissing - fun _cardholderCurrency() = cardholderCurrency + fun _cardholderCurrency(): JsonField = cardholderCurrency @JsonProperty("verification_address") @ExcludeMissing - fun _verificationAddress() = verificationAddress + fun _verificationAddress(): JsonField = verificationAddress @JsonAnyGetter @ExcludeMissing @@ -173,12 +179,12 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var spendLimit: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var created: JsonField? = null + private var spendLimit: JsonField? = null + private var state: JsonField? = null private var accountHolder: JsonField = JsonMissing.of() - private var authRuleTokens: JsonField> = JsonMissing.of() + private var authRuleTokens: JsonField>? = null private var cardholderCurrency: JsonField = JsonMissing.of() private var verificationAddress: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -189,7 +195,7 @@ private constructor( spendLimit = account.spendLimit state = account.state accountHolder = account.accountHolder - authRuleTokens = account.authRuleTokens + authRuleTokens = account.authRuleTokens.map { it.toMutableList() } cardholderCurrency = account.cardholderCurrency verificationAddress = account.verificationAddress additionalProperties = account.additionalProperties.toMutableMap() @@ -211,7 +217,7 @@ private constructor( * Timestamp of when the account was created. For accounts created before 2023-05-11, this * field will be null. */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) + fun created(created: OffsetDateTime?) = created(JsonField.ofNullable(created)) /** * Timestamp of when the account was created. For accounts created before 2023-05-11, this @@ -283,7 +289,24 @@ private constructor( * Auth Rule information instead. */ fun authRuleTokens(authRuleTokens: JsonField>) = apply { - this.authRuleTokens = authRuleTokens + this.authRuleTokens = authRuleTokens.map { it.toMutableList() } + } + + /** + * List of identifiers for the Auth Rule(s) that are applied on the account. This field is + * deprecated and will no longer be populated in the `account_holder` object. The key will + * be removed from the schema in a future release. Use the `/auth_rules` endpoints to fetch + * Auth Rule information instead. + */ + fun addAuthRuleToken(authRuleToken: String) = apply { + authRuleTokens = + (authRuleTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(authRuleToken) + } } /** 3-digit alphabetic ISO 4217 code for the currency of the cardholder. */ @@ -323,12 +346,12 @@ private constructor( fun build(): Account = Account( - token, - created, - spendLimit, - state, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(spendLimit) { "`spendLimit` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, accountHolder, - authRuleTokens.map { it.toImmutable() }, + (authRuleTokens ?: JsonMissing.of()).map { it.toImmutable() }, cardholderCurrency, verificationAddress, additionalProperties.toImmutable(), @@ -368,13 +391,13 @@ private constructor( fun monthly(): Long = monthly.getRequired("monthly") /** Daily spend limit (in cents). */ - @JsonProperty("daily") @ExcludeMissing fun _daily() = daily + @JsonProperty("daily") @ExcludeMissing fun _daily(): JsonField = daily /** Total spend limit over account lifetime (in cents). */ - @JsonProperty("lifetime") @ExcludeMissing fun _lifetime() = lifetime + @JsonProperty("lifetime") @ExcludeMissing fun _lifetime(): JsonField = lifetime /** Monthly spend limit (in cents). */ - @JsonProperty("monthly") @ExcludeMissing fun _monthly() = monthly + @JsonProperty("monthly") @ExcludeMissing fun _monthly(): JsonField = monthly @JsonAnyGetter @ExcludeMissing @@ -400,9 +423,9 @@ private constructor( class Builder { - private var daily: JsonField = JsonMissing.of() - private var lifetime: JsonField = JsonMissing.of() - private var monthly: JsonField = JsonMissing.of() + private var daily: JsonField? = null + private var lifetime: JsonField? = null + private var monthly: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(spendLimit: SpendLimit) = apply { @@ -451,9 +474,9 @@ private constructor( fun build(): SpendLimit = SpendLimit( - daily, - lifetime, - monthly, + checkNotNull(daily) { "`daily` is required but was not set" }, + checkNotNull(lifetime) { "`lifetime` is required but was not set" }, + checkNotNull(monthly) { "`monthly` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -577,7 +600,7 @@ private constructor( fun phoneNumber(): String = phoneNumber.getRequired("phone_number") /** Globally unique identifier for the account holder. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * Only applicable for customers using the KYC-Exempt workflow to enroll authorized users of @@ -586,13 +609,15 @@ private constructor( */ @JsonProperty("business_account_token") @ExcludeMissing - fun _businessAccountToken() = businessAccountToken + fun _businessAccountToken(): JsonField = businessAccountToken /** Email address. */ - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email /** Phone number of the individual. */ - @JsonProperty("phone_number") @ExcludeMissing fun _phoneNumber() = phoneNumber + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber @JsonAnyGetter @ExcludeMissing @@ -619,10 +644,10 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var businessAccountToken: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var phoneNumber: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var businessAccountToken: JsonField? = null + private var email: JsonField? = null + private var phoneNumber: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(accountHolder: AccountHolder) = apply { @@ -691,10 +716,12 @@ private constructor( fun build(): AccountHolder = AccountHolder( - token, - businessAccountToken, - email, - phoneNumber, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(businessAccountToken) { + "`businessAccountToken` is required but was not set" + }, + checkNotNull(email) { "`email` is required but was not set" }, + checkNotNull(phoneNumber) { "`phoneNumber` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -768,28 +795,30 @@ private constructor( fun address2(): String? = address2.getNullable("address2") /** Valid deliverable address (no PO boxes). */ - @JsonProperty("address1") @ExcludeMissing fun _address1() = address1 + @JsonProperty("address1") @ExcludeMissing fun _address1(): JsonField = address1 /** City name. */ - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city /** Country name. Only USA is currently supported. */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** * Valid postal code. Only USA postal codes (ZIP codes) are currently supported, entered as * a five-digit postal code or nine-digit postal code (ZIP+4) using the format 12345-1234. */ - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode /** * Valid state code. Only USA state codes are currently supported, entered in uppercase ISO * 3166-2 two-character format. */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** Unit or apartment number (if applicable). */ - @JsonProperty("address2") @ExcludeMissing fun _address2() = address2 + @JsonProperty("address2") @ExcludeMissing fun _address2(): JsonField = address2 @JsonAnyGetter @ExcludeMissing @@ -818,11 +847,11 @@ private constructor( class Builder { - private var address1: JsonField = JsonMissing.of() - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() + private var address1: JsonField? = null + private var city: JsonField? = null + private var country: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null private var address2: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -907,11 +936,11 @@ private constructor( fun build(): VerificationAddress = VerificationAddress( - address1, - city, - country, - postalCode, - state, + checkNotNull(address1) { "`address1` is required but was not set" }, + checkNotNull(city) { "`city` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(postalCode) { "`postalCode` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, address2, additionalProperties.toImmutable(), ) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolder.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolder.kt index c26d21a2..80c0f51a 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolder.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolder.kt @@ -202,13 +202,15 @@ private constructor( fun websiteUrl(): String? = websiteUrl.getNullable("website_url") /** Globally unique identifier for the account holder. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Timestamp of when the account holder was created. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Globally unique identifier for the account. */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** * Only present when user_type == "BUSINESS". List of all entities with >25% ownership in the @@ -216,7 +218,8 @@ private constructor( */ @JsonProperty("beneficial_owner_entities") @ExcludeMissing - fun _beneficialOwnerEntities() = beneficialOwnerEntities + fun _beneficialOwnerEntities(): JsonField> = + beneficialOwnerEntities /** * Only present when user_type == "BUSINESS". List of all individuals with >25% ownership in the @@ -224,7 +227,8 @@ private constructor( */ @JsonProperty("beneficial_owner_individuals") @ExcludeMissing - fun _beneficialOwnerIndividuals() = beneficialOwnerIndividuals + fun _beneficialOwnerIndividuals(): JsonField> = + beneficialOwnerIndividuals /** * Only applicable for customers using the KYC-Exempt workflow to enroll authorized users of @@ -233,13 +237,15 @@ private constructor( */ @JsonProperty("business_account_token") @ExcludeMissing - fun _businessAccountToken() = businessAccountToken + fun _businessAccountToken(): JsonField = businessAccountToken /** * Only present when user_type == "BUSINESS". Information about the business for which the * account is being opened and KYB is being run. */ - @JsonProperty("business_entity") @ExcludeMissing fun _businessEntity() = businessEntity + @JsonProperty("business_entity") + @ExcludeMissing + fun _businessEntity(): JsonField = businessEntity /** * Only present when user_type == "BUSINESS". An individual with significant responsibility for @@ -249,45 +255,57 @@ private constructor( * cards that Lithic will provide. In some cases, this individual could also be a beneficial * owner listed above. */ - @JsonProperty("control_person") @ExcludeMissing fun _controlPerson() = controlPerson + @JsonProperty("control_person") + @ExcludeMissing + fun _controlPerson(): JsonField = controlPerson /** * < Deprecated. Use control_person.email when user_type == "BUSINESS". Use * individual.phone_number when user_type == "INDIVIDUAL". * > Primary email of Account Holder. */ - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email /** The type of KYC exemption for a KYC-Exempt Account Holder. */ - @JsonProperty("exemption_type") @ExcludeMissing fun _exemptionType() = exemptionType + @JsonProperty("exemption_type") + @ExcludeMissing + fun _exemptionType(): JsonField = exemptionType /** * Customer-provided token that indicates a relationship with an object outside of the Lithic * ecosystem. */ - @JsonProperty("external_id") @ExcludeMissing fun _externalId() = externalId + @JsonProperty("external_id") @ExcludeMissing fun _externalId(): JsonField = externalId /** * Only present when user_type == "INDIVIDUAL". Information about the individual for which the * account is being opened and KYC is being run. */ - @JsonProperty("individual") @ExcludeMissing fun _individual() = individual + @JsonProperty("individual") + @ExcludeMissing + fun _individual(): JsonField = individual /** Only present when user_type == "BUSINESS". User-submitted description of the business. */ - @JsonProperty("nature_of_business") @ExcludeMissing fun _natureOfBusiness() = natureOfBusiness + @JsonProperty("nature_of_business") + @ExcludeMissing + fun _natureOfBusiness(): JsonField = natureOfBusiness /** * < Deprecated. Use control_person.phone_number when user_type == "BUSINESS". Use * individual.phone_number when user_type == "INDIVIDUAL". * > Primary phone of Account Holder, entered in E.164 format. */ - @JsonProperty("phone_number") @ExcludeMissing fun _phoneNumber() = phoneNumber + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber /** * Only present for "KYB_BASIC" workflow. A list of documents required for the account holder to * be approved. */ - @JsonProperty("required_documents") @ExcludeMissing fun _requiredDocuments() = requiredDocuments + @JsonProperty("required_documents") + @ExcludeMissing + fun _requiredDocuments(): JsonField> = requiredDocuments /** * @@ -297,12 +315,14 @@ private constructor( * Note: * - `PENDING_REVIEW` is only applicable for the `KYB_BASIC` workflow. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** * Reason for the evaluation status. */ - @JsonProperty("status_reasons") @ExcludeMissing fun _statusReasons() = statusReasons + @JsonProperty("status_reasons") + @ExcludeMissing + fun _statusReasons(): JsonField> = statusReasons /** * The type of Account Holder. If the type is "INDIVIDUAL", the "individual" attribute will be @@ -310,15 +330,16 @@ private constructor( * "beneficial_owner_individuals", "beneficial_owner_entities", "nature_of_business", and * "website_url" attributes will be present. */ - @JsonProperty("user_type") @ExcludeMissing fun _userType() = userType + @JsonProperty("user_type") @ExcludeMissing fun _userType(): JsonField = userType /** Information about the most recent identity verification attempt */ @JsonProperty("verification_application") @ExcludeMissing - fun _verificationApplication() = verificationApplication + fun _verificationApplication(): JsonField = + verificationApplication /** Only present when user_type == "BUSINESS". Business's primary website. */ - @JsonProperty("website_url") @ExcludeMissing fun _websiteUrl() = websiteUrl + @JsonProperty("website_url") @ExcludeMissing fun _websiteUrl(): JsonField = websiteUrl @JsonAnyGetter @ExcludeMissing @@ -361,13 +382,15 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var created: JsonField? = null private var accountToken: JsonField = JsonMissing.of() - private var beneficialOwnerEntities: JsonField> = - JsonMissing.of() - private var beneficialOwnerIndividuals: JsonField> = - JsonMissing.of() + private var beneficialOwnerEntities: + JsonField>? = + null + private var beneficialOwnerIndividuals: + JsonField>? = + null private var businessAccountToken: JsonField = JsonMissing.of() private var businessEntity: JsonField = JsonMissing.of() private var controlPerson: JsonField = JsonMissing.of() @@ -377,9 +400,9 @@ private constructor( private var individual: JsonField = JsonMissing.of() private var natureOfBusiness: JsonField = JsonMissing.of() private var phoneNumber: JsonField = JsonMissing.of() - private var requiredDocuments: JsonField> = JsonMissing.of() + private var requiredDocuments: JsonField>? = null private var status: JsonField = JsonMissing.of() - private var statusReasons: JsonField> = JsonMissing.of() + private var statusReasons: JsonField>? = null private var userType: JsonField = JsonMissing.of() private var verificationApplication: JsonField = JsonMissing.of() @@ -390,8 +413,10 @@ private constructor( token = accountHolder.token created = accountHolder.created accountToken = accountHolder.accountToken - beneficialOwnerEntities = accountHolder.beneficialOwnerEntities - beneficialOwnerIndividuals = accountHolder.beneficialOwnerIndividuals + beneficialOwnerEntities = + accountHolder.beneficialOwnerEntities.map { it.toMutableList() } + beneficialOwnerIndividuals = + accountHolder.beneficialOwnerIndividuals.map { it.toMutableList() } businessAccountToken = accountHolder.businessAccountToken businessEntity = accountHolder.businessEntity controlPerson = accountHolder.controlPerson @@ -401,9 +426,9 @@ private constructor( individual = accountHolder.individual natureOfBusiness = accountHolder.natureOfBusiness phoneNumber = accountHolder.phoneNumber - requiredDocuments = accountHolder.requiredDocuments + requiredDocuments = accountHolder.requiredDocuments.map { it.toMutableList() } status = accountHolder.status - statusReasons = accountHolder.statusReasons + statusReasons = accountHolder.statusReasons.map { it.toMutableList() } userType = accountHolder.userType verificationApplication = accountHolder.verificationApplication websiteUrl = accountHolder.websiteUrl @@ -443,7 +468,24 @@ private constructor( */ fun beneficialOwnerEntities( beneficialOwnerEntities: JsonField> - ) = apply { this.beneficialOwnerEntities = beneficialOwnerEntities } + ) = apply { + this.beneficialOwnerEntities = beneficialOwnerEntities.map { it.toMutableList() } + } + + /** + * Only present when user_type == "BUSINESS". List of all entities with >25% ownership in + * the company. + */ + fun addBeneficialOwnerEntity(beneficialOwnerEntity: AccountHolderBusinessResponse) = apply { + beneficialOwnerEntities = + (beneficialOwnerEntities ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(beneficialOwnerEntity) + } + } /** * Only present when user_type == "BUSINESS". List of all individuals with >25% ownership in @@ -459,7 +501,26 @@ private constructor( */ fun beneficialOwnerIndividuals( beneficialOwnerIndividuals: JsonField> - ) = apply { this.beneficialOwnerIndividuals = beneficialOwnerIndividuals } + ) = apply { + this.beneficialOwnerIndividuals = beneficialOwnerIndividuals.map { it.toMutableList() } + } + + /** + * Only present when user_type == "BUSINESS". List of all individuals with >25% ownership in + * the company. + */ + fun addBeneficialOwnerIndividual( + beneficialOwnerIndividual: AccountHolderIndividualResponse + ) = apply { + beneficialOwnerIndividuals = + (beneficialOwnerIndividuals ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(beneficialOwnerIndividual) + } + } /** * Only applicable for customers using the KYC-Exempt workflow to enroll authorized users of @@ -604,7 +665,22 @@ private constructor( * holder to be approved. */ fun requiredDocuments(requiredDocuments: JsonField>) = apply { - this.requiredDocuments = requiredDocuments + this.requiredDocuments = requiredDocuments.map { it.toMutableList() } + } + + /** + * Only present for "KYB_BASIC" workflow. A list of documents required for the account + * holder to be approved. + */ + fun addRequiredDocument(requiredDocument: RequiredDocument) = apply { + requiredDocuments = + (requiredDocuments ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(requiredDocument) + } } /** @@ -639,7 +715,22 @@ private constructor( * status. */ fun statusReasons(statusReasons: JsonField>) = apply { - this.statusReasons = statusReasons + this.statusReasons = statusReasons.map { it.toMutableList() } + } + + /** + * Reason for the evaluation + * status. + */ + fun addStatusReason(statusReason: StatusReason) = apply { + statusReasons = + (statusReasons ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(statusReason) + } } /** @@ -694,11 +785,11 @@ private constructor( fun build(): AccountHolder = AccountHolder( - token, - created, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, accountToken, - beneficialOwnerEntities.map { it.toImmutable() }, - beneficialOwnerIndividuals.map { it.toImmutable() }, + (beneficialOwnerEntities ?: JsonMissing.of()).map { it.toImmutable() }, + (beneficialOwnerIndividuals ?: JsonMissing.of()).map { it.toImmutable() }, businessAccountToken, businessEntity, controlPerson, @@ -708,9 +799,9 @@ private constructor( individual, natureOfBusiness, phoneNumber, - requiredDocuments.map { it.toImmutable() }, + (requiredDocuments ?: JsonMissing.of()).map { it.toImmutable() }, status, - statusReasons.map { it.toImmutable() }, + (statusReasons ?: JsonMissing.of()).map { it.toImmutable() }, userType, verificationApplication, websiteUrl, @@ -781,33 +872,43 @@ private constructor( * Business's physical address - PO boxes, UPS drops, and FedEx drops are not acceptable; * APO/FPO are acceptable. */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") @ExcludeMissing fun _address(): JsonField
= address /** * Any name that the business operates under that is not its legal business name (if * applicable). */ - @JsonProperty("dba_business_name") @ExcludeMissing fun _dbaBusinessName() = dbaBusinessName + @JsonProperty("dba_business_name") + @ExcludeMissing + fun _dbaBusinessName(): JsonField = dbaBusinessName /** Globally unique identifier for the entity. */ - @JsonProperty("entity_token") @ExcludeMissing fun _entityToken() = entityToken + @JsonProperty("entity_token") + @ExcludeMissing + fun _entityToken(): JsonField = entityToken /** * Government-issued identification number. US Federal Employer Identification Numbers (EIN) * are currently supported, entered as full nine-digits, with or without hyphens. */ - @JsonProperty("government_id") @ExcludeMissing fun _governmentId() = governmentId + @JsonProperty("government_id") + @ExcludeMissing + fun _governmentId(): JsonField = governmentId /** Legal (formal) business name. */ @JsonProperty("legal_business_name") @ExcludeMissing - fun _legalBusinessName() = legalBusinessName + fun _legalBusinessName(): JsonField = legalBusinessName /** One or more of the business's phone number(s), entered as a list in E.164 format. */ - @JsonProperty("phone_numbers") @ExcludeMissing fun _phoneNumbers() = phoneNumbers + @JsonProperty("phone_numbers") + @ExcludeMissing + fun _phoneNumbers(): JsonField> = phoneNumbers /** Parent company name (if applicable). */ - @JsonProperty("parent_company") @ExcludeMissing fun _parentCompany() = parentCompany + @JsonProperty("parent_company") + @ExcludeMissing + fun _parentCompany(): JsonField = parentCompany @JsonAnyGetter @ExcludeMissing @@ -837,12 +938,12 @@ private constructor( class Builder { - private var address: JsonField
= JsonMissing.of() - private var dbaBusinessName: JsonField = JsonMissing.of() - private var entityToken: JsonField = JsonMissing.of() - private var governmentId: JsonField = JsonMissing.of() - private var legalBusinessName: JsonField = JsonMissing.of() - private var phoneNumbers: JsonField> = JsonMissing.of() + private var address: JsonField
? = null + private var dbaBusinessName: JsonField? = null + private var entityToken: JsonField? = null + private var governmentId: JsonField? = null + private var legalBusinessName: JsonField? = null + private var phoneNumbers: JsonField>? = null private var parentCompany: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -853,7 +954,8 @@ private constructor( entityToken = accountHolderBusinessResponse.entityToken governmentId = accountHolderBusinessResponse.governmentId legalBusinessName = accountHolderBusinessResponse.legalBusinessName - phoneNumbers = accountHolderBusinessResponse.phoneNumbers + phoneNumbers = + accountHolderBusinessResponse.phoneNumbers.map { it.toMutableList() } parentCompany = accountHolderBusinessResponse.parentCompany additionalProperties = accountHolderBusinessResponse.additionalProperties.toMutableMap() @@ -922,7 +1024,19 @@ private constructor( /** One or more of the business's phone number(s), entered as a list in E.164 format. */ fun phoneNumbers(phoneNumbers: JsonField>) = apply { - this.phoneNumbers = phoneNumbers + this.phoneNumbers = phoneNumbers.map { it.toMutableList() } + } + + /** One or more of the business's phone number(s), entered as a list in E.164 format. */ + fun addPhoneNumber(phoneNumber: String) = apply { + phoneNumbers = + (phoneNumbers ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(phoneNumber) + } } /** Parent company name (if applicable). */ @@ -954,12 +1068,17 @@ private constructor( fun build(): AccountHolderBusinessResponse = AccountHolderBusinessResponse( - address, - dbaBusinessName, - entityToken, - governmentId, - legalBusinessName, - phoneNumbers.map { it.toImmutable() }, + checkNotNull(address) { "`address` is required but was not set" }, + checkNotNull(dbaBusinessName) { + "`dbaBusinessName` is required but was not set" + }, + checkNotNull(entityToken) { "`entityToken` is required but was not set" }, + checkNotNull(governmentId) { "`governmentId` is required but was not set" }, + checkNotNull(legalBusinessName) { + "`legalBusinessName` is required but was not set" + }, + checkNotNull(phoneNumbers) { "`phoneNumbers` is required but was not set" } + .map { it.toImmutable() }, parentCompany, additionalProperties.toImmutable(), ) @@ -1036,25 +1155,29 @@ private constructor( fun phoneNumber(): String = phoneNumber.getRequired("phone_number") /** Individual's current address */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") @ExcludeMissing fun _address(): JsonField
= address /** Individual's date of birth, as an RFC 3339 date. */ - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** Individual's email address. */ - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email /** Globally unique identifier for the entity. */ - @JsonProperty("entity_token") @ExcludeMissing fun _entityToken() = entityToken + @JsonProperty("entity_token") + @ExcludeMissing + fun _entityToken(): JsonField = entityToken /** Individual's first name, as it appears on government-issued identity documents. */ - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** Individual's last name, as it appears on government-issued identity documents. */ - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName /** Individual's phone number, entered in E.164 format. */ - @JsonProperty("phone_number") @ExcludeMissing fun _phoneNumber() = phoneNumber + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber @JsonAnyGetter @ExcludeMissing @@ -1084,13 +1207,13 @@ private constructor( class Builder { - private var address: JsonField
= JsonMissing.of() - private var dob: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var entityToken: JsonField = JsonMissing.of() - private var firstName: JsonField = JsonMissing.of() - private var lastName: JsonField = JsonMissing.of() - private var phoneNumber: JsonField = JsonMissing.of() + private var address: JsonField
? = null + private var dob: JsonField? = null + private var email: JsonField? = null + private var entityToken: JsonField? = null + private var firstName: JsonField? = null + private var lastName: JsonField? = null + private var phoneNumber: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(accountHolderIndividualResponse: AccountHolderIndividualResponse) = @@ -1173,13 +1296,13 @@ private constructor( fun build(): AccountHolderIndividualResponse = AccountHolderIndividualResponse( - address, - dob, - email, - entityToken, - firstName, - lastName, - phoneNumber, + checkNotNull(address) { "`address` is required but was not set" }, + checkNotNull(dob) { "`dob` is required but was not set" }, + checkNotNull(email) { "`email` is required but was not set" }, + checkNotNull(entityToken) { "`entityToken` is required but was not set" }, + checkNotNull(firstName) { "`firstName` is required but was not set" }, + checkNotNull(lastName) { "`lastName` is required but was not set" }, + checkNotNull(phoneNumber) { "`phoneNumber` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1541,7 +1664,7 @@ private constructor( fun updated(): OffsetDateTime? = updated.getNullable("updated") /** Timestamp of when the application was created. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** * KYC and KYB evaluation states. @@ -1549,13 +1672,15 @@ private constructor( * Note: * - `PENDING_REVIEW` is only applicable for the `KYB_BASIC` workflow. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** Reason for the evaluation status. */ - @JsonProperty("status_reasons") @ExcludeMissing fun _statusReasons() = statusReasons + @JsonProperty("status_reasons") + @ExcludeMissing + fun _statusReasons(): JsonField> = statusReasons /** Timestamp of when the application was last updated. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated @JsonAnyGetter @ExcludeMissing @@ -1584,7 +1709,7 @@ private constructor( private var created: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() - private var statusReasons: JsonField> = JsonMissing.of() + private var statusReasons: JsonField>? = null private var updated: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1593,7 +1718,8 @@ private constructor( ) = apply { created = accountHolderVerificationApplication.created status = accountHolderVerificationApplication.status - statusReasons = accountHolderVerificationApplication.statusReasons + statusReasons = + accountHolderVerificationApplication.statusReasons.map { it.toMutableList() } updated = accountHolderVerificationApplication.updated additionalProperties = accountHolderVerificationApplication.additionalProperties.toMutableMap() @@ -1627,7 +1753,19 @@ private constructor( /** Reason for the evaluation status. */ fun statusReasons(statusReasons: JsonField>) = apply { - this.statusReasons = statusReasons + this.statusReasons = statusReasons.map { it.toMutableList() } + } + + /** Reason for the evaluation status. */ + fun addStatusReason(statusReason: StatusReason) = apply { + statusReasons = + (statusReasons ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(statusReason) + } } /** Timestamp of when the application was last updated. */ @@ -1659,7 +1797,7 @@ private constructor( AccountHolderVerificationApplication( created, status, - statusReasons.map { it.toImmutable() }, + (statusReasons ?: JsonMissing.of()).map { it.toImmutable() }, updated, additionalProperties.toImmutable(), ) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderCreateResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderCreateResponse.kt index 9693420c..5b99907c 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderCreateResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderCreateResponse.kt @@ -78,10 +78,12 @@ private constructor( requiredDocuments.getNullable("required_documents") /** Globally unique identifier for the account holder. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Globally unique identifier for the account. */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** * KYC and KYB evaluation states. @@ -89,25 +91,29 @@ private constructor( * Note: * - `PENDING_REVIEW` is only applicable for the `KYB_BASIC` workflow. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** Reason for the evaluation status. */ - @JsonProperty("status_reasons") @ExcludeMissing fun _statusReasons() = statusReasons + @JsonProperty("status_reasons") + @ExcludeMissing + fun _statusReasons(): JsonField> = statusReasons /** Timestamp of when the account holder was created. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** * Customer-provided token that indicates a relationship with an object outside of the Lithic * ecosystem. */ - @JsonProperty("external_id") @ExcludeMissing fun _externalId() = externalId + @JsonProperty("external_id") @ExcludeMissing fun _externalId(): JsonField = externalId /** * Only present for "KYB_BASIC" workflow. A list of documents required for the account holder to * be approved. */ - @JsonProperty("required_documents") @ExcludeMissing fun _requiredDocuments() = requiredDocuments + @JsonProperty("required_documents") + @ExcludeMissing + fun _requiredDocuments(): JsonField> = requiredDocuments @JsonAnyGetter @ExcludeMissing @@ -137,23 +143,24 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountToken: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var statusReasons: JsonField> = JsonMissing.of() + private var token: JsonField? = null + private var accountToken: JsonField? = null + private var status: JsonField? = null + private var statusReasons: JsonField>? = null private var created: JsonField = JsonMissing.of() private var externalId: JsonField = JsonMissing.of() - private var requiredDocuments: JsonField> = JsonMissing.of() + private var requiredDocuments: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(accountHolderCreateResponse: AccountHolderCreateResponse) = apply { token = accountHolderCreateResponse.token accountToken = accountHolderCreateResponse.accountToken status = accountHolderCreateResponse.status - statusReasons = accountHolderCreateResponse.statusReasons + statusReasons = accountHolderCreateResponse.statusReasons.map { it.toMutableList() } created = accountHolderCreateResponse.created externalId = accountHolderCreateResponse.externalId - requiredDocuments = accountHolderCreateResponse.requiredDocuments + requiredDocuments = + accountHolderCreateResponse.requiredDocuments.map { it.toMutableList() } additionalProperties = accountHolderCreateResponse.additionalProperties.toMutableMap() } @@ -193,7 +200,19 @@ private constructor( /** Reason for the evaluation status. */ fun statusReasons(statusReasons: JsonField>) = apply { - this.statusReasons = statusReasons + this.statusReasons = statusReasons.map { it.toMutableList() } + } + + /** Reason for the evaluation status. */ + fun addStatusReason(statusReason: StatusReasons) = apply { + statusReasons = + (statusReasons ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(statusReason) + } } /** Timestamp of when the account holder was created. */ @@ -226,7 +245,22 @@ private constructor( * holder to be approved. */ fun requiredDocuments(requiredDocuments: JsonField>) = apply { - this.requiredDocuments = requiredDocuments + this.requiredDocuments = requiredDocuments.map { it.toMutableList() } + } + + /** + * Only present for "KYB_BASIC" workflow. A list of documents required for the account + * holder to be approved. + */ + fun addRequiredDocument(requiredDocument: RequiredDocument) = apply { + requiredDocuments = + (requiredDocuments ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(requiredDocument) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -250,13 +284,14 @@ private constructor( fun build(): AccountHolderCreateResponse = AccountHolderCreateResponse( - token, - accountToken, - status, - statusReasons.map { it.toImmutable() }, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountToken) { "`accountToken` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(statusReasons) { "`statusReasons` is required but was not set" } + .map { it.toImmutable() }, created, externalId, - requiredDocuments.map { it.toImmutable() }, + (requiredDocuments ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderListDocumentsResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderListDocumentsResponse.kt index 6eb2863c..09fad15e 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderListDocumentsResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderListDocumentsResponse.kt @@ -27,7 +27,7 @@ private constructor( fun data(): List? = data.getNullable("data") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonAnyGetter @ExcludeMissing @@ -51,19 +51,32 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(accountHolderListDocumentsResponse: AccountHolderListDocumentsResponse) = apply { - data = accountHolderListDocumentsResponse.data + data = accountHolderListDocumentsResponse.data.map { it.toMutableList() } additionalProperties = accountHolderListDocumentsResponse.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: Document) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(data) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -86,7 +99,7 @@ private constructor( fun build(): AccountHolderListDocumentsResponse = AccountHolderListDocumentsResponse( - data.map { it.toImmutable() }, + (data ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable() ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentDocumentReviewParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentDocumentReviewParams.kt index 09c69e2e..5ec7ef9f 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentDocumentReviewParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentDocumentReviewParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -41,12 +42,28 @@ constructor( */ fun statusReason(): DocumentUploadStatusReasons? = body.statusReason() - fun _additionalHeaders(): Headers = additionalHeaders + /** The account holder document upload which to perform the simulation upon. */ + fun _documentUploadToken(): JsonField = body._documentUploadToken() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** An account holder document's upload status for use within the simulation. */ + fun _status(): JsonField = body._status() + + /** A list of status reasons associated with a KYB account holder in PENDING_REVIEW */ + fun _acceptedEntityStatusReasons(): JsonField> = + body._acceptedEntityStatusReasons() + + /** + * Status reason that will be associated with the simulated account holder status. Only required + * for a `REJECTED` status or `PARTIAL_APPROVAL` status. + */ + fun _statusReason(): JsonField = body._statusReason() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): AccountHolderSimulateEnrollmentDocumentReviewBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -57,37 +74,75 @@ constructor( class AccountHolderSimulateEnrollmentDocumentReviewBody @JsonCreator internal constructor( - @JsonProperty("document_upload_token") private val documentUploadToken: String, - @JsonProperty("status") private val status: Status, + @JsonProperty("document_upload_token") + @ExcludeMissing + private val documentUploadToken: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), @JsonProperty("accepted_entity_status_reasons") - private val acceptedEntityStatusReasons: List?, - @JsonProperty("status_reason") private val statusReason: DocumentUploadStatusReasons?, + @ExcludeMissing + private val acceptedEntityStatusReasons: JsonField> = JsonMissing.of(), + @JsonProperty("status_reason") + @ExcludeMissing + private val statusReason: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The account holder document upload which to perform the simulation upon. */ + fun documentUploadToken(): String = documentUploadToken.getRequired("document_upload_token") + + /** An account holder document's upload status for use within the simulation. */ + fun status(): Status = status.getRequired("status") + + /** A list of status reasons associated with a KYB account holder in PENDING_REVIEW */ + fun acceptedEntityStatusReasons(): List? = + acceptedEntityStatusReasons.getNullable("accepted_entity_status_reasons") + + /** + * Status reason that will be associated with the simulated account holder status. Only + * required for a `REJECTED` status or `PARTIAL_APPROVAL` status. + */ + fun statusReason(): DocumentUploadStatusReasons? = statusReason.getNullable("status_reason") + /** The account holder document upload which to perform the simulation upon. */ @JsonProperty("document_upload_token") - fun documentUploadToken(): String = documentUploadToken + @ExcludeMissing + fun _documentUploadToken(): JsonField = documentUploadToken /** An account holder document's upload status for use within the simulation. */ - @JsonProperty("status") fun status(): Status = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** A list of status reasons associated with a KYB account holder in PENDING_REVIEW */ @JsonProperty("accepted_entity_status_reasons") - fun acceptedEntityStatusReasons(): List? = acceptedEntityStatusReasons + @ExcludeMissing + fun _acceptedEntityStatusReasons(): JsonField> = acceptedEntityStatusReasons /** * Status reason that will be associated with the simulated account holder status. Only * required for a `REJECTED` status or `PARTIAL_APPROVAL` status. */ @JsonProperty("status_reason") - fun statusReason(): DocumentUploadStatusReasons? = statusReason + @ExcludeMissing + fun _statusReason(): JsonField = statusReason @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AccountHolderSimulateEnrollmentDocumentReviewBody = apply { + if (!validated) { + documentUploadToken() + status() + acceptedEntityStatusReasons() + statusReason() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -97,10 +152,10 @@ constructor( class Builder { - private var documentUploadToken: String? = null - private var status: Status? = null - private var acceptedEntityStatusReasons: MutableList? = null - private var statusReason: DocumentUploadStatusReasons? = null + private var documentUploadToken: JsonField? = null + private var status: JsonField? = null + private var acceptedEntityStatusReasons: JsonField>? = null + private var statusReason: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -112,7 +167,7 @@ constructor( status = accountHolderSimulateEnrollmentDocumentReviewBody.status acceptedEntityStatusReasons = accountHolderSimulateEnrollmentDocumentReviewBody.acceptedEntityStatusReasons - ?.toMutableList() + .map { it.toMutableList() } statusReason = accountHolderSimulateEnrollmentDocumentReviewBody.statusReason additionalProperties = accountHolderSimulateEnrollmentDocumentReviewBody.additionalProperties @@ -120,23 +175,40 @@ constructor( } /** The account holder document upload which to perform the simulation upon. */ - fun documentUploadToken(documentUploadToken: String) = apply { + fun documentUploadToken(documentUploadToken: String) = + documentUploadToken(JsonField.of(documentUploadToken)) + + /** The account holder document upload which to perform the simulation upon. */ + fun documentUploadToken(documentUploadToken: JsonField) = apply { this.documentUploadToken = documentUploadToken } /** An account holder document's upload status for use within the simulation. */ - fun status(status: Status) = apply { this.status = status } + fun status(status: Status) = status(JsonField.of(status)) + + /** An account holder document's upload status for use within the simulation. */ + fun status(status: JsonField) = apply { this.status = status } /** A list of status reasons associated with a KYB account holder in PENDING_REVIEW */ - fun acceptedEntityStatusReasons(acceptedEntityStatusReasons: List?) = apply { - this.acceptedEntityStatusReasons = acceptedEntityStatusReasons?.toMutableList() - } + fun acceptedEntityStatusReasons(acceptedEntityStatusReasons: List) = + acceptedEntityStatusReasons(JsonField.of(acceptedEntityStatusReasons)) + + /** A list of status reasons associated with a KYB account holder in PENDING_REVIEW */ + fun acceptedEntityStatusReasons(acceptedEntityStatusReasons: JsonField>) = + apply { + this.acceptedEntityStatusReasons = + acceptedEntityStatusReasons.map { it.toMutableList() } + } /** A list of status reasons associated with a KYB account holder in PENDING_REVIEW */ fun addAcceptedEntityStatusReason(acceptedEntityStatusReason: String) = apply { acceptedEntityStatusReasons = - (acceptedEntityStatusReasons ?: mutableListOf()).apply { - add(acceptedEntityStatusReason) + (acceptedEntityStatusReasons ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(acceptedEntityStatusReason) } } @@ -144,7 +216,14 @@ constructor( * Status reason that will be associated with the simulated account holder status. Only * required for a `REJECTED` status or `PARTIAL_APPROVAL` status. */ - fun statusReason(statusReason: DocumentUploadStatusReasons?) = apply { + fun statusReason(statusReason: DocumentUploadStatusReasons) = + statusReason(JsonField.of(statusReason)) + + /** + * Status reason that will be associated with the simulated account holder status. Only + * required for a `REJECTED` status or `PARTIAL_APPROVAL` status. + */ + fun statusReason(statusReason: JsonField) = apply { this.statusReason = statusReason } @@ -173,7 +252,7 @@ constructor( "`documentUploadToken` is required but was not set" }, checkNotNull(status) { "`status` is required but was not set" }, - acceptedEntityStatusReasons?.toImmutable(), + (acceptedEntityStatusReasons ?: JsonMissing.of()).map { it.toImmutable() }, statusReason, additionalProperties.toImmutable(), ) @@ -229,14 +308,28 @@ constructor( body.documentUploadToken(documentUploadToken) } + /** The account holder document upload which to perform the simulation upon. */ + fun documentUploadToken(documentUploadToken: JsonField) = apply { + body.documentUploadToken(documentUploadToken) + } + /** An account holder document's upload status for use within the simulation. */ fun status(status: Status) = apply { body.status(status) } + /** An account holder document's upload status for use within the simulation. */ + fun status(status: JsonField) = apply { body.status(status) } + /** A list of status reasons associated with a KYB account holder in PENDING_REVIEW */ - fun acceptedEntityStatusReasons(acceptedEntityStatusReasons: List?) = apply { + fun acceptedEntityStatusReasons(acceptedEntityStatusReasons: List) = apply { body.acceptedEntityStatusReasons(acceptedEntityStatusReasons) } + /** A list of status reasons associated with a KYB account holder in PENDING_REVIEW */ + fun acceptedEntityStatusReasons(acceptedEntityStatusReasons: JsonField>) = + apply { + body.acceptedEntityStatusReasons(acceptedEntityStatusReasons) + } + /** A list of status reasons associated with a KYB account holder in PENDING_REVIEW */ fun addAcceptedEntityStatusReason(acceptedEntityStatusReason: String) = apply { body.addAcceptedEntityStatusReason(acceptedEntityStatusReason) @@ -246,10 +339,37 @@ constructor( * Status reason that will be associated with the simulated account holder status. Only * required for a `REJECTED` status or `PARTIAL_APPROVAL` status. */ - fun statusReason(statusReason: DocumentUploadStatusReasons?) = apply { + fun statusReason(statusReason: DocumentUploadStatusReasons) = apply { body.statusReason(statusReason) } + /** + * Status reason that will be associated with the simulated account holder status. Only + * required for a `REJECTED` status or `PARTIAL_APPROVAL` status. + */ + fun statusReason(statusReason: JsonField) = apply { + body.statusReason(statusReason) + } + + 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) @@ -348,25 +468,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): AccountHolderSimulateEnrollmentDocumentReviewParams = AccountHolderSimulateEnrollmentDocumentReviewParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewParams.kt index 1f38e2ed..fc979d31 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -41,12 +42,24 @@ constructor( */ fun statusReasons(): List? = body.statusReasons() - fun _additionalHeaders(): Headers = additionalHeaders + /** The account holder which to perform the simulation upon. */ + fun _accountHolderToken(): JsonField = body._accountHolderToken() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** An account holder's status for use within the simulation. */ + fun _status(): JsonField = body._status() + + /** + * Status reason that will be associated with the simulated account holder status. Only required + * for a `REJECTED` status. + */ + fun _statusReasons(): JsonField> = body._statusReasons() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): AccountHolderSimulateEnrollmentReviewBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -57,29 +70,62 @@ constructor( class AccountHolderSimulateEnrollmentReviewBody @JsonCreator internal constructor( - @JsonProperty("account_holder_token") private val accountHolderToken: String?, - @JsonProperty("status") private val status: Status?, - @JsonProperty("status_reasons") private val statusReasons: List?, + @JsonProperty("account_holder_token") + @ExcludeMissing + private val accountHolderToken: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), + @JsonProperty("status_reasons") + @ExcludeMissing + private val statusReasons: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The account holder which to perform the simulation upon. */ - @JsonProperty("account_holder_token") fun accountHolderToken(): String? = accountHolderToken + fun accountHolderToken(): String? = accountHolderToken.getNullable("account_holder_token") + + /** An account holder's status for use within the simulation. */ + fun status(): Status? = status.getNullable("status") + + /** + * Status reason that will be associated with the simulated account holder status. Only + * required for a `REJECTED` status. + */ + fun statusReasons(): List? = statusReasons.getNullable("status_reasons") + + /** The account holder which to perform the simulation upon. */ + @JsonProperty("account_holder_token") + @ExcludeMissing + fun _accountHolderToken(): JsonField = accountHolderToken /** An account holder's status for use within the simulation. */ - @JsonProperty("status") fun status(): Status? = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** * Status reason that will be associated with the simulated account holder status. Only * required for a `REJECTED` status. */ - @JsonProperty("status_reasons") fun statusReasons(): List? = statusReasons + @JsonProperty("status_reasons") + @ExcludeMissing + fun _statusReasons(): JsonField> = statusReasons @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AccountHolderSimulateEnrollmentReviewBody = apply { + if (!validated) { + accountHolderToken() + status() + statusReasons() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -89,9 +135,9 @@ constructor( class Builder { - private var accountHolderToken: String? = null - private var status: Status? = null - private var statusReasons: MutableList? = null + private var accountHolderToken: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var statusReasons: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -100,25 +146,41 @@ constructor( accountHolderToken = accountHolderSimulateEnrollmentReviewBody.accountHolderToken status = accountHolderSimulateEnrollmentReviewBody.status statusReasons = - accountHolderSimulateEnrollmentReviewBody.statusReasons?.toMutableList() + accountHolderSimulateEnrollmentReviewBody.statusReasons.map { + it.toMutableList() + } additionalProperties = accountHolderSimulateEnrollmentReviewBody.additionalProperties.toMutableMap() } /** The account holder which to perform the simulation upon. */ - fun accountHolderToken(accountHolderToken: String?) = apply { + fun accountHolderToken(accountHolderToken: String) = + accountHolderToken(JsonField.of(accountHolderToken)) + + /** The account holder which to perform the simulation upon. */ + fun accountHolderToken(accountHolderToken: JsonField) = apply { this.accountHolderToken = accountHolderToken } /** An account holder's status for use within the simulation. */ - fun status(status: Status?) = apply { this.status = status } + fun status(status: Status) = status(JsonField.of(status)) + + /** An account holder's status for use within the simulation. */ + fun status(status: JsonField) = apply { this.status = status } /** * Status reason that will be associated with the simulated account holder status. Only * required for a `REJECTED` status. */ - fun statusReasons(statusReasons: List?) = apply { - this.statusReasons = statusReasons?.toMutableList() + fun statusReasons(statusReasons: List) = + statusReasons(JsonField.of(statusReasons)) + + /** + * Status reason that will be associated with the simulated account holder status. Only + * required for a `REJECTED` status. + */ + fun statusReasons(statusReasons: JsonField>) = apply { + this.statusReasons = statusReasons.map { it.toMutableList() } } /** @@ -126,7 +188,14 @@ constructor( * required for a `REJECTED` status. */ fun addStatusReason(statusReason: StatusReason) = apply { - statusReasons = (statusReasons ?: mutableListOf()).apply { add(statusReason) } + statusReasons = + (statusReasons ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(statusReason) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -152,7 +221,7 @@ constructor( AccountHolderSimulateEnrollmentReviewBody( accountHolderToken, status, - statusReasons?.toImmutable(), + (statusReasons ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -201,18 +270,34 @@ constructor( } /** The account holder which to perform the simulation upon. */ - fun accountHolderToken(accountHolderToken: String?) = apply { + fun accountHolderToken(accountHolderToken: String) = apply { body.accountHolderToken(accountHolderToken) } + /** The account holder which to perform the simulation upon. */ + fun accountHolderToken(accountHolderToken: JsonField) = apply { + body.accountHolderToken(accountHolderToken) + } + + /** An account holder's status for use within the simulation. */ + fun status(status: Status) = apply { body.status(status) } + /** An account holder's status for use within the simulation. */ - fun status(status: Status?) = apply { body.status(status) } + fun status(status: JsonField) = apply { body.status(status) } + + /** + * Status reason that will be associated with the simulated account holder status. Only + * required for a `REJECTED` status. + */ + fun statusReasons(statusReasons: List) = apply { + body.statusReasons(statusReasons) + } /** * Status reason that will be associated with the simulated account holder status. Only * required for a `REJECTED` status. */ - fun statusReasons(statusReasons: List?) = apply { + fun statusReasons(statusReasons: JsonField>) = apply { body.statusReasons(statusReasons) } @@ -224,6 +309,25 @@ constructor( body.addStatusReason(statusReason) } + 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) @@ -322,25 +426,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): AccountHolderSimulateEnrollmentReviewParams = AccountHolderSimulateEnrollmentReviewParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewResponse.kt index d790fc39..9835de2d 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewResponse.kt @@ -207,10 +207,12 @@ private constructor( fun websiteUrl(): String? = websiteUrl.getNullable("website_url") /** Globally unique identifier for the account holder. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Globally unique identifier for the account. */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** * Only present when user_type == "BUSINESS". List of all entities with >25% ownership in the @@ -218,7 +220,7 @@ private constructor( */ @JsonProperty("beneficial_owner_entities") @ExcludeMissing - fun _beneficialOwnerEntities() = beneficialOwnerEntities + fun _beneficialOwnerEntities(): JsonField> = beneficialOwnerEntities /** * Only present when user_type == "BUSINESS". List of all individuals with >25% ownership in the @@ -226,7 +228,7 @@ private constructor( */ @JsonProperty("beneficial_owner_individuals") @ExcludeMissing - fun _beneficialOwnerIndividuals() = beneficialOwnerIndividuals + fun _beneficialOwnerIndividuals(): JsonField> = beneficialOwnerIndividuals /** * Only applicable for customers using the KYC-Exempt workflow to enroll authorized users of @@ -235,13 +237,15 @@ private constructor( */ @JsonProperty("business_account_token") @ExcludeMissing - fun _businessAccountToken() = businessAccountToken + fun _businessAccountToken(): JsonField = businessAccountToken /** * Only present when user_type == "BUSINESS". Information about the business for which the * account is being opened and KYB is being run. */ - @JsonProperty("business_entity") @ExcludeMissing fun _businessEntity() = businessEntity + @JsonProperty("business_entity") + @ExcludeMissing + fun _businessEntity(): JsonField = businessEntity /** * Only present when user_type == "BUSINESS". @@ -255,51 +259,63 @@ private constructor( * to the cards that Lithic will provide. In some cases, this individual could also be a * beneficial owner listed above. */ - @JsonProperty("control_person") @ExcludeMissing fun _controlPerson() = controlPerson + @JsonProperty("control_person") + @ExcludeMissing + fun _controlPerson(): JsonField = controlPerson /** Timestamp of when the account holder was created. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** * < Deprecated. Use control_person.email when user_type == "BUSINESS". Use * individual.phone_number when user_type == "INDIVIDUAL". * > Primary email of Account Holder. */ - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email /** * The type of KYC exemption for a KYC-Exempt Account Holder. "None" if the account holder is * not KYC-Exempt. */ - @JsonProperty("exemption_type") @ExcludeMissing fun _exemptionType() = exemptionType + @JsonProperty("exemption_type") + @ExcludeMissing + fun _exemptionType(): JsonField = exemptionType /** * Customer-provided token that indicates a relationship with an object outside of the Lithic * ecosystem. */ - @JsonProperty("external_id") @ExcludeMissing fun _externalId() = externalId + @JsonProperty("external_id") @ExcludeMissing fun _externalId(): JsonField = externalId /** * Only present when user_type == "INDIVIDUAL". Information about the individual for which the * account is being opened and KYC is being run. */ - @JsonProperty("individual") @ExcludeMissing fun _individual() = individual + @JsonProperty("individual") + @ExcludeMissing + fun _individual(): JsonField = individual /** Only present when user_type == "BUSINESS". User-submitted description of the business. */ - @JsonProperty("nature_of_business") @ExcludeMissing fun _natureOfBusiness() = natureOfBusiness + @JsonProperty("nature_of_business") + @ExcludeMissing + fun _natureOfBusiness(): JsonField = natureOfBusiness /** * < Deprecated. Use control_person.phone_number when user_type == "BUSINESS". Use * individual.phone_number when user_type == "INDIVIDUAL". * > Primary phone of Account Holder, entered in E.164 format. */ - @JsonProperty("phone_number") @ExcludeMissing fun _phoneNumber() = phoneNumber + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber /** * Only present for "KYB_BASIC" and "KYC_ADVANCED" workflows. A list of documents required for * the account holder to be approved. */ - @JsonProperty("required_documents") @ExcludeMissing fun _requiredDocuments() = requiredDocuments + @JsonProperty("required_documents") + @ExcludeMissing + fun _requiredDocuments(): JsonField> = requiredDocuments /** * @@ -309,12 +325,14 @@ private constructor( * Note: `PENDING_RESUBMIT` and `PENDING_DOCUMENT` are only applicable for the `ADVANCED` * workflow. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** * Reason for the evaluation status. */ - @JsonProperty("status_reasons") @ExcludeMissing fun _statusReasons() = statusReasons + @JsonProperty("status_reasons") + @ExcludeMissing + fun _statusReasons(): JsonField> = statusReasons /** * The type of Account Holder. If the type is "INDIVIDUAL", the "individual" attribute will be @@ -325,15 +343,15 @@ private constructor( * * "nature_of_business", and "website_url" attributes will be present. */ - @JsonProperty("user_type") @ExcludeMissing fun _userType() = userType + @JsonProperty("user_type") @ExcludeMissing fun _userType(): JsonField = userType /** Information about the most recent identity verification attempt */ @JsonProperty("verification_application") @ExcludeMissing - fun _verificationApplication() = verificationApplication + fun _verificationApplication(): JsonField = verificationApplication /** Only present when user_type == "BUSINESS". Business's primary website. */ - @JsonProperty("website_url") @ExcludeMissing fun _websiteUrl() = websiteUrl + @JsonProperty("website_url") @ExcludeMissing fun _websiteUrl(): JsonField = websiteUrl @JsonAnyGetter @ExcludeMissing @@ -378,8 +396,8 @@ private constructor( private var token: JsonField = JsonMissing.of() private var accountToken: JsonField = JsonMissing.of() - private var beneficialOwnerEntities: JsonField> = JsonMissing.of() - private var beneficialOwnerIndividuals: JsonField> = JsonMissing.of() + private var beneficialOwnerEntities: JsonField>? = null + private var beneficialOwnerIndividuals: JsonField>? = null private var businessAccountToken: JsonField = JsonMissing.of() private var businessEntity: JsonField = JsonMissing.of() private var controlPerson: JsonField = JsonMissing.of() @@ -390,9 +408,9 @@ private constructor( private var individual: JsonField = JsonMissing.of() private var natureOfBusiness: JsonField = JsonMissing.of() private var phoneNumber: JsonField = JsonMissing.of() - private var requiredDocuments: JsonField> = JsonMissing.of() + private var requiredDocuments: JsonField>? = null private var status: JsonField = JsonMissing.of() - private var statusReasons: JsonField> = JsonMissing.of() + private var statusReasons: JsonField>? = null private var userType: JsonField = JsonMissing.of() private var verificationApplication: JsonField = JsonMissing.of() private var websiteUrl: JsonField = JsonMissing.of() @@ -405,9 +423,13 @@ private constructor( token = accountHolderSimulateEnrollmentReviewResponse.token accountToken = accountHolderSimulateEnrollmentReviewResponse.accountToken beneficialOwnerEntities = - accountHolderSimulateEnrollmentReviewResponse.beneficialOwnerEntities + accountHolderSimulateEnrollmentReviewResponse.beneficialOwnerEntities.map { + it.toMutableList() + } beneficialOwnerIndividuals = - accountHolderSimulateEnrollmentReviewResponse.beneficialOwnerIndividuals + accountHolderSimulateEnrollmentReviewResponse.beneficialOwnerIndividuals.map { + it.toMutableList() + } businessAccountToken = accountHolderSimulateEnrollmentReviewResponse.businessAccountToken businessEntity = accountHolderSimulateEnrollmentReviewResponse.businessEntity @@ -419,9 +441,15 @@ private constructor( individual = accountHolderSimulateEnrollmentReviewResponse.individual natureOfBusiness = accountHolderSimulateEnrollmentReviewResponse.natureOfBusiness phoneNumber = accountHolderSimulateEnrollmentReviewResponse.phoneNumber - requiredDocuments = accountHolderSimulateEnrollmentReviewResponse.requiredDocuments + requiredDocuments = + accountHolderSimulateEnrollmentReviewResponse.requiredDocuments.map { + it.toMutableList() + } status = accountHolderSimulateEnrollmentReviewResponse.status - statusReasons = accountHolderSimulateEnrollmentReviewResponse.statusReasons + statusReasons = + accountHolderSimulateEnrollmentReviewResponse.statusReasons.map { + it.toMutableList() + } userType = accountHolderSimulateEnrollmentReviewResponse.userType verificationApplication = accountHolderSimulateEnrollmentReviewResponse.verificationApplication @@ -457,9 +485,24 @@ private constructor( */ fun beneficialOwnerEntities(beneficialOwnerEntities: JsonField>) = apply { - this.beneficialOwnerEntities = beneficialOwnerEntities + this.beneficialOwnerEntities = beneficialOwnerEntities.map { it.toMutableList() } } + /** + * Only present when user_type == "BUSINESS". List of all entities with >25% ownership in + * the company. + */ + fun addBeneficialOwnerEntity(beneficialOwnerEntity: KybBusinessEntity) = apply { + beneficialOwnerEntities = + (beneficialOwnerEntities ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(beneficialOwnerEntity) + } + } + /** * Only present when user_type == "BUSINESS". List of all individuals with >25% ownership in * the company. @@ -473,9 +516,25 @@ private constructor( */ fun beneficialOwnerIndividuals(beneficialOwnerIndividuals: JsonField>) = apply { - this.beneficialOwnerIndividuals = beneficialOwnerIndividuals + this.beneficialOwnerIndividuals = + beneficialOwnerIndividuals.map { it.toMutableList() } } + /** + * Only present when user_type == "BUSINESS". List of all individuals with >25% ownership in + * the company. + */ + fun addBeneficialOwnerIndividual(beneficialOwnerIndividual: Individual) = apply { + beneficialOwnerIndividuals = + (beneficialOwnerIndividuals ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(beneficialOwnerIndividual) + } + } + /** * Only applicable for customers using the KYC-Exempt workflow to enroll authorized users of * businesses. Pass the account_token of the enrolled business associated with the @@ -635,7 +694,22 @@ private constructor( * for the account holder to be approved. */ fun requiredDocuments(requiredDocuments: JsonField>) = apply { - this.requiredDocuments = requiredDocuments + this.requiredDocuments = requiredDocuments.map { it.toMutableList() } + } + + /** + * Only present for "KYB_BASIC" and "KYC_ADVANCED" workflows. A list of documents required + * for the account holder to be approved. + */ + fun addRequiredDocument(requiredDocument: RequiredDocument) = apply { + requiredDocuments = + (requiredDocuments ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(requiredDocument) + } } /** @@ -670,7 +744,22 @@ private constructor( * status. */ fun statusReasons(statusReasons: JsonField>) = apply { - this.statusReasons = statusReasons + this.statusReasons = statusReasons.map { it.toMutableList() } + } + + /** + * Reason for the evaluation + * status. + */ + fun addStatusReason(statusReason: StatusReasons) = apply { + statusReasons = + (statusReasons ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(statusReason) + } } /** @@ -734,8 +823,8 @@ private constructor( AccountHolderSimulateEnrollmentReviewResponse( token, accountToken, - beneficialOwnerEntities.map { it.toImmutable() }, - beneficialOwnerIndividuals.map { it.toImmutable() }, + (beneficialOwnerEntities ?: JsonMissing.of()).map { it.toImmutable() }, + (beneficialOwnerIndividuals ?: JsonMissing.of()).map { it.toImmutable() }, businessAccountToken, businessEntity, controlPerson, @@ -746,9 +835,9 @@ private constructor( individual, natureOfBusiness, phoneNumber, - requiredDocuments.map { it.toImmutable() }, + (requiredDocuments ?: JsonMissing.of()).map { it.toImmutable() }, status, - statusReasons.map { it.toImmutable() }, + (statusReasons ?: JsonMissing.of()).map { it.toImmutable() }, userType, verificationApplication, websiteUrl, @@ -813,30 +902,38 @@ private constructor( * Business''s physical address - PO boxes, UPS drops, and FedEx drops are not acceptable; * APO/FPO are acceptable. */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") @ExcludeMissing fun _address(): JsonField = address /** * Government-issued identification number. US Federal Employer Identification Numbers (EIN) * are currently supported, entered as full nine-digits, with or without hyphens. */ - @JsonProperty("government_id") @ExcludeMissing fun _governmentId() = governmentId + @JsonProperty("government_id") + @ExcludeMissing + fun _governmentId(): JsonField = governmentId /** Legal (formal) business name. */ @JsonProperty("legal_business_name") @ExcludeMissing - fun _legalBusinessName() = legalBusinessName + fun _legalBusinessName(): JsonField = legalBusinessName /** One or more of the business's phone number(s), entered as a list in E.164 format. */ - @JsonProperty("phone_numbers") @ExcludeMissing fun _phoneNumbers() = phoneNumbers + @JsonProperty("phone_numbers") + @ExcludeMissing + fun _phoneNumbers(): JsonField> = phoneNumbers /** * Any name that the business operates under that is not its legal business name (if * applicable). */ - @JsonProperty("dba_business_name") @ExcludeMissing fun _dbaBusinessName() = dbaBusinessName + @JsonProperty("dba_business_name") + @ExcludeMissing + fun _dbaBusinessName(): JsonField = dbaBusinessName /** Parent company name (if applicable). */ - @JsonProperty("parent_company") @ExcludeMissing fun _parentCompany() = parentCompany + @JsonProperty("parent_company") + @ExcludeMissing + fun _parentCompany(): JsonField = parentCompany @JsonAnyGetter @ExcludeMissing @@ -865,10 +962,10 @@ private constructor( class Builder { - private var address: JsonField = JsonMissing.of() - private var governmentId: JsonField = JsonMissing.of() - private var legalBusinessName: JsonField = JsonMissing.of() - private var phoneNumbers: JsonField> = JsonMissing.of() + private var address: JsonField? = null + private var governmentId: JsonField? = null + private var legalBusinessName: JsonField? = null + private var phoneNumbers: JsonField>? = null private var dbaBusinessName: JsonField = JsonMissing.of() private var parentCompany: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -877,7 +974,7 @@ private constructor( address = kybBusinessEntity.address governmentId = kybBusinessEntity.governmentId legalBusinessName = kybBusinessEntity.legalBusinessName - phoneNumbers = kybBusinessEntity.phoneNumbers + phoneNumbers = kybBusinessEntity.phoneNumbers.map { it.toMutableList() } dbaBusinessName = kybBusinessEntity.dbaBusinessName parentCompany = kybBusinessEntity.parentCompany additionalProperties = kybBusinessEntity.additionalProperties.toMutableMap() @@ -923,7 +1020,19 @@ private constructor( /** One or more of the business's phone number(s), entered as a list in E.164 format. */ fun phoneNumbers(phoneNumbers: JsonField>) = apply { - this.phoneNumbers = phoneNumbers + this.phoneNumbers = phoneNumbers.map { it.toMutableList() } + } + + /** One or more of the business's phone number(s), entered as a list in E.164 format. */ + fun addPhoneNumber(phoneNumber: String) = apply { + phoneNumbers = + (phoneNumbers ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(phoneNumber) + } } /** @@ -970,10 +1079,13 @@ private constructor( fun build(): KybBusinessEntity = KybBusinessEntity( - address, - governmentId, - legalBusinessName, - phoneNumbers.map { it.toImmutable() }, + checkNotNull(address) { "`address` is required but was not set" }, + checkNotNull(governmentId) { "`governmentId` is required but was not set" }, + checkNotNull(legalBusinessName) { + "`legalBusinessName` is required but was not set" + }, + checkNotNull(phoneNumbers) { "`phoneNumbers` is required but was not set" } + .map { it.toImmutable() }, dbaBusinessName, parentCompany, additionalProperties.toImmutable(), @@ -1038,31 +1150,33 @@ private constructor( fun address2(): String? = address2.getNullable("address2") /** Valid deliverable address (no PO boxes). */ - @JsonProperty("address1") @ExcludeMissing fun _address1() = address1 + @JsonProperty("address1") @ExcludeMissing fun _address1(): JsonField = address1 /** Name of city. */ - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city /** * Valid country code. Only USA is currently supported, entered in uppercase ISO 3166-1 * alpha-3 three-character format. */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** * Valid postal code. Only USA ZIP codes are currently supported, entered as a * five-digit ZIP or nine-digit ZIP+4. */ - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode /** * Valid state code. Only USA state codes are currently supported, entered in uppercase * ISO 3166-2 two-character format. */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** Unit or apartment number (if applicable). */ - @JsonProperty("address2") @ExcludeMissing fun _address2() = address2 + @JsonProperty("address2") @ExcludeMissing fun _address2(): JsonField = address2 @JsonAnyGetter @ExcludeMissing @@ -1091,11 +1205,11 @@ private constructor( class Builder { - private var address1: JsonField = JsonMissing.of() - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() + private var address1: JsonField? = null + private var city: JsonField? = null + private var country: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null private var address2: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1189,11 +1303,11 @@ private constructor( fun build(): Address2 = Address2( - address1, - city, - country, - postalCode, - state, + checkNotNull(address1) { "`address1` is required but was not set" }, + checkNotNull(city) { "`city` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(postalCode) { "`postalCode` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, address2, additionalProperties.toImmutable(), ) @@ -1298,19 +1412,19 @@ private constructor( * Individual's current address - PO boxes, UPS drops, and FedEx drops are not acceptable; * APO/FPO are acceptable. Only USA addresses are currently supported. */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") @ExcludeMissing fun _address(): JsonField = address /** Individual's date of birth, as an RFC 3339 date. */ - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** * Individual's email address. If utilizing Lithic for chargeback processing, this customer * email address may be used to communicate dispute status and resolution. */ - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email /** Individual's first name, as it appears on government-issued identity documents. */ - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** * Government-issued identification number (required for identity verification and @@ -1318,13 +1432,17 @@ private constructor( * Taxpayer Identification Numbers (ITIN) are currently supported, entered as full * nine-digits, with or without hyphens */ - @JsonProperty("government_id") @ExcludeMissing fun _governmentId() = governmentId + @JsonProperty("government_id") + @ExcludeMissing + fun _governmentId(): JsonField = governmentId /** Individual's last name, as it appears on government-issued identity documents. */ - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName /** Individual's phone number, entered in E.164 format. */ - @JsonProperty("phone_number") @ExcludeMissing fun _phoneNumber() = phoneNumber + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber @JsonAnyGetter @ExcludeMissing @@ -1532,31 +1650,33 @@ private constructor( fun address2(): String? = address2.getNullable("address2") /** Valid deliverable address (no PO boxes). */ - @JsonProperty("address1") @ExcludeMissing fun _address1() = address1 + @JsonProperty("address1") @ExcludeMissing fun _address1(): JsonField = address1 /** Name of city. */ - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city /** * Valid country code. Only USA is currently supported, entered in uppercase ISO 3166-1 * alpha-3 three-character format. */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** * Valid postal code. Only USA ZIP codes are currently supported, entered as a * five-digit ZIP or nine-digit ZIP+4. */ - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode /** * Valid state code. Only USA state codes are currently supported, entered in uppercase * ISO 3166-2 two-character format. */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** Unit or apartment number (if applicable). */ - @JsonProperty("address2") @ExcludeMissing fun _address2() = address2 + @JsonProperty("address2") @ExcludeMissing fun _address2(): JsonField = address2 @JsonAnyGetter @ExcludeMissing @@ -1585,11 +1705,11 @@ private constructor( class Builder { - private var address1: JsonField = JsonMissing.of() - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() + private var address1: JsonField? = null + private var city: JsonField? = null + private var country: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null private var address2: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1683,11 +1803,11 @@ private constructor( fun build(): Address2 = Address2( - address1, - city, - country, - postalCode, - state, + checkNotNull(address1) { "`address1` is required but was not set" }, + checkNotNull(city) { "`city` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(postalCode) { "`postalCode` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, address2, additionalProperties.toImmutable(), ) @@ -2176,7 +2296,7 @@ private constructor( fun updated(): OffsetDateTime = updated.getRequired("updated") /** Timestamp of when the application was created. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** * KYC and KYB evaluation states. @@ -2184,13 +2304,15 @@ private constructor( * Note: `PENDING_RESUBMIT` and `PENDING_DOCUMENT` are only applicable for the `ADVANCED` * workflow. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** Reason for the evaluation status. */ - @JsonProperty("status_reasons") @ExcludeMissing fun _statusReasons() = statusReasons + @JsonProperty("status_reasons") + @ExcludeMissing + fun _statusReasons(): JsonField> = statusReasons /** Timestamp of when the application was last updated. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated @JsonAnyGetter @ExcludeMissing @@ -2217,16 +2339,16 @@ private constructor( class Builder { - private var created: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var statusReasons: JsonField> = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() + private var created: JsonField? = null + private var status: JsonField? = null + private var statusReasons: JsonField>? = null + private var updated: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(verificationApplication: VerificationApplication) = apply { created = verificationApplication.created status = verificationApplication.status - statusReasons = verificationApplication.statusReasons + statusReasons = verificationApplication.statusReasons.map { it.toMutableList() } updated = verificationApplication.updated additionalProperties = verificationApplication.additionalProperties.toMutableMap() } @@ -2259,7 +2381,19 @@ private constructor( /** Reason for the evaluation status. */ fun statusReasons(statusReasons: JsonField>) = apply { - this.statusReasons = statusReasons + this.statusReasons = statusReasons.map { it.toMutableList() } + } + + /** Reason for the evaluation status. */ + fun addStatusReason(statusReason: StatusReasons) = apply { + statusReasons = + (statusReasons ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(statusReason) + } } /** Timestamp of when the application was last updated. */ @@ -2289,10 +2423,11 @@ private constructor( fun build(): VerificationApplication = VerificationApplication( - created, - status, - statusReasons.map { it.toImmutable() }, - updated, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(statusReasons) { "`statusReasons` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(updated) { "`updated` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderUpdateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderUpdateParams.kt index 426d646c..00e55ce8 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderUpdateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -46,12 +48,32 @@ constructor( */ fun phoneNumber(): String? = body.phoneNumber() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * Only applicable for customers using the KYC-Exempt workflow to enroll authorized users of + * businesses. Pass the account_token of the enrolled business associated with the + * AUTHORIZED_USER in this field. + */ + fun _businessAccountToken(): JsonField = body._businessAccountToken() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Account holder's email address. The primary purpose of this field is for cardholder + * identification and verification during the digital wallet tokenization process. + */ + fun _email(): JsonField = body._email() + + /** + * Account holder's phone number, entered in E.164 format. The primary purpose of this field is + * for cardholder identification and verification during the digital wallet tokenization + * process. + */ + fun _phoneNumber(): JsonField = body._phoneNumber() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): AccountHolderUpdateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -69,38 +91,79 @@ constructor( class AccountHolderUpdateBody @JsonCreator internal constructor( - @JsonProperty("business_account_token") private val businessAccountToken: String?, - @JsonProperty("email") private val email: String?, - @JsonProperty("phone_number") private val phoneNumber: String?, + @JsonProperty("business_account_token") + @ExcludeMissing + private val businessAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("email") + @ExcludeMissing + private val email: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + private val phoneNumber: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * Only applicable for customers using the KYC-Exempt workflow to enroll authorized users of + * businesses. Pass the account_token of the enrolled business associated with the + * AUTHORIZED_USER in this field. + */ + fun businessAccountToken(): String? = + businessAccountToken.getNullable("business_account_token") + + /** + * Account holder's email address. The primary purpose of this field is for cardholder + * identification and verification during the digital wallet tokenization process. + */ + fun email(): String? = email.getNullable("email") + + /** + * Account holder's phone number, entered in E.164 format. The primary purpose of this field + * is for cardholder identification and verification during the digital wallet tokenization + * process. + */ + fun phoneNumber(): String? = phoneNumber.getNullable("phone_number") + /** * Only applicable for customers using the KYC-Exempt workflow to enroll authorized users of * businesses. Pass the account_token of the enrolled business associated with the * AUTHORIZED_USER in this field. */ @JsonProperty("business_account_token") - fun businessAccountToken(): String? = businessAccountToken + @ExcludeMissing + fun _businessAccountToken(): JsonField = businessAccountToken /** * Account holder's email address. The primary purpose of this field is for cardholder * identification and verification during the digital wallet tokenization process. */ - @JsonProperty("email") fun email(): String? = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email /** * Account holder's phone number, entered in E.164 format. The primary purpose of this field * is for cardholder identification and verification during the digital wallet tokenization * process. */ - @JsonProperty("phone_number") fun phoneNumber(): String? = phoneNumber + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AccountHolderUpdateBody = apply { + if (!validated) { + businessAccountToken() + email() + phoneNumber() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -110,9 +173,9 @@ constructor( class Builder { - private var businessAccountToken: String? = null - private var email: String? = null - private var phoneNumber: String? = null + private var businessAccountToken: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var phoneNumber: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(accountHolderUpdateBody: AccountHolderUpdateBody) = apply { @@ -127,7 +190,15 @@ constructor( * users of businesses. Pass the account_token of the enrolled business associated with * the AUTHORIZED_USER in this field. */ - fun businessAccountToken(businessAccountToken: String?) = apply { + fun businessAccountToken(businessAccountToken: String) = + businessAccountToken(JsonField.of(businessAccountToken)) + + /** + * Only applicable for customers using the KYC-Exempt workflow to enroll authorized + * users of businesses. Pass the account_token of the enrolled business associated with + * the AUTHORIZED_USER in this field. + */ + fun businessAccountToken(businessAccountToken: JsonField) = apply { this.businessAccountToken = businessAccountToken } @@ -135,14 +206,29 @@ constructor( * Account holder's email address. The primary purpose of this field is for cardholder * identification and verification during the digital wallet tokenization process. */ - fun email(email: String?) = apply { this.email = email } + fun email(email: String) = email(JsonField.of(email)) + + /** + * Account holder's email address. The primary purpose of this field is for cardholder + * identification and verification during the digital wallet tokenization process. + */ + fun email(email: JsonField) = apply { this.email = email } /** * Account holder's phone number, entered in E.164 format. The primary purpose of this * field is for cardholder identification and verification during the digital wallet * tokenization process. */ - fun phoneNumber(phoneNumber: String?) = apply { this.phoneNumber = phoneNumber } + fun phoneNumber(phoneNumber: String) = phoneNumber(JsonField.of(phoneNumber)) + + /** + * Account holder's phone number, entered in E.164 format. The primary purpose of this + * field is for cardholder identification and verification during the digital wallet + * tokenization process. + */ + fun phoneNumber(phoneNumber: JsonField) = apply { + this.phoneNumber = phoneNumber + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -221,7 +307,16 @@ constructor( * businesses. Pass the account_token of the enrolled business associated with the * AUTHORIZED_USER in this field. */ - fun businessAccountToken(businessAccountToken: String?) = apply { + fun businessAccountToken(businessAccountToken: String) = apply { + body.businessAccountToken(businessAccountToken) + } + + /** + * Only applicable for customers using the KYC-Exempt workflow to enroll authorized users of + * businesses. Pass the account_token of the enrolled business associated with the + * AUTHORIZED_USER in this field. + */ + fun businessAccountToken(businessAccountToken: JsonField) = apply { body.businessAccountToken(businessAccountToken) } @@ -229,14 +324,46 @@ constructor( * Account holder's email address. The primary purpose of this field is for cardholder * identification and verification during the digital wallet tokenization process. */ - fun email(email: String?) = apply { body.email(email) } + fun email(email: String) = apply { body.email(email) } + + /** + * Account holder's email address. The primary purpose of this field is for cardholder + * identification and verification during the digital wallet tokenization process. + */ + fun email(email: JsonField) = apply { body.email(email) } + + /** + * Account holder's phone number, entered in E.164 format. The primary purpose of this field + * is for cardholder identification and verification during the digital wallet tokenization + * process. + */ + fun phoneNumber(phoneNumber: String) = apply { body.phoneNumber(phoneNumber) } /** * Account holder's phone number, entered in E.164 format. The primary purpose of this field * is for cardholder identification and verification during the digital wallet tokenization * process. */ - fun phoneNumber(phoneNumber: String?) = apply { body.phoneNumber(phoneNumber) } + fun phoneNumber(phoneNumber: JsonField) = apply { body.phoneNumber(phoneNumber) } + + 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() @@ -336,25 +463,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): AccountHolderUpdateParams = AccountHolderUpdateParams( checkNotNull(accountHolderToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderUpdateResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderUpdateResponse.kt index 803dc586..1d9c930c 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderUpdateResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderUpdateResponse.kt @@ -47,7 +47,7 @@ private constructor( fun phoneNumber(): String? = phoneNumber.getNullable("phone_number") /** The token for the account holder that was updated */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * Only applicable for customers using the KYC-Exempt workflow to enroll businesses with @@ -56,13 +56,15 @@ private constructor( */ @JsonProperty("business_account_token") @ExcludeMissing - fun _businessAccountToken() = businessAccountToken + fun _businessAccountToken(): JsonField = businessAccountToken /** The newly updated email for the account holder */ - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email /** The newly updated phone_number for the account holder */ - @JsonProperty("phone_number") @ExcludeMissing fun _phoneNumber() = phoneNumber + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderUploadDocumentParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderUploadDocumentParams.kt index 79982d4a..c3502e07 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderUploadDocumentParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountHolderUploadDocumentParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -52,12 +53,18 @@ constructor( /** Globally unique identifier for the entity. */ fun entityToken(): String = body.entityToken() - fun _additionalHeaders(): Headers = additionalHeaders + /** The type of document to upload */ + fun _documentType(): JsonField = body._documentType() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Globally unique identifier for the entity. */ + fun _entityToken(): JsonField = body._entityToken() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): AccountHolderUploadDocumentBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -75,22 +82,46 @@ constructor( class AccountHolderUploadDocumentBody @JsonCreator internal constructor( - @JsonProperty("document_type") private val documentType: DocumentType, - @JsonProperty("entity_token") private val entityToken: String, + @JsonProperty("document_type") + @ExcludeMissing + private val documentType: JsonField = JsonMissing.of(), + @JsonProperty("entity_token") + @ExcludeMissing + private val entityToken: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The type of document to upload */ - @JsonProperty("document_type") fun documentType(): DocumentType = documentType + fun documentType(): DocumentType = documentType.getRequired("document_type") + + /** Globally unique identifier for the entity. */ + fun entityToken(): String = entityToken.getRequired("entity_token") + + /** The type of document to upload */ + @JsonProperty("document_type") + @ExcludeMissing + fun _documentType(): JsonField = documentType /** Globally unique identifier for the entity. */ - @JsonProperty("entity_token") fun entityToken(): String = entityToken + @JsonProperty("entity_token") + @ExcludeMissing + fun _entityToken(): JsonField = entityToken @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AccountHolderUploadDocumentBody = apply { + if (!validated) { + documentType() + entityToken() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -100,8 +131,8 @@ constructor( class Builder { - private var documentType: DocumentType? = null - private var entityToken: String? = null + private var documentType: JsonField? = null + private var entityToken: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(accountHolderUploadDocumentBody: AccountHolderUploadDocumentBody) = @@ -113,12 +144,20 @@ constructor( } /** The type of document to upload */ - fun documentType(documentType: DocumentType) = apply { + fun documentType(documentType: DocumentType) = documentType(JsonField.of(documentType)) + + /** The type of document to upload */ + fun documentType(documentType: JsonField) = apply { this.documentType = documentType } /** Globally unique identifier for the entity. */ - fun entityToken(entityToken: String) = apply { this.entityToken = entityToken } + fun entityToken(entityToken: String) = entityToken(JsonField.of(entityToken)) + + /** Globally unique identifier for the entity. */ + fun entityToken(entityToken: JsonField) = apply { + this.entityToken = entityToken + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -197,9 +236,36 @@ constructor( /** The type of document to upload */ fun documentType(documentType: DocumentType) = apply { body.documentType(documentType) } + /** The type of document to upload */ + fun documentType(documentType: JsonField) = apply { + body.documentType(documentType) + } + /** Globally unique identifier for the entity. */ fun entityToken(entityToken: String) = apply { body.entityToken(entityToken) } + /** Globally unique identifier for the entity. */ + fun entityToken(entityToken: JsonField) = apply { body.entityToken(entityToken) } + + 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) @@ -298,25 +364,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): AccountHolderUploadDocumentParams = AccountHolderUploadDocumentParams( checkNotNull(accountHolderToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountSpendLimits.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountSpendLimits.kt index 313c42e9..9325f44e 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountSpendLimits.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountSpendLimits.kt @@ -40,11 +40,15 @@ private constructor( @JsonProperty("available_spend_limit") @ExcludeMissing - fun _availableSpendLimit() = availableSpendLimit + fun _availableSpendLimit(): JsonField = availableSpendLimit - @JsonProperty("spend_limit") @ExcludeMissing fun _spendLimit() = spendLimit + @JsonProperty("spend_limit") + @ExcludeMissing + fun _spendLimit(): JsonField = spendLimit - @JsonProperty("spend_velocity") @ExcludeMissing fun _spendVelocity() = spendVelocity + @JsonProperty("spend_velocity") + @ExcludeMissing + fun _spendVelocity(): JsonField = spendVelocity @JsonAnyGetter @ExcludeMissing @@ -70,7 +74,7 @@ private constructor( class Builder { - private var availableSpendLimit: JsonField = JsonMissing.of() + private var availableSpendLimit: JsonField? = null private var spendLimit: JsonField = JsonMissing.of() private var spendVelocity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -120,7 +124,9 @@ private constructor( fun build(): AccountSpendLimits = AccountSpendLimits( - availableSpendLimit, + checkNotNull(availableSpendLimit) { + "`availableSpendLimit` is required but was not set" + }, spendLimit, spendVelocity, additionalProperties.toImmutable(), @@ -166,19 +172,19 @@ private constructor( * The available spend limit (in cents) relative to the daily limit configured on the * Account. */ - @JsonProperty("daily") @ExcludeMissing fun _daily() = daily + @JsonProperty("daily") @ExcludeMissing fun _daily(): JsonField = daily /** * The available spend limit (in cents) relative to the lifetime limit configured on the * Account. */ - @JsonProperty("lifetime") @ExcludeMissing fun _lifetime() = lifetime + @JsonProperty("lifetime") @ExcludeMissing fun _lifetime(): JsonField = lifetime /** * The available spend limit (in cents) relative to the monthly limit configured on the * Account. */ - @JsonProperty("monthly") @ExcludeMissing fun _monthly() = monthly + @JsonProperty("monthly") @ExcludeMissing fun _monthly(): JsonField = monthly @JsonAnyGetter @ExcludeMissing @@ -325,13 +331,13 @@ private constructor( fun monthly(): Long? = monthly.getNullable("monthly") /** The configured daily spend limit (in cents) on the Account. */ - @JsonProperty("daily") @ExcludeMissing fun _daily() = daily + @JsonProperty("daily") @ExcludeMissing fun _daily(): JsonField = daily /** The configured lifetime spend limit (in cents) on the Account. */ - @JsonProperty("lifetime") @ExcludeMissing fun _lifetime() = lifetime + @JsonProperty("lifetime") @ExcludeMissing fun _lifetime(): JsonField = lifetime /** The configured monthly spend limit (in cents) on the Account. */ - @JsonProperty("monthly") @ExcludeMissing fun _monthly() = monthly + @JsonProperty("monthly") @ExcludeMissing fun _monthly(): JsonField = monthly @JsonAnyGetter @ExcludeMissing @@ -472,19 +478,19 @@ private constructor( * Current daily spend velocity (in cents) on the Account. Present if daily spend limit is * set. */ - @JsonProperty("daily") @ExcludeMissing fun _daily() = daily + @JsonProperty("daily") @ExcludeMissing fun _daily(): JsonField = daily /** * Current lifetime spend velocity (in cents) on the Account. Present if lifetime spend * limit is set. */ - @JsonProperty("lifetime") @ExcludeMissing fun _lifetime() = lifetime + @JsonProperty("lifetime") @ExcludeMissing fun _lifetime(): JsonField = lifetime /** * Current monthly spend velocity (in cents) on the Account. Present if monthly spend limit * is set. */ - @JsonProperty("monthly") @ExcludeMissing fun _monthly() = monthly + @JsonProperty("monthly") @ExcludeMissing fun _monthly(): JsonField = monthly @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountUpdateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountUpdateParams.kt index 65d9fb60..c1c4389c 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountUpdateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountUpdateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -65,12 +66,44 @@ constructor( */ fun verificationAddress(): VerificationAddress? = body.verificationAddress() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * Amount (in cents) for the account's daily spend limit. By default the daily spend limit is + * set to $1,250. + */ + fun _dailySpendLimit(): JsonField = body._dailySpendLimit() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Amount (in cents) for the account's lifetime spend limit. Once this limit is reached, no + * transactions will be accepted on any card created for this account until the limit is + * updated. Note that a spend limit of 0 is effectively no limit, and should only be used to + * reset or remove a prior limit. Only a limit of 1 or above will result in declined + * transactions due to checks against the account limit. This behavior differs from the daily + * spend limit and the monthly spend limit. + */ + fun _lifetimeSpendLimit(): JsonField = body._lifetimeSpendLimit() + + /** + * Amount (in cents) for the account's monthly spend limit. By default the monthly spend limit + * is set to $5,000. + */ + fun _monthlySpendLimit(): JsonField = body._monthlySpendLimit() + + /** Account states. */ + fun _state(): JsonField = body._state() + + /** + * Address used during Address Verification Service (AVS) checks during transactions if enabled + * via Auth Rules. This field is deprecated as AVS checks are no longer supported by + * Authorization Rules. The field will be removed from the schema in a future release. + */ + fun _verificationAddress(): JsonField = body._verificationAddress() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): AccountUpdateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -88,11 +121,21 @@ constructor( class AccountUpdateBody @JsonCreator internal constructor( - @JsonProperty("daily_spend_limit") private val dailySpendLimit: Long?, - @JsonProperty("lifetime_spend_limit") private val lifetimeSpendLimit: Long?, - @JsonProperty("monthly_spend_limit") private val monthlySpendLimit: Long?, - @JsonProperty("state") private val state: State?, - @JsonProperty("verification_address") private val verificationAddress: VerificationAddress?, + @JsonProperty("daily_spend_limit") + @ExcludeMissing + private val dailySpendLimit: JsonField = JsonMissing.of(), + @JsonProperty("lifetime_spend_limit") + @ExcludeMissing + private val lifetimeSpendLimit: JsonField = JsonMissing.of(), + @JsonProperty("monthly_spend_limit") + @ExcludeMissing + private val monthlySpendLimit: JsonField = JsonMissing.of(), + @JsonProperty("state") + @ExcludeMissing + private val state: JsonField = JsonMissing.of(), + @JsonProperty("verification_address") + @ExcludeMissing + private val verificationAddress: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -101,7 +144,42 @@ constructor( * Amount (in cents) for the account's daily spend limit. By default the daily spend limit * is set to $1,250. */ - @JsonProperty("daily_spend_limit") fun dailySpendLimit(): Long? = dailySpendLimit + fun dailySpendLimit(): Long? = dailySpendLimit.getNullable("daily_spend_limit") + + /** + * Amount (in cents) for the account's lifetime spend limit. Once this limit is reached, no + * transactions will be accepted on any card created for this account until the limit is + * updated. Note that a spend limit of 0 is effectively no limit, and should only be used to + * reset or remove a prior limit. Only a limit of 1 or above will result in declined + * transactions due to checks against the account limit. This behavior differs from the + * daily spend limit and the monthly spend limit. + */ + fun lifetimeSpendLimit(): Long? = lifetimeSpendLimit.getNullable("lifetime_spend_limit") + + /** + * Amount (in cents) for the account's monthly spend limit. By default the monthly spend + * limit is set to $5,000. + */ + fun monthlySpendLimit(): Long? = monthlySpendLimit.getNullable("monthly_spend_limit") + + /** Account states. */ + fun state(): State? = state.getNullable("state") + + /** + * Address used during Address Verification Service (AVS) checks during transactions if + * enabled via Auth Rules. This field is deprecated as AVS checks are no longer supported by + * Authorization Rules. The field will be removed from the schema in a future release. + */ + fun verificationAddress(): VerificationAddress? = + verificationAddress.getNullable("verification_address") + + /** + * Amount (in cents) for the account's daily spend limit. By default the daily spend limit + * is set to $1,250. + */ + @JsonProperty("daily_spend_limit") + @ExcludeMissing + fun _dailySpendLimit(): JsonField = dailySpendLimit /** * Amount (in cents) for the account's lifetime spend limit. Once this limit is reached, no @@ -111,16 +189,20 @@ constructor( * transactions due to checks against the account limit. This behavior differs from the * daily spend limit and the monthly spend limit. */ - @JsonProperty("lifetime_spend_limit") fun lifetimeSpendLimit(): Long? = lifetimeSpendLimit + @JsonProperty("lifetime_spend_limit") + @ExcludeMissing + fun _lifetimeSpendLimit(): JsonField = lifetimeSpendLimit /** * Amount (in cents) for the account's monthly spend limit. By default the monthly spend * limit is set to $5,000. */ - @JsonProperty("monthly_spend_limit") fun monthlySpendLimit(): Long? = monthlySpendLimit + @JsonProperty("monthly_spend_limit") + @ExcludeMissing + fun _monthlySpendLimit(): JsonField = monthlySpendLimit /** Account states. */ - @JsonProperty("state") fun state(): State? = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** * Address used during Address Verification Service (AVS) checks during transactions if @@ -128,12 +210,26 @@ constructor( * Authorization Rules. The field will be removed from the schema in a future release. */ @JsonProperty("verification_address") - fun verificationAddress(): VerificationAddress? = verificationAddress + @ExcludeMissing + fun _verificationAddress(): JsonField = verificationAddress @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AccountUpdateBody = apply { + if (!validated) { + dailySpendLimit() + lifetimeSpendLimit() + monthlySpendLimit() + state() + verificationAddress()?.validate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -143,11 +239,11 @@ constructor( class Builder { - private var dailySpendLimit: Long? = null - private var lifetimeSpendLimit: Long? = null - private var monthlySpendLimit: Long? = null - private var state: State? = null - private var verificationAddress: VerificationAddress? = null + private var dailySpendLimit: JsonField = JsonMissing.of() + private var lifetimeSpendLimit: JsonField = JsonMissing.of() + private var monthlySpendLimit: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var verificationAddress: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(accountUpdateBody: AccountUpdateBody) = apply { @@ -163,15 +259,16 @@ constructor( * Amount (in cents) for the account's daily spend limit. By default the daily spend * limit is set to $1,250. */ - fun dailySpendLimit(dailySpendLimit: Long?) = apply { - this.dailySpendLimit = dailySpendLimit - } + fun dailySpendLimit(dailySpendLimit: Long) = + dailySpendLimit(JsonField.of(dailySpendLimit)) /** * Amount (in cents) for the account's daily spend limit. By default the daily spend * limit is set to $1,250. */ - fun dailySpendLimit(dailySpendLimit: Long) = dailySpendLimit(dailySpendLimit as Long?) + fun dailySpendLimit(dailySpendLimit: JsonField) = apply { + this.dailySpendLimit = dailySpendLimit + } /** * Amount (in cents) for the account's lifetime spend limit. Once this limit is reached, @@ -181,9 +278,8 @@ constructor( * declined transactions due to checks against the account limit. This behavior differs * from the daily spend limit and the monthly spend limit. */ - fun lifetimeSpendLimit(lifetimeSpendLimit: Long?) = apply { - this.lifetimeSpendLimit = lifetimeSpendLimit - } + fun lifetimeSpendLimit(lifetimeSpendLimit: Long) = + lifetimeSpendLimit(JsonField.of(lifetimeSpendLimit)) /** * Amount (in cents) for the account's lifetime spend limit. Once this limit is reached, @@ -193,26 +289,30 @@ constructor( * declined transactions due to checks against the account limit. This behavior differs * from the daily spend limit and the monthly spend limit. */ - fun lifetimeSpendLimit(lifetimeSpendLimit: Long) = - lifetimeSpendLimit(lifetimeSpendLimit as Long?) + fun lifetimeSpendLimit(lifetimeSpendLimit: JsonField) = apply { + this.lifetimeSpendLimit = lifetimeSpendLimit + } /** * Amount (in cents) for the account's monthly spend limit. By default the monthly spend * limit is set to $5,000. */ - fun monthlySpendLimit(monthlySpendLimit: Long?) = apply { - this.monthlySpendLimit = monthlySpendLimit - } + fun monthlySpendLimit(monthlySpendLimit: Long) = + monthlySpendLimit(JsonField.of(monthlySpendLimit)) /** * Amount (in cents) for the account's monthly spend limit. By default the monthly spend * limit is set to $5,000. */ - fun monthlySpendLimit(monthlySpendLimit: Long) = - monthlySpendLimit(monthlySpendLimit as Long?) + fun monthlySpendLimit(monthlySpendLimit: JsonField) = apply { + this.monthlySpendLimit = monthlySpendLimit + } /** Account states. */ - fun state(state: State?) = apply { this.state = state } + fun state(state: State) = state(JsonField.of(state)) + + /** Account states. */ + fun state(state: JsonField) = apply { this.state = state } /** * Address used during Address Verification Service (AVS) checks during transactions if @@ -220,7 +320,16 @@ constructor( * supported by Authorization Rules. The field will be removed from the schema in a * future release. */ - fun verificationAddress(verificationAddress: VerificationAddress?) = apply { + fun verificationAddress(verificationAddress: VerificationAddress) = + verificationAddress(JsonField.of(verificationAddress)) + + /** + * Address used during Address Verification Service (AVS) checks during transactions if + * enabled via Auth Rules. This field is deprecated as AVS checks are no longer + * supported by Authorization Rules. The field will be removed from the schema in a + * future release. + */ + fun verificationAddress(verificationAddress: JsonField) = apply { this.verificationAddress = verificationAddress } @@ -300,15 +409,15 @@ constructor( * Amount (in cents) for the account's daily spend limit. By default the daily spend limit * is set to $1,250. */ - fun dailySpendLimit(dailySpendLimit: Long?) = apply { - body.dailySpendLimit(dailySpendLimit) - } + fun dailySpendLimit(dailySpendLimit: Long) = apply { body.dailySpendLimit(dailySpendLimit) } /** * Amount (in cents) for the account's daily spend limit. By default the daily spend limit * is set to $1,250. */ - fun dailySpendLimit(dailySpendLimit: Long) = dailySpendLimit(dailySpendLimit as Long?) + fun dailySpendLimit(dailySpendLimit: JsonField) = apply { + body.dailySpendLimit(dailySpendLimit) + } /** * Amount (in cents) for the account's lifetime spend limit. Once this limit is reached, no @@ -318,7 +427,7 @@ constructor( * transactions due to checks against the account limit. This behavior differs from the * daily spend limit and the monthly spend limit. */ - fun lifetimeSpendLimit(lifetimeSpendLimit: Long?) = apply { + fun lifetimeSpendLimit(lifetimeSpendLimit: Long) = apply { body.lifetimeSpendLimit(lifetimeSpendLimit) } @@ -330,14 +439,15 @@ constructor( * transactions due to checks against the account limit. This behavior differs from the * daily spend limit and the monthly spend limit. */ - fun lifetimeSpendLimit(lifetimeSpendLimit: Long) = - lifetimeSpendLimit(lifetimeSpendLimit as Long?) + fun lifetimeSpendLimit(lifetimeSpendLimit: JsonField) = apply { + body.lifetimeSpendLimit(lifetimeSpendLimit) + } /** * Amount (in cents) for the account's monthly spend limit. By default the monthly spend * limit is set to $5,000. */ - fun monthlySpendLimit(monthlySpendLimit: Long?) = apply { + fun monthlySpendLimit(monthlySpendLimit: Long) = apply { body.monthlySpendLimit(monthlySpendLimit) } @@ -345,21 +455,53 @@ constructor( * Amount (in cents) for the account's monthly spend limit. By default the monthly spend * limit is set to $5,000. */ - fun monthlySpendLimit(monthlySpendLimit: Long) = - monthlySpendLimit(monthlySpendLimit as Long?) + fun monthlySpendLimit(monthlySpendLimit: JsonField) = apply { + body.monthlySpendLimit(monthlySpendLimit) + } /** Account states. */ - fun state(state: State?) = apply { body.state(state) } + fun state(state: State) = apply { body.state(state) } + + /** Account states. */ + fun state(state: JsonField) = apply { body.state(state) } + + /** + * Address used during Address Verification Service (AVS) checks during transactions if + * enabled via Auth Rules. This field is deprecated as AVS checks are no longer supported by + * Authorization Rules. The field will be removed from the schema in a future release. + */ + fun verificationAddress(verificationAddress: VerificationAddress) = apply { + body.verificationAddress(verificationAddress) + } /** * Address used during Address Verification Service (AVS) checks during transactions if * enabled via Auth Rules. This field is deprecated as AVS checks are no longer supported by * Authorization Rules. The field will be removed from the schema in a future release. */ - fun verificationAddress(verificationAddress: VerificationAddress?) = apply { + fun verificationAddress(verificationAddress: JsonField) = apply { body.verificationAddress(verificationAddress) } + 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) @@ -458,25 +600,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): AccountUpdateParams = AccountUpdateParams( checkNotNull(accountToken) { "`accountToken` is required but was not set" }, @@ -552,32 +675,72 @@ constructor( class VerificationAddress @JsonCreator private constructor( - @JsonProperty("address1") private val address1: String?, - @JsonProperty("address2") private val address2: String?, - @JsonProperty("city") private val city: String?, - @JsonProperty("country") private val country: String?, - @JsonProperty("postal_code") private val postalCode: String?, - @JsonProperty("state") private val state: String?, + @JsonProperty("address1") + @ExcludeMissing + private val address1: JsonField = JsonMissing.of(), + @JsonProperty("address2") + @ExcludeMissing + private val address2: JsonField = JsonMissing.of(), + @JsonProperty("city") + @ExcludeMissing + private val city: JsonField = JsonMissing.of(), + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + private val postalCode: JsonField = JsonMissing.of(), + @JsonProperty("state") + @ExcludeMissing + private val state: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("address1") fun address1(): String? = address1 + fun address1(): String? = address1.getNullable("address1") + + fun address2(): String? = address2.getNullable("address2") - @JsonProperty("address2") fun address2(): String? = address2 + fun city(): String? = city.getNullable("city") - @JsonProperty("city") fun city(): String? = city + fun country(): String? = country.getNullable("country") - @JsonProperty("country") fun country(): String? = country + fun postalCode(): String? = postalCode.getNullable("postal_code") - @JsonProperty("postal_code") fun postalCode(): String? = postalCode + fun state(): String? = state.getNullable("state") - @JsonProperty("state") fun state(): String? = state + @JsonProperty("address1") @ExcludeMissing fun _address1(): JsonField = address1 + + @JsonProperty("address2") @ExcludeMissing fun _address2(): JsonField = address2 + + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city + + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode + + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): VerificationAddress = apply { + if (!validated) { + address1() + address2() + city() + country() + postalCode() + state() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -587,12 +750,12 @@ constructor( class Builder { - private var address1: String? = null - private var address2: String? = null - private var city: String? = null - private var country: String? = null - private var postalCode: String? = null - private var state: String? = null + private var address1: JsonField = JsonMissing.of() + private var address2: JsonField = JsonMissing.of() + private var city: JsonField = JsonMissing.of() + private var country: JsonField = JsonMissing.of() + private var postalCode: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(verificationAddress: VerificationAddress) = apply { @@ -605,17 +768,29 @@ constructor( additionalProperties = verificationAddress.additionalProperties.toMutableMap() } - fun address1(address1: String?) = apply { this.address1 = address1 } + fun address1(address1: String) = address1(JsonField.of(address1)) + + fun address1(address1: JsonField) = apply { this.address1 = address1 } + + fun address2(address2: String) = address2(JsonField.of(address2)) + + fun address2(address2: JsonField) = apply { this.address2 = address2 } + + fun city(city: String) = city(JsonField.of(city)) + + fun city(city: JsonField) = apply { this.city = city } + + fun country(country: String) = country(JsonField.of(country)) - fun address2(address2: String?) = apply { this.address2 = address2 } + fun country(country: JsonField) = apply { this.country = country } - fun city(city: String?) = apply { this.city = city } + fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) - fun country(country: String?) = apply { this.country = country } + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - fun postalCode(postalCode: String?) = apply { this.postalCode = postalCode } + fun state(state: String) = state(JsonField.of(state)) - fun state(state: String?) = apply { this.state = state } + fun state(state: JsonField) = apply { this.state = state } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Address.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Address.kt index 6ee354b2..91775f4c 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Address.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Address.kt @@ -65,32 +65,32 @@ private constructor( fun address2(): String? = address2.getNullable("address2") /** Valid deliverable address (no PO boxes). */ - @JsonProperty("address1") @ExcludeMissing fun _address1() = address1 + @JsonProperty("address1") @ExcludeMissing fun _address1(): JsonField = address1 /** Name of city. */ - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city /** * Valid country code, entered in uppercase ISO 3166-1 alpha-3 three-character format. Only USA * is currently supported for all workflows. KYC_EXEMPT supports CAN additionally. */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** * Valid postal code. USA postal codes (ZIP codes) are supported, entered as a five-digit postal * code or nine-digit postal code (ZIP+4) using the format 12345-1234. KYC_EXEMPT supports * Canadian postal codes. */ - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") @ExcludeMissing fun _postalCode(): JsonField = postalCode /** * Valid state code. USA state codes are supported, entered in uppercase ISO 3166-2 * two-character format. KYC_EXEMPT supports Canadian province codes. */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** Unit or apartment number (if applicable). */ - @JsonProperty("address2") @ExcludeMissing fun _address2() = address2 + @JsonProperty("address2") @ExcludeMissing fun _address2(): JsonField = address2 @JsonAnyGetter @ExcludeMissing @@ -119,11 +119,11 @@ private constructor( class Builder { - private var address1: JsonField = JsonMissing.of() - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() + private var address1: JsonField? = null + private var city: JsonField? = null + private var country: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null private var address2: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -214,11 +214,11 @@ private constructor( fun build(): Address = Address( - address1, - city, - country, - postalCode, - state, + checkNotNull(address1) { "`address1` is required but was not set" }, + checkNotNull(city) { "`city` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(postalCode) { "`postalCode` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, address2, additionalProperties.toImmutable(), ) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AggregateBalance.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AggregateBalance.kt index 1782a54d..3aa22bb5 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AggregateBalance.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AggregateBalance.kt @@ -99,18 +99,20 @@ private constructor( fun updated(): OffsetDateTime = updated.getRequired("updated") /** Funds available for spend in the currency's smallest unit (e.g., cents for USD) */ - @JsonProperty("available_amount") @ExcludeMissing fun _availableAmount() = availableAmount + @JsonProperty("available_amount") + @ExcludeMissing + fun _availableAmount(): JsonField = availableAmount /** Date and time for when the balance was first created. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** 3-digit alphabetic ISO 4217 code for the local currency of the balance. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** Type of financial account */ @JsonProperty("financial_account_type") @ExcludeMissing - fun _financialAccountType() = financialAccountType + fun _financialAccountType(): JsonField = financialAccountType /** * Globally unique identifier for the financial account that had its balance updated most @@ -118,32 +120,34 @@ private constructor( */ @JsonProperty("last_financial_account_token") @ExcludeMissing - fun _lastFinancialAccountToken() = lastFinancialAccountToken + fun _lastFinancialAccountToken(): JsonField = lastFinancialAccountToken /** Globally unique identifier for the last transaction event that impacted this balance */ @JsonProperty("last_transaction_event_token") @ExcludeMissing - fun _lastTransactionEventToken() = lastTransactionEventToken + fun _lastTransactionEventToken(): JsonField = lastTransactionEventToken /** Globally unique identifier for the last transaction that impacted this balance */ @JsonProperty("last_transaction_token") @ExcludeMissing - fun _lastTransactionToken() = lastTransactionToken + fun _lastTransactionToken(): JsonField = lastTransactionToken /** * Funds not available for spend due to card authorizations or pending ACH release. Shown in the * currency's smallest unit (e.g., cents for USD) */ - @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount /** * The sum of available and pending balance in the currency's smallest unit (e.g., cents for * USD) */ - @JsonProperty("total_amount") @ExcludeMissing fun _totalAmount() = totalAmount + @JsonProperty("total_amount") @ExcludeMissing fun _totalAmount(): JsonField = totalAmount /** Date and time for when the balance was last updated. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated @JsonAnyGetter @ExcludeMissing @@ -176,16 +180,16 @@ private constructor( class Builder { - private var availableAmount: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var financialAccountType: JsonField = JsonMissing.of() - private var lastFinancialAccountToken: JsonField = JsonMissing.of() - private var lastTransactionEventToken: JsonField = JsonMissing.of() - private var lastTransactionToken: JsonField = JsonMissing.of() - private var pendingAmount: JsonField = JsonMissing.of() - private var totalAmount: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() + private var availableAmount: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var financialAccountType: JsonField? = null + private var lastFinancialAccountToken: JsonField? = null + private var lastTransactionEventToken: JsonField? = null + private var lastTransactionToken: JsonField? = null + private var pendingAmount: JsonField? = null + private var totalAmount: JsonField? = null + private var updated: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(aggregateBalance: AggregateBalance) = apply { @@ -317,16 +321,24 @@ private constructor( fun build(): AggregateBalance = AggregateBalance( - availableAmount, - created, - currency, - financialAccountType, - lastFinancialAccountToken, - lastTransactionEventToken, - lastTransactionToken, - pendingAmount, - totalAmount, - updated, + checkNotNull(availableAmount) { "`availableAmount` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(financialAccountType) { + "`financialAccountType` is required but was not set" + }, + checkNotNull(lastFinancialAccountToken) { + "`lastFinancialAccountToken` is required but was not set" + }, + checkNotNull(lastTransactionEventToken) { + "`lastTransactionEventToken` is required but was not set" + }, + checkNotNull(lastTransactionToken) { + "`lastTransactionToken` is required but was not set" + }, + checkNotNull(pendingAmount) { "`pendingAmount` is required but was not set" }, + checkNotNull(totalAmount) { "`totalAmount` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AggregateBalanceListResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AggregateBalanceListResponse.kt index 69230e40..bb0c2e49 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AggregateBalanceListResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AggregateBalanceListResponse.kt @@ -86,41 +86,47 @@ private constructor( fun updated(): OffsetDateTime = updated.getRequired("updated") /** Funds available for spend in the currency's smallest unit (e.g., cents for USD) */ - @JsonProperty("available_amount") @ExcludeMissing fun _availableAmount() = availableAmount + @JsonProperty("available_amount") + @ExcludeMissing + fun _availableAmount(): JsonField = availableAmount /** Date and time for when the balance was first created. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** 3-digit alphabetic ISO 4217 code for the local currency of the balance. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** Globally unique identifier for the card that had its balance updated most recently */ - @JsonProperty("last_card_token") @ExcludeMissing fun _lastCardToken() = lastCardToken + @JsonProperty("last_card_token") + @ExcludeMissing + fun _lastCardToken(): JsonField = lastCardToken /** Globally unique identifier for the last transaction event that impacted this balance */ @JsonProperty("last_transaction_event_token") @ExcludeMissing - fun _lastTransactionEventToken() = lastTransactionEventToken + fun _lastTransactionEventToken(): JsonField = lastTransactionEventToken /** Globally unique identifier for the last transaction that impacted this balance */ @JsonProperty("last_transaction_token") @ExcludeMissing - fun _lastTransactionToken() = lastTransactionToken + fun _lastTransactionToken(): JsonField = lastTransactionToken /** * Funds not available for spend due to card authorizations or pending ACH release. Shown in the * currency's smallest unit (e.g., cents for USD) */ - @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount /** * The sum of available and pending balance in the currency's smallest unit (e.g., cents for * USD) */ - @JsonProperty("total_amount") @ExcludeMissing fun _totalAmount() = totalAmount + @JsonProperty("total_amount") @ExcludeMissing fun _totalAmount(): JsonField = totalAmount /** Date and time for when the balance was last updated. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated @JsonAnyGetter @ExcludeMissing @@ -152,15 +158,15 @@ private constructor( class Builder { - private var availableAmount: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var lastCardToken: JsonField = JsonMissing.of() - private var lastTransactionEventToken: JsonField = JsonMissing.of() - private var lastTransactionToken: JsonField = JsonMissing.of() - private var pendingAmount: JsonField = JsonMissing.of() - private var totalAmount: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() + private var availableAmount: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var lastCardToken: JsonField? = null + private var lastTransactionEventToken: JsonField? = null + private var lastTransactionToken: JsonField? = null + private var pendingAmount: JsonField? = null + private var totalAmount: JsonField? = null + private var updated: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(aggregateBalanceListResponse: AggregateBalanceListResponse) = apply { @@ -275,15 +281,19 @@ private constructor( fun build(): AggregateBalanceListResponse = AggregateBalanceListResponse( - availableAmount, - created, - currency, - lastCardToken, - lastTransactionEventToken, - lastTransactionToken, - pendingAmount, - totalAmount, - updated, + checkNotNull(availableAmount) { "`availableAmount` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(lastCardToken) { "`lastCardToken` is required but was not set" }, + checkNotNull(lastTransactionEventToken) { + "`lastTransactionEventToken` is required but was not set" + }, + checkNotNull(lastTransactionToken) { + "`lastTransactionToken` is required but was not set" + }, + checkNotNull(pendingAmount) { "`pendingAmount` is required but was not set" }, + checkNotNull(totalAmount) { "`totalAmount` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ApiStatus.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ApiStatus.kt index a1505bf2..08dd3e47 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ApiStatus.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ApiStatus.kt @@ -27,7 +27,7 @@ private constructor( fun message(): String? = message.getNullable("message") - @JsonProperty("message") @ExcludeMissing fun _message() = message + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt index 28f4ff24..0cb832ab 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt @@ -85,41 +85,55 @@ private constructor( fun programLevel(): Boolean? = programLevel.getNullable("program_level") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Indicates whether the Auth Rule is ACTIVE or INACTIVE */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** * Array of account_token(s) identifying the accounts that the Auth Rule applies to. Note that * only this field or `card_tokens` can be provided for a given Auth Rule. */ - @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + @JsonProperty("account_tokens") + @ExcludeMissing + fun _accountTokens(): JsonField> = accountTokens /** * Countries in which the Auth Rule permits transactions. Note that Lithic maintains a list of * countries in which all transactions are blocked; "allowing" those countries in an Auth Rule * does not override the Lithic-wide restrictions. */ - @JsonProperty("allowed_countries") @ExcludeMissing fun _allowedCountries() = allowedCountries + @JsonProperty("allowed_countries") + @ExcludeMissing + fun _allowedCountries(): JsonField> = allowedCountries /** Merchant category codes for which the Auth Rule permits transactions. */ - @JsonProperty("allowed_mcc") @ExcludeMissing fun _allowedMcc() = allowedMcc + @JsonProperty("allowed_mcc") + @ExcludeMissing + fun _allowedMcc(): JsonField> = allowedMcc /** Countries in which the Auth Rule automatically declines transactions. */ - @JsonProperty("blocked_countries") @ExcludeMissing fun _blockedCountries() = blockedCountries + @JsonProperty("blocked_countries") + @ExcludeMissing + fun _blockedCountries(): JsonField> = blockedCountries /** Merchant category codes for which the Auth Rule automatically declines transactions. */ - @JsonProperty("blocked_mcc") @ExcludeMissing fun _blockedMcc() = blockedMcc + @JsonProperty("blocked_mcc") + @ExcludeMissing + fun _blockedMcc(): JsonField> = blockedMcc /** * Array of card_token(s) identifying the cards that the Auth Rule applies to. Note that only * this field or `account_tokens` can be provided for a given Auth Rule. */ - @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + @JsonProperty("card_tokens") + @ExcludeMissing + fun _cardTokens(): JsonField> = cardTokens /** Boolean indicating whether the Auth Rule is applied at the program level. */ - @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + @JsonProperty("program_level") + @ExcludeMissing + fun _programLevel(): JsonField = programLevel @JsonAnyGetter @ExcludeMissing @@ -151,26 +165,26 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var accountTokens: JsonField> = JsonMissing.of() - private var allowedCountries: JsonField> = JsonMissing.of() - private var allowedMcc: JsonField> = JsonMissing.of() - private var blockedCountries: JsonField> = JsonMissing.of() - private var blockedMcc: JsonField> = JsonMissing.of() - private var cardTokens: JsonField> = JsonMissing.of() + private var token: JsonField? = null + private var state: JsonField? = null + private var accountTokens: JsonField>? = null + private var allowedCountries: JsonField>? = null + private var allowedMcc: JsonField>? = null + private var blockedCountries: JsonField>? = null + private var blockedMcc: JsonField>? = null + private var cardTokens: JsonField>? = null private var programLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(authRule: AuthRule) = apply { token = authRule.token state = authRule.state - accountTokens = authRule.accountTokens - allowedCountries = authRule.allowedCountries - allowedMcc = authRule.allowedMcc - blockedCountries = authRule.blockedCountries - blockedMcc = authRule.blockedMcc - cardTokens = authRule.cardTokens + accountTokens = authRule.accountTokens.map { it.toMutableList() } + allowedCountries = authRule.allowedCountries.map { it.toMutableList() } + allowedMcc = authRule.allowedMcc.map { it.toMutableList() } + blockedCountries = authRule.blockedCountries.map { it.toMutableList() } + blockedMcc = authRule.blockedMcc.map { it.toMutableList() } + cardTokens = authRule.cardTokens.map { it.toMutableList() } programLevel = authRule.programLevel additionalProperties = authRule.additionalProperties.toMutableMap() } @@ -198,7 +212,22 @@ private constructor( * that only this field or `card_tokens` can be provided for a given Auth Rule. */ fun accountTokens(accountTokens: JsonField>) = apply { - this.accountTokens = accountTokens + this.accountTokens = accountTokens.map { it.toMutableList() } + } + + /** + * Array of account_token(s) identifying the accounts that the Auth Rule applies to. Note + * that only this field or `card_tokens` can be provided for a given Auth Rule. + */ + fun addAccountToken(accountToken: String) = apply { + accountTokens = + (accountTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(accountToken) + } } /** @@ -215,14 +244,44 @@ private constructor( * Rule does not override the Lithic-wide restrictions. */ fun allowedCountries(allowedCountries: JsonField>) = apply { - this.allowedCountries = allowedCountries + this.allowedCountries = allowedCountries.map { it.toMutableList() } + } + + /** + * Countries in which the Auth Rule permits transactions. Note that Lithic maintains a list + * of countries in which all transactions are blocked; "allowing" those countries in an Auth + * Rule does not override the Lithic-wide restrictions. + */ + fun addAllowedCountry(allowedCountry: String) = apply { + allowedCountries = + (allowedCountries ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(allowedCountry) + } } /** Merchant category codes for which the Auth Rule permits transactions. */ fun allowedMcc(allowedMcc: List) = allowedMcc(JsonField.of(allowedMcc)) /** Merchant category codes for which the Auth Rule permits transactions. */ - fun allowedMcc(allowedMcc: JsonField>) = apply { this.allowedMcc = allowedMcc } + fun allowedMcc(allowedMcc: JsonField>) = apply { + this.allowedMcc = allowedMcc.map { it.toMutableList() } + } + + /** Merchant category codes for which the Auth Rule permits transactions. */ + fun addAllowedMcc(allowedMcc: String) = apply { + this.allowedMcc = + (this.allowedMcc ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(allowedMcc) + } + } /** Countries in which the Auth Rule automatically declines transactions. */ fun blockedCountries(blockedCountries: List) = @@ -230,14 +289,40 @@ private constructor( /** Countries in which the Auth Rule automatically declines transactions. */ fun blockedCountries(blockedCountries: JsonField>) = apply { - this.blockedCountries = blockedCountries + this.blockedCountries = blockedCountries.map { it.toMutableList() } + } + + /** Countries in which the Auth Rule automatically declines transactions. */ + fun addBlockedCountry(blockedCountry: String) = apply { + blockedCountries = + (blockedCountries ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(blockedCountry) + } } /** Merchant category codes for which the Auth Rule automatically declines transactions. */ fun blockedMcc(blockedMcc: List) = blockedMcc(JsonField.of(blockedMcc)) /** Merchant category codes for which the Auth Rule automatically declines transactions. */ - fun blockedMcc(blockedMcc: JsonField>) = apply { this.blockedMcc = blockedMcc } + fun blockedMcc(blockedMcc: JsonField>) = apply { + this.blockedMcc = blockedMcc.map { it.toMutableList() } + } + + /** Merchant category codes for which the Auth Rule automatically declines transactions. */ + fun addBlockedMcc(blockedMcc: String) = apply { + this.blockedMcc = + (this.blockedMcc ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(blockedMcc) + } + } /** * Array of card_token(s) identifying the cards that the Auth Rule applies to. Note that @@ -249,7 +334,24 @@ private constructor( * Array of card_token(s) identifying the cards that the Auth Rule applies to. Note that * only this field or `account_tokens` can be provided for a given Auth Rule. */ - fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + fun cardTokens(cardTokens: JsonField>) = apply { + this.cardTokens = cardTokens.map { it.toMutableList() } + } + + /** + * Array of card_token(s) identifying the cards that the Auth Rule applies to. Note that + * only this field or `account_tokens` can be provided for a given Auth Rule. + */ + fun addCardToken(cardToken: String) = apply { + cardTokens = + (cardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(cardToken) + } + } /** Boolean indicating whether the Auth Rule is applied at the program level. */ fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) @@ -280,14 +382,14 @@ private constructor( fun build(): AuthRule = AuthRule( - token, - state, - accountTokens.map { it.toImmutable() }, - allowedCountries.map { it.toImmutable() }, - allowedMcc.map { it.toImmutable() }, - blockedCountries.map { it.toImmutable() }, - blockedMcc.map { it.toImmutable() }, - cardTokens.map { it.toImmutable() }, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + (accountTokens ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedCountries ?: JsonMissing.of()).map { it.toImmutable() }, + (allowedMcc ?: JsonMissing.of()).map { it.toImmutable() }, + (blockedCountries ?: JsonMissing.of()).map { it.toImmutable() }, + (blockedMcc ?: JsonMissing.of()).map { it.toImmutable() }, + (cardTokens ?: JsonMissing.of()).map { it.toImmutable() }, programLevel, additionalProperties.toImmutable(), ) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ApplyParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ApplyParams.kt index 710cc7ac..b6e3ecfd 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ApplyParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ApplyParams.kt @@ -16,6 +16,8 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.lithic.api.core.BaseDeserializer import com.lithic.api.core.BaseSerializer import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.getOrThrow @@ -380,18 +382,34 @@ constructor( class ApplyAuthRuleRequestAccountTokens @JsonCreator private constructor( - @JsonProperty("account_tokens") private val accountTokens: List, + @JsonProperty("account_tokens") + @ExcludeMissing + private val accountTokens: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Account tokens to which the Auth Rule applies. */ - @JsonProperty("account_tokens") fun accountTokens(): List = accountTokens + fun accountTokens(): List = accountTokens.getRequired("account_tokens") + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") + @ExcludeMissing + fun _accountTokens(): JsonField> = accountTokens @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ApplyAuthRuleRequestAccountTokens = apply { + if (!validated) { + accountTokens() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -401,25 +419,37 @@ constructor( class Builder { - private var accountTokens: MutableList? = null + private var accountTokens: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( applyAuthRuleRequestAccountTokens: ApplyAuthRuleRequestAccountTokens ) = apply { - accountTokens = applyAuthRuleRequestAccountTokens.accountTokens.toMutableList() + accountTokens = + applyAuthRuleRequestAccountTokens.accountTokens.map { it.toMutableList() } additionalProperties = applyAuthRuleRequestAccountTokens.additionalProperties.toMutableMap() } /** Account tokens to which the Auth Rule applies. */ - fun accountTokens(accountTokens: List) = apply { - this.accountTokens = accountTokens.toMutableList() + fun accountTokens(accountTokens: List) = + accountTokens(JsonField.of(accountTokens)) + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(accountTokens: JsonField>) = apply { + this.accountTokens = accountTokens.map { it.toMutableList() } } /** Account tokens to which the Auth Rule applies. */ fun addAccountToken(accountToken: String) = apply { - accountTokens = (accountTokens ?: mutableListOf()).apply { add(accountToken) } + accountTokens = + (accountTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(accountToken) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -444,7 +474,7 @@ constructor( fun build(): ApplyAuthRuleRequestAccountTokens = ApplyAuthRuleRequestAccountTokens( checkNotNull(accountTokens) { "`accountTokens` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -471,18 +501,34 @@ constructor( class ApplyAuthRuleRequestCardTokens @JsonCreator private constructor( - @JsonProperty("card_tokens") private val cardTokens: List, + @JsonProperty("card_tokens") + @ExcludeMissing + private val cardTokens: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Card tokens to which the Auth Rule applies. */ - @JsonProperty("card_tokens") fun cardTokens(): List = cardTokens + fun cardTokens(): List = cardTokens.getRequired("card_tokens") + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") + @ExcludeMissing + fun _cardTokens(): JsonField> = cardTokens @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ApplyAuthRuleRequestCardTokens = apply { + if (!validated) { + cardTokens() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -492,24 +538,35 @@ constructor( class Builder { - private var cardTokens: MutableList? = null + private var cardTokens: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(applyAuthRuleRequestCardTokens: ApplyAuthRuleRequestCardTokens) = apply { - cardTokens = applyAuthRuleRequestCardTokens.cardTokens.toMutableList() + cardTokens = + applyAuthRuleRequestCardTokens.cardTokens.map { it.toMutableList() } additionalProperties = applyAuthRuleRequestCardTokens.additionalProperties.toMutableMap() } /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: List) = apply { - this.cardTokens = cardTokens.toMutableList() + fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(cardTokens: JsonField>) = apply { + this.cardTokens = cardTokens.map { it.toMutableList() } } /** Card tokens to which the Auth Rule applies. */ fun addCardToken(cardToken: String) = apply { - cardTokens = (cardTokens ?: mutableListOf()).apply { add(cardToken) } + cardTokens = + (cardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(cardToken) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -534,7 +591,7 @@ constructor( fun build(): ApplyAuthRuleRequestCardTokens = ApplyAuthRuleRequestCardTokens( checkNotNull(cardTokens) { "`cardTokens` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -561,23 +618,47 @@ constructor( class ApplyAuthRuleRequestProgramLevel @JsonCreator private constructor( - @JsonProperty("program_level") private val programLevel: Boolean, - @JsonProperty("excluded_card_tokens") private val excludedCardTokens: List?, + @JsonProperty("program_level") + @ExcludeMissing + private val programLevel: JsonField = JsonMissing.of(), + @JsonProperty("excluded_card_tokens") + @ExcludeMissing + private val excludedCardTokens: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Whether the Auth Rule applies to all authorizations on the card program. */ - @JsonProperty("program_level") fun programLevel(): Boolean = programLevel + fun programLevel(): Boolean = programLevel.getRequired("program_level") + + /** Card tokens to which the Auth Rule does not apply. */ + fun excludedCardTokens(): List? = + excludedCardTokens.getNullable("excluded_card_tokens") + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") + @ExcludeMissing + fun _programLevel(): JsonField = programLevel /** Card tokens to which the Auth Rule does not apply. */ @JsonProperty("excluded_card_tokens") - fun excludedCardTokens(): List? = excludedCardTokens + @ExcludeMissing + fun _excludedCardTokens(): JsonField> = excludedCardTokens @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ApplyAuthRuleRequestProgramLevel = apply { + if (!validated) { + programLevel() + excludedCardTokens() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -587,31 +668,48 @@ constructor( class Builder { - private var programLevel: Boolean? = null - private var excludedCardTokens: MutableList? = null + private var programLevel: JsonField? = null + private var excludedCardTokens: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(applyAuthRuleRequestProgramLevel: ApplyAuthRuleRequestProgramLevel) = apply { programLevel = applyAuthRuleRequestProgramLevel.programLevel excludedCardTokens = - applyAuthRuleRequestProgramLevel.excludedCardTokens?.toMutableList() + applyAuthRuleRequestProgramLevel.excludedCardTokens.map { + it.toMutableList() + } additionalProperties = applyAuthRuleRequestProgramLevel.additionalProperties.toMutableMap() } /** Whether the Auth Rule applies to all authorizations on the card program. */ - fun programLevel(programLevel: Boolean) = apply { this.programLevel = programLevel } + fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(programLevel: JsonField) = apply { + this.programLevel = programLevel + } + + /** Card tokens to which the Auth Rule does not apply. */ + fun excludedCardTokens(excludedCardTokens: List) = + excludedCardTokens(JsonField.of(excludedCardTokens)) /** Card tokens to which the Auth Rule does not apply. */ - fun excludedCardTokens(excludedCardTokens: List?) = apply { - this.excludedCardTokens = excludedCardTokens?.toMutableList() + fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { + this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } } /** Card tokens to which the Auth Rule does not apply. */ fun addExcludedCardToken(excludedCardToken: String) = apply { excludedCardTokens = - (excludedCardTokens ?: mutableListOf()).apply { add(excludedCardToken) } + (excludedCardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(excludedCardToken) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -636,7 +734,7 @@ constructor( fun build(): ApplyAuthRuleRequestProgramLevel = ApplyAuthRuleRequestProgramLevel( checkNotNull(programLevel) { "`programLevel` is required but was not set" }, - excludedCardTokens?.toImmutable(), + (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2BacktestCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2BacktestCreateParams.kt index bd321983..d62d2e47 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2BacktestCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2BacktestCreateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -55,12 +57,18 @@ constructor( /** The start time of the backtest. */ fun start(): OffsetDateTime? = body.start() - fun _additionalHeaders(): Headers = additionalHeaders + /** The end time of the backtest. */ + fun _end(): JsonField = body._end() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The start time of the backtest. */ + fun _start(): JsonField = body._start() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): AuthRuleV2BacktestCreateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -78,22 +86,42 @@ constructor( class AuthRuleV2BacktestCreateBody @JsonCreator internal constructor( - @JsonProperty("end") private val end: OffsetDateTime?, - @JsonProperty("start") private val start: OffsetDateTime?, + @JsonProperty("end") + @ExcludeMissing + private val end: JsonField = JsonMissing.of(), + @JsonProperty("start") + @ExcludeMissing + private val start: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The end time of the backtest. */ - @JsonProperty("end") fun end(): OffsetDateTime? = end + fun end(): OffsetDateTime? = end.getNullable("end") + + /** The start time of the backtest. */ + fun start(): OffsetDateTime? = start.getNullable("start") + + /** The end time of the backtest. */ + @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end /** The start time of the backtest. */ - @JsonProperty("start") fun start(): OffsetDateTime? = start + @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AuthRuleV2BacktestCreateBody = apply { + if (!validated) { + end() + start() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -103,8 +131,8 @@ constructor( class Builder { - private var end: OffsetDateTime? = null - private var start: OffsetDateTime? = null + private var end: JsonField = JsonMissing.of() + private var start: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(authRuleV2BacktestCreateBody: AuthRuleV2BacktestCreateBody) = apply { @@ -115,10 +143,16 @@ constructor( } /** The end time of the backtest. */ - fun end(end: OffsetDateTime?) = apply { this.end = end } + fun end(end: OffsetDateTime) = end(JsonField.of(end)) + + /** The end time of the backtest. */ + fun end(end: JsonField) = apply { this.end = end } /** The start time of the backtest. */ - fun start(start: OffsetDateTime?) = apply { this.start = start } + fun start(start: OffsetDateTime) = start(JsonField.of(start)) + + /** The start time of the backtest. */ + fun start(start: JsonField) = apply { this.start = start } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -191,10 +225,35 @@ constructor( fun authRuleToken(authRuleToken: String) = apply { this.authRuleToken = authRuleToken } /** The end time of the backtest. */ - fun end(end: OffsetDateTime?) = apply { body.end(end) } + fun end(end: OffsetDateTime) = apply { body.end(end) } + + /** The end time of the backtest. */ + fun end(end: JsonField) = apply { body.end(end) } /** The start time of the backtest. */ - fun start(start: OffsetDateTime?) = apply { body.start(start) } + fun start(start: OffsetDateTime) = apply { body.start(start) } + + /** The start time of the backtest. */ + fun start(start: JsonField) = apply { body.start(start) } + + 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() @@ -294,25 +353,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): AuthRuleV2BacktestCreateParams = AuthRuleV2BacktestCreateParams( checkNotNull(authRuleToken) { "`authRuleToken` is required but was not set" }, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt index 3ce5b835..a89f20e2 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt @@ -18,6 +18,7 @@ import com.lithic.api.core.BaseSerializer import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.getOrThrow @@ -377,30 +378,66 @@ constructor( class CreateAuthRuleRequestAccountTokens @JsonCreator private constructor( - @JsonProperty("account_tokens") private val accountTokens: List, - @JsonProperty("name") private val name: String?, - @JsonProperty("parameters") private val parameters: Parameters?, - @JsonProperty("type") private val type: AuthRuleType?, + @JsonProperty("account_tokens") + @ExcludeMissing + private val accountTokens: JsonField> = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("parameters") + @ExcludeMissing + private val parameters: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Account tokens to which the Auth Rule applies. */ - @JsonProperty("account_tokens") fun accountTokens(): List = accountTokens + fun accountTokens(): List = accountTokens.getRequired("account_tokens") /** Auth Rule Name */ - @JsonProperty("name") fun name(): String? = name + fun name(): String? = name.getNullable("name") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") fun parameters(): Parameters? = parameters + fun parameters(): Parameters? = parameters.getNullable("parameters") /** The type of Auth Rule */ - @JsonProperty("type") fun type(): AuthRuleType? = type + fun type(): AuthRuleType? = type.getNullable("type") + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") + @ExcludeMissing + fun _accountTokens(): JsonField> = accountTokens + + /** Auth Rule Name */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters + + /** The type of Auth Rule */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CreateAuthRuleRequestAccountTokens = apply { + if (!validated) { + accountTokens() + name() + parameters() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -410,16 +447,17 @@ constructor( class Builder { - private var accountTokens: MutableList? = null - private var name: String? = null - private var parameters: Parameters? = null - private var type: AuthRuleType? = null + private var accountTokens: JsonField>? = null + private var name: JsonField = JsonMissing.of() + private var parameters: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( createAuthRuleRequestAccountTokens: CreateAuthRuleRequestAccountTokens ) = apply { - accountTokens = createAuthRuleRequestAccountTokens.accountTokens.toMutableList() + accountTokens = + createAuthRuleRequestAccountTokens.accountTokens.map { it.toMutableList() } name = createAuthRuleRequestAccountTokens.name parameters = createAuthRuleRequestAccountTokens.parameters type = createAuthRuleRequestAccountTokens.type @@ -428,33 +466,51 @@ constructor( } /** Account tokens to which the Auth Rule applies. */ - fun accountTokens(accountTokens: List) = apply { - this.accountTokens = accountTokens.toMutableList() + fun accountTokens(accountTokens: List) = + accountTokens(JsonField.of(accountTokens)) + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(accountTokens: JsonField>) = apply { + this.accountTokens = accountTokens.map { it.toMutableList() } } /** Account tokens to which the Auth Rule applies. */ fun addAccountToken(accountToken: String) = apply { - accountTokens = (accountTokens ?: mutableListOf()).apply { add(accountToken) } + accountTokens = + (accountTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(accountToken) + } } /** Auth Rule Name */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Auth Rule Name */ + fun name(name: JsonField) = apply { this.name = name } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) /** Parameters for the current version of the Auth Rule */ - fun parameters(parameters: Parameters?) = apply { this.parameters = parameters } + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = - apply { - this.parameters = - Parameters.ofConditionalBlockParameters(conditionalBlockParameters) - } + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) - fun parameters(velocityLimitParams: VelocityLimitParams) = apply { - this.parameters = Parameters.ofVelocityLimitParams(velocityLimitParams) - } + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) /** The type of Auth Rule */ - fun type(type: AuthRuleType?) = apply { this.type = type } + fun type(type: AuthRuleType) = type(JsonField.of(type)) + + /** The type of Auth Rule */ + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -478,7 +534,7 @@ constructor( fun build(): CreateAuthRuleRequestAccountTokens = CreateAuthRuleRequestAccountTokens( checkNotNull(accountTokens) { "`accountTokens` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, name, parameters, type, @@ -496,6 +552,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun conditionalBlockParameters(): ConditionalBlockParameters? = conditionalBlockParameters @@ -523,6 +581,17 @@ constructor( } } + fun validate(): Parameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown Parameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -571,12 +640,16 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Parameters { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Parameters(conditionalBlockParameters = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Parameters(velocityLimitParams = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Parameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Parameters(velocityLimitParams = it, _json = json) + } return Parameters(_json = json) } @@ -604,17 +677,32 @@ constructor( class ConditionalBlockParameters @JsonCreator private constructor( - @JsonProperty("conditions") private val conditions: List, + @JsonProperty("conditions") + @ExcludeMissing + private val conditions: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("conditions") fun conditions(): List = conditions + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -624,22 +712,33 @@ constructor( class Builder { - private var conditions: MutableList? = null + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions.toMutableList() + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } - fun conditions(conditions: List) = apply { - this.conditions = conditions.toMutableList() + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions.map { it.toMutableList() } } fun addCondition(condition: Condition) = apply { - conditions = (conditions ?: mutableListOf()).apply { add(condition) } + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -667,7 +766,7 @@ constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( checkNotNull(conditions) { "`conditions` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -676,9 +775,15 @@ constructor( class Condition @JsonCreator private constructor( - @JsonProperty("attribute") private val attribute: Attribute?, - @JsonProperty("operation") private val operation: Operation?, - @JsonProperty("value") private val value: Value?, + @JsonProperty("attribute") + @ExcludeMissing + private val attribute: JsonField = JsonMissing.of(), + @JsonProperty("operation") + @ExcludeMissing + private val operation: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -719,18 +824,77 @@ constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") fun attribute(): Attribute? = attribute + fun attribute(): Attribute? = attribute.getNullable("attribute") /** The operation to apply to the attribute */ - @JsonProperty("operation") fun operation(): Operation? = operation + fun operation(): Operation? = operation.getNullable("operation") /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") fun value(): Value? = value + fun value(): Value? = value.getNullable("value") + + /** + * The attribute to target. + * + * The following attributes may be targeted: + * - `MCC`: A four-digit number listed in ISO 18245. An MCC is used to classify + * a business by the types of goods or services it provides. + * - `COUNTRY`: Country of entity of card acceptor. Possible values are: (1) all + * ISO 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and (3) ANT for + * Netherlands Antilles. + * - `CURRENCY`: 3-digit alphabetic ISO 4217 code for the merchant currency of + * the transaction. + * - `MERCHANT_ID`: Unique alphanumeric identifier for the payment card acceptor + * (merchant). + * - `DESCRIPTOR`: Short description of card acceptor. + * - `LIABILITY_SHIFT`: Indicates whether chargeback liability shift to the + * issuer applies to the transaction. Valid values are `NONE`, + * `3DS_AUTHENTICATED`, or `TOKEN_AUTHENTICATED`. + * - `PAN_ENTRY_MODE`: The method by which the cardholder's primary account + * number (PAN) was entered. Valid values are `AUTO_ENTRY`, `BAR_CODE`, + * `CONTACTLESS`, `ECOMMERCE`, `ERROR_KEYED`, `ERROR_MAGNETIC_STRIPE`, `ICC`, + * `KEY_ENTERED`, `MAGNETIC_STRIPE`, `MANUAL`, `OCR`, `SECURE_CARDLESS`, + * `UNSPECIFIED`, `UNKNOWN`, `CREDENTIAL_ON_FILE`, or `ECOMMERCE`. + * - `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the + * acquirer fee field in the settlement/cardholder billing currency. This is + * the amount the issuer should authorize against unless the issuer is paying + * the acquirer fee on behalf of the cardholder. + * - `RISK_SCORE`: Network-provided score assessing risk level associated with a + * given authorization. Scores are on a range of 0-999, with 0 representing + * the lowest risk and 999 representing the highest risk. For Visa + * transactions, where the raw score has a range of 0-99, Lithic will + * normalize the score by multiplying the raw score by 10x. + * - `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in the + * trailing hour up and until the authorization. + * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the + * trailing 24 hours up and until the authorization. + */ + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -740,9 +904,9 @@ constructor( class Builder { - private var attribute: Attribute? = null - private var operation: Operation? = null - private var value: Value? = null + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -790,24 +954,71 @@ constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in * the trailing 24 hours up and until the authorization. */ - fun attribute(attribute: Attribute?) = apply { this.attribute = attribute } + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** + * The attribute to target. + * + * The following attributes may be targeted: + * - `MCC`: A four-digit number listed in ISO 18245. An MCC is used to + * classify a business by the types of goods or services it provides. + * - `COUNTRY`: Country of entity of card acceptor. Possible values are: (1) + * all ISO 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and (3) ANT + * for Netherlands Antilles. + * - `CURRENCY`: 3-digit alphabetic ISO 4217 code for the merchant currency + * of the transaction. + * - `MERCHANT_ID`: Unique alphanumeric identifier for the payment card + * acceptor (merchant). + * - `DESCRIPTOR`: Short description of card acceptor. + * - `LIABILITY_SHIFT`: Indicates whether chargeback liability shift to the + * issuer applies to the transaction. Valid values are `NONE`, + * `3DS_AUTHENTICATED`, or `TOKEN_AUTHENTICATED`. + * - `PAN_ENTRY_MODE`: The method by which the cardholder's primary account + * number (PAN) was entered. Valid values are `AUTO_ENTRY`, `BAR_CODE`, + * `CONTACTLESS`, `ECOMMERCE`, `ERROR_KEYED`, `ERROR_MAGNETIC_STRIPE`, + * `ICC`, `KEY_ENTERED`, `MAGNETIC_STRIPE`, `MANUAL`, `OCR`, + * `SECURE_CARDLESS`, `UNSPECIFIED`, `UNKNOWN`, `CREDENTIAL_ON_FILE`, or + * `ECOMMERCE`. + * - `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the + * acquirer fee field in the settlement/cardholder billing currency. This + * is the amount the issuer should authorize against unless the issuer is + * paying the acquirer fee on behalf of the cardholder. + * - `RISK_SCORE`: Network-provided score assessing risk level associated + * with a given authorization. Scores are on a range of 0-999, with 0 + * representing the lowest risk and 999 representing the highest risk. For + * Visa transactions, where the raw score has a range of 0-99, Lithic will + * normalize the score by multiplying the raw score by 10x. + * - `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in + * the trailing hour up and until the authorization. + * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in + * the trailing 24 hours up and until the authorization. + */ + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) /** The operation to apply to the attribute */ - fun operation(operation: Operation?) = apply { this.operation = operation } + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(value: Value) = value(JsonField.of(value)) /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - fun value(value: Value?) = apply { this.value = value } + fun value(value: JsonField) = apply { this.value = value } /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - fun value(string: String) = apply { this.value = Value.ofString(string) } + fun value(string: String) = value(Value.ofString(string)) /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ - fun value(long: Long) = apply { this.value = Value.ofLong(long) } + fun value(long: Long) = value(Value.ofLong(long)) /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ - fun valueOfStrings(strings: List) = apply { - this.value = Value.ofStrings(strings) - } + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) fun additionalProperties(additionalProperties: Map) = apply { @@ -1047,6 +1258,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun string(): String? = string /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ @@ -1078,6 +1291,15 @@ constructor( } } + fun validate(): Value = apply { + if (!validated) { + if (string == null && long == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1277,30 +1499,66 @@ constructor( class CreateAuthRuleRequestCardTokens @JsonCreator private constructor( - @JsonProperty("card_tokens") private val cardTokens: List, - @JsonProperty("name") private val name: String?, - @JsonProperty("parameters") private val parameters: Parameters?, - @JsonProperty("type") private val type: AuthRuleType?, + @JsonProperty("card_tokens") + @ExcludeMissing + private val cardTokens: JsonField> = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("parameters") + @ExcludeMissing + private val parameters: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Card tokens to which the Auth Rule applies. */ - @JsonProperty("card_tokens") fun cardTokens(): List = cardTokens + fun cardTokens(): List = cardTokens.getRequired("card_tokens") + + /** Auth Rule Name */ + fun name(): String? = name.getNullable("name") + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): Parameters? = parameters.getNullable("parameters") + + /** The type of Auth Rule */ + fun type(): AuthRuleType? = type.getNullable("type") + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") + @ExcludeMissing + fun _cardTokens(): JsonField> = cardTokens /** Auth Rule Name */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") fun parameters(): Parameters? = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The type of Auth Rule */ - @JsonProperty("type") fun type(): AuthRuleType? = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CreateAuthRuleRequestCardTokens = apply { + if (!validated) { + cardTokens() + name() + parameters() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1310,15 +1568,16 @@ constructor( class Builder { - private var cardTokens: MutableList? = null - private var name: String? = null - private var parameters: Parameters? = null - private var type: AuthRuleType? = null + private var cardTokens: JsonField>? = null + private var name: JsonField = JsonMissing.of() + private var parameters: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(createAuthRuleRequestCardTokens: CreateAuthRuleRequestCardTokens) = apply { - cardTokens = createAuthRuleRequestCardTokens.cardTokens.toMutableList() + cardTokens = + createAuthRuleRequestCardTokens.cardTokens.map { it.toMutableList() } name = createAuthRuleRequestCardTokens.name parameters = createAuthRuleRequestCardTokens.parameters type = createAuthRuleRequestCardTokens.type @@ -1327,33 +1586,50 @@ constructor( } /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: List) = apply { - this.cardTokens = cardTokens.toMutableList() + fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(cardTokens: JsonField>) = apply { + this.cardTokens = cardTokens.map { it.toMutableList() } } /** Card tokens to which the Auth Rule applies. */ fun addCardToken(cardToken: String) = apply { - cardTokens = (cardTokens ?: mutableListOf()).apply { add(cardToken) } + cardTokens = + (cardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(cardToken) + } } /** Auth Rule Name */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Auth Rule Name */ + fun name(name: JsonField) = apply { this.name = name } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) /** Parameters for the current version of the Auth Rule */ - fun parameters(parameters: Parameters?) = apply { this.parameters = parameters } + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = - apply { - this.parameters = - Parameters.ofConditionalBlockParameters(conditionalBlockParameters) - } + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) - fun parameters(velocityLimitParams: VelocityLimitParams) = apply { - this.parameters = Parameters.ofVelocityLimitParams(velocityLimitParams) - } + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) /** The type of Auth Rule */ - fun type(type: AuthRuleType?) = apply { this.type = type } + fun type(type: AuthRuleType) = type(JsonField.of(type)) + + /** The type of Auth Rule */ + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1377,7 +1653,7 @@ constructor( fun build(): CreateAuthRuleRequestCardTokens = CreateAuthRuleRequestCardTokens( checkNotNull(cardTokens) { "`cardTokens` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, name, parameters, type, @@ -1395,6 +1671,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun conditionalBlockParameters(): ConditionalBlockParameters? = conditionalBlockParameters @@ -1422,6 +1700,17 @@ constructor( } } + fun validate(): Parameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown Parameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1470,12 +1759,16 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Parameters { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Parameters(conditionalBlockParameters = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Parameters(velocityLimitParams = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Parameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Parameters(velocityLimitParams = it, _json = json) + } return Parameters(_json = json) } @@ -1503,17 +1796,32 @@ constructor( class ConditionalBlockParameters @JsonCreator private constructor( - @JsonProperty("conditions") private val conditions: List, + @JsonProperty("conditions") + @ExcludeMissing + private val conditions: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("conditions") fun conditions(): List = conditions + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1523,22 +1831,33 @@ constructor( class Builder { - private var conditions: MutableList? = null + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions.toMutableList() + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } - fun conditions(conditions: List) = apply { - this.conditions = conditions.toMutableList() + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions.map { it.toMutableList() } } fun addCondition(condition: Condition) = apply { - conditions = (conditions ?: mutableListOf()).apply { add(condition) } + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -1566,7 +1885,7 @@ constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( checkNotNull(conditions) { "`conditions` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -1575,9 +1894,15 @@ constructor( class Condition @JsonCreator private constructor( - @JsonProperty("attribute") private val attribute: Attribute?, - @JsonProperty("operation") private val operation: Operation?, - @JsonProperty("value") private val value: Value?, + @JsonProperty("attribute") + @ExcludeMissing + private val attribute: JsonField = JsonMissing.of(), + @JsonProperty("operation") + @ExcludeMissing + private val operation: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -1618,18 +1943,77 @@ constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") fun attribute(): Attribute? = attribute + fun attribute(): Attribute? = attribute.getNullable("attribute") + + /** The operation to apply to the attribute */ + fun operation(): Operation? = operation.getNullable("operation") + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(): Value? = value.getNullable("value") + + /** + * The attribute to target. + * + * The following attributes may be targeted: + * - `MCC`: A four-digit number listed in ISO 18245. An MCC is used to classify + * a business by the types of goods or services it provides. + * - `COUNTRY`: Country of entity of card acceptor. Possible values are: (1) all + * ISO 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and (3) ANT for + * Netherlands Antilles. + * - `CURRENCY`: 3-digit alphabetic ISO 4217 code for the merchant currency of + * the transaction. + * - `MERCHANT_ID`: Unique alphanumeric identifier for the payment card acceptor + * (merchant). + * - `DESCRIPTOR`: Short description of card acceptor. + * - `LIABILITY_SHIFT`: Indicates whether chargeback liability shift to the + * issuer applies to the transaction. Valid values are `NONE`, + * `3DS_AUTHENTICATED`, or `TOKEN_AUTHENTICATED`. + * - `PAN_ENTRY_MODE`: The method by which the cardholder's primary account + * number (PAN) was entered. Valid values are `AUTO_ENTRY`, `BAR_CODE`, + * `CONTACTLESS`, `ECOMMERCE`, `ERROR_KEYED`, `ERROR_MAGNETIC_STRIPE`, `ICC`, + * `KEY_ENTERED`, `MAGNETIC_STRIPE`, `MANUAL`, `OCR`, `SECURE_CARDLESS`, + * `UNSPECIFIED`, `UNKNOWN`, `CREDENTIAL_ON_FILE`, or `ECOMMERCE`. + * - `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the + * acquirer fee field in the settlement/cardholder billing currency. This is + * the amount the issuer should authorize against unless the issuer is paying + * the acquirer fee on behalf of the cardholder. + * - `RISK_SCORE`: Network-provided score assessing risk level associated with a + * given authorization. Scores are on a range of 0-999, with 0 representing + * the lowest risk and 999 representing the highest risk. For Visa + * transactions, where the raw score has a range of 0-99, Lithic will + * normalize the score by multiplying the raw score by 10x. + * - `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in the + * trailing hour up and until the authorization. + * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the + * trailing 24 hours up and until the authorization. + */ + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") fun operation(): Operation? = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") fun value(): Value? = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1639,9 +2023,9 @@ constructor( class Builder { - private var attribute: Attribute? = null - private var operation: Operation? = null - private var value: Value? = null + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1689,24 +2073,71 @@ constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in * the trailing 24 hours up and until the authorization. */ - fun attribute(attribute: Attribute?) = apply { this.attribute = attribute } + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** + * The attribute to target. + * + * The following attributes may be targeted: + * - `MCC`: A four-digit number listed in ISO 18245. An MCC is used to + * classify a business by the types of goods or services it provides. + * - `COUNTRY`: Country of entity of card acceptor. Possible values are: (1) + * all ISO 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and (3) ANT + * for Netherlands Antilles. + * - `CURRENCY`: 3-digit alphabetic ISO 4217 code for the merchant currency + * of the transaction. + * - `MERCHANT_ID`: Unique alphanumeric identifier for the payment card + * acceptor (merchant). + * - `DESCRIPTOR`: Short description of card acceptor. + * - `LIABILITY_SHIFT`: Indicates whether chargeback liability shift to the + * issuer applies to the transaction. Valid values are `NONE`, + * `3DS_AUTHENTICATED`, or `TOKEN_AUTHENTICATED`. + * - `PAN_ENTRY_MODE`: The method by which the cardholder's primary account + * number (PAN) was entered. Valid values are `AUTO_ENTRY`, `BAR_CODE`, + * `CONTACTLESS`, `ECOMMERCE`, `ERROR_KEYED`, `ERROR_MAGNETIC_STRIPE`, + * `ICC`, `KEY_ENTERED`, `MAGNETIC_STRIPE`, `MANUAL`, `OCR`, + * `SECURE_CARDLESS`, `UNSPECIFIED`, `UNKNOWN`, `CREDENTIAL_ON_FILE`, or + * `ECOMMERCE`. + * - `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the + * acquirer fee field in the settlement/cardholder billing currency. This + * is the amount the issuer should authorize against unless the issuer is + * paying the acquirer fee on behalf of the cardholder. + * - `RISK_SCORE`: Network-provided score assessing risk level associated + * with a given authorization. Scores are on a range of 0-999, with 0 + * representing the lowest risk and 999 representing the highest risk. For + * Visa transactions, where the raw score has a range of 0-99, Lithic will + * normalize the score by multiplying the raw score by 10x. + * - `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in + * the trailing hour up and until the authorization. + * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in + * the trailing 24 hours up and until the authorization. + */ + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) /** The operation to apply to the attribute */ - fun operation(operation: Operation?) = apply { this.operation = operation } + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(value: Value) = value(JsonField.of(value)) /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - fun value(value: Value?) = apply { this.value = value } + fun value(value: JsonField) = apply { this.value = value } /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - fun value(string: String) = apply { this.value = Value.ofString(string) } + fun value(string: String) = value(Value.ofString(string)) /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ - fun value(long: Long) = apply { this.value = Value.ofLong(long) } + fun value(long: Long) = value(Value.ofLong(long)) /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ - fun valueOfStrings(strings: List) = apply { - this.value = Value.ofStrings(strings) - } + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) fun additionalProperties(additionalProperties: Map) = apply { @@ -1946,6 +2377,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun string(): String? = string /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ @@ -1977,6 +2410,15 @@ constructor( } } + fun validate(): Value = apply { + if (!validated) { + if (string == null && long == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2176,35 +2618,79 @@ constructor( class CreateAuthRuleRequestProgramLevel @JsonCreator private constructor( - @JsonProperty("program_level") private val programLevel: Boolean, - @JsonProperty("excluded_card_tokens") private val excludedCardTokens: List?, - @JsonProperty("name") private val name: String?, - @JsonProperty("parameters") private val parameters: Parameters?, - @JsonProperty("type") private val type: AuthRuleType?, + @JsonProperty("program_level") + @ExcludeMissing + private val programLevel: JsonField = JsonMissing.of(), + @JsonProperty("excluded_card_tokens") + @ExcludeMissing + private val excludedCardTokens: JsonField> = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("parameters") + @ExcludeMissing + private val parameters: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Whether the Auth Rule applies to all authorizations on the card program. */ - @JsonProperty("program_level") fun programLevel(): Boolean = programLevel + fun programLevel(): Boolean = programLevel.getRequired("program_level") + + /** Card tokens to which the Auth Rule does not apply. */ + fun excludedCardTokens(): List? = + excludedCardTokens.getNullable("excluded_card_tokens") + + /** Auth Rule Name */ + fun name(): String? = name.getNullable("name") + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): Parameters? = parameters.getNullable("parameters") + + /** The type of Auth Rule */ + fun type(): AuthRuleType? = type.getNullable("type") + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") + @ExcludeMissing + fun _programLevel(): JsonField = programLevel /** Card tokens to which the Auth Rule does not apply. */ @JsonProperty("excluded_card_tokens") - fun excludedCardTokens(): List? = excludedCardTokens + @ExcludeMissing + fun _excludedCardTokens(): JsonField> = excludedCardTokens /** Auth Rule Name */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") fun parameters(): Parameters? = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The type of Auth Rule */ - @JsonProperty("type") fun type(): AuthRuleType? = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CreateAuthRuleRequestProgramLevel = apply { + if (!validated) { + programLevel() + excludedCardTokens() + name() + parameters() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2214,11 +2700,11 @@ constructor( class Builder { - private var programLevel: Boolean? = null - private var excludedCardTokens: MutableList? = null - private var name: String? = null - private var parameters: Parameters? = null - private var type: AuthRuleType? = null + private var programLevel: JsonField? = null + private var excludedCardTokens: JsonField>? = null + private var name: JsonField = JsonMissing.of() + private var parameters: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -2226,7 +2712,7 @@ constructor( ) = apply { programLevel = createAuthRuleRequestProgramLevel.programLevel excludedCardTokens = - createAuthRuleRequestProgramLevel.excludedCardTokens?.toMutableList() + createAuthRuleRequestProgramLevel.excludedCardTokens.map { it.toMutableList() } name = createAuthRuleRequestProgramLevel.name parameters = createAuthRuleRequestProgramLevel.parameters type = createAuthRuleRequestProgramLevel.type @@ -2235,37 +2721,59 @@ constructor( } /** Whether the Auth Rule applies to all authorizations on the card program. */ - fun programLevel(programLevel: Boolean) = apply { this.programLevel = programLevel } + fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(programLevel: JsonField) = apply { + this.programLevel = programLevel + } /** Card tokens to which the Auth Rule does not apply. */ - fun excludedCardTokens(excludedCardTokens: List?) = apply { - this.excludedCardTokens = excludedCardTokens?.toMutableList() + fun excludedCardTokens(excludedCardTokens: List) = + excludedCardTokens(JsonField.of(excludedCardTokens)) + + /** Card tokens to which the Auth Rule does not apply. */ + fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { + this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } } /** Card tokens to which the Auth Rule does not apply. */ fun addExcludedCardToken(excludedCardToken: String) = apply { excludedCardTokens = - (excludedCardTokens ?: mutableListOf()).apply { add(excludedCardToken) } + (excludedCardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(excludedCardToken) + } } /** Auth Rule Name */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Auth Rule Name */ + fun name(name: JsonField) = apply { this.name = name } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) /** Parameters for the current version of the Auth Rule */ - fun parameters(parameters: Parameters?) = apply { this.parameters = parameters } + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = - apply { - this.parameters = - Parameters.ofConditionalBlockParameters(conditionalBlockParameters) - } + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) - fun parameters(velocityLimitParams: VelocityLimitParams) = apply { - this.parameters = Parameters.ofVelocityLimitParams(velocityLimitParams) - } + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) /** The type of Auth Rule */ - fun type(type: AuthRuleType?) = apply { this.type = type } + fun type(type: AuthRuleType) = type(JsonField.of(type)) + + /** The type of Auth Rule */ + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2289,7 +2797,7 @@ constructor( fun build(): CreateAuthRuleRequestProgramLevel = CreateAuthRuleRequestProgramLevel( checkNotNull(programLevel) { "`programLevel` is required but was not set" }, - excludedCardTokens?.toImmutable(), + (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, name, parameters, type, @@ -2307,6 +2815,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun conditionalBlockParameters(): ConditionalBlockParameters? = conditionalBlockParameters @@ -2334,6 +2844,17 @@ constructor( } } + fun validate(): Parameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown Parameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2382,12 +2903,16 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Parameters { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Parameters(conditionalBlockParameters = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Parameters(velocityLimitParams = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Parameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Parameters(velocityLimitParams = it, _json = json) + } return Parameters(_json = json) } @@ -2415,17 +2940,32 @@ constructor( class ConditionalBlockParameters @JsonCreator private constructor( - @JsonProperty("conditions") private val conditions: List, + @JsonProperty("conditions") + @ExcludeMissing + private val conditions: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("conditions") fun conditions(): List = conditions + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2435,22 +2975,33 @@ constructor( class Builder { - private var conditions: MutableList? = null + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions.toMutableList() + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } - fun conditions(conditions: List) = apply { - this.conditions = conditions.toMutableList() + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions.map { it.toMutableList() } } fun addCondition(condition: Condition) = apply { - conditions = (conditions ?: mutableListOf()).apply { add(condition) } + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -2478,7 +3029,7 @@ constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( checkNotNull(conditions) { "`conditions` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -2487,9 +3038,15 @@ constructor( class Condition @JsonCreator private constructor( - @JsonProperty("attribute") private val attribute: Attribute?, - @JsonProperty("operation") private val operation: Operation?, - @JsonProperty("value") private val value: Value?, + @JsonProperty("attribute") + @ExcludeMissing + private val attribute: JsonField = JsonMissing.of(), + @JsonProperty("operation") + @ExcludeMissing + private val operation: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -2530,18 +3087,77 @@ constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") fun attribute(): Attribute? = attribute + fun attribute(): Attribute? = attribute.getNullable("attribute") + + /** The operation to apply to the attribute */ + fun operation(): Operation? = operation.getNullable("operation") + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(): Value? = value.getNullable("value") + + /** + * The attribute to target. + * + * The following attributes may be targeted: + * - `MCC`: A four-digit number listed in ISO 18245. An MCC is used to classify + * a business by the types of goods or services it provides. + * - `COUNTRY`: Country of entity of card acceptor. Possible values are: (1) all + * ISO 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and (3) ANT for + * Netherlands Antilles. + * - `CURRENCY`: 3-digit alphabetic ISO 4217 code for the merchant currency of + * the transaction. + * - `MERCHANT_ID`: Unique alphanumeric identifier for the payment card acceptor + * (merchant). + * - `DESCRIPTOR`: Short description of card acceptor. + * - `LIABILITY_SHIFT`: Indicates whether chargeback liability shift to the + * issuer applies to the transaction. Valid values are `NONE`, + * `3DS_AUTHENTICATED`, or `TOKEN_AUTHENTICATED`. + * - `PAN_ENTRY_MODE`: The method by which the cardholder's primary account + * number (PAN) was entered. Valid values are `AUTO_ENTRY`, `BAR_CODE`, + * `CONTACTLESS`, `ECOMMERCE`, `ERROR_KEYED`, `ERROR_MAGNETIC_STRIPE`, `ICC`, + * `KEY_ENTERED`, `MAGNETIC_STRIPE`, `MANUAL`, `OCR`, `SECURE_CARDLESS`, + * `UNSPECIFIED`, `UNKNOWN`, `CREDENTIAL_ON_FILE`, or `ECOMMERCE`. + * - `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the + * acquirer fee field in the settlement/cardholder billing currency. This is + * the amount the issuer should authorize against unless the issuer is paying + * the acquirer fee on behalf of the cardholder. + * - `RISK_SCORE`: Network-provided score assessing risk level associated with a + * given authorization. Scores are on a range of 0-999, with 0 representing + * the lowest risk and 999 representing the highest risk. For Visa + * transactions, where the raw score has a range of 0-99, Lithic will + * normalize the score by multiplying the raw score by 10x. + * - `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in the + * trailing hour up and until the authorization. + * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the + * trailing 24 hours up and until the authorization. + */ + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") fun operation(): Operation? = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") fun value(): Value? = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2551,9 +3167,9 @@ constructor( class Builder { - private var attribute: Attribute? = null - private var operation: Operation? = null - private var value: Value? = null + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2601,24 +3217,71 @@ constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in * the trailing 24 hours up and until the authorization. */ - fun attribute(attribute: Attribute?) = apply { this.attribute = attribute } + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** + * The attribute to target. + * + * The following attributes may be targeted: + * - `MCC`: A four-digit number listed in ISO 18245. An MCC is used to + * classify a business by the types of goods or services it provides. + * - `COUNTRY`: Country of entity of card acceptor. Possible values are: (1) + * all ISO 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and (3) ANT + * for Netherlands Antilles. + * - `CURRENCY`: 3-digit alphabetic ISO 4217 code for the merchant currency + * of the transaction. + * - `MERCHANT_ID`: Unique alphanumeric identifier for the payment card + * acceptor (merchant). + * - `DESCRIPTOR`: Short description of card acceptor. + * - `LIABILITY_SHIFT`: Indicates whether chargeback liability shift to the + * issuer applies to the transaction. Valid values are `NONE`, + * `3DS_AUTHENTICATED`, or `TOKEN_AUTHENTICATED`. + * - `PAN_ENTRY_MODE`: The method by which the cardholder's primary account + * number (PAN) was entered. Valid values are `AUTO_ENTRY`, `BAR_CODE`, + * `CONTACTLESS`, `ECOMMERCE`, `ERROR_KEYED`, `ERROR_MAGNETIC_STRIPE`, + * `ICC`, `KEY_ENTERED`, `MAGNETIC_STRIPE`, `MANUAL`, `OCR`, + * `SECURE_CARDLESS`, `UNSPECIFIED`, `UNKNOWN`, `CREDENTIAL_ON_FILE`, or + * `ECOMMERCE`. + * - `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the + * acquirer fee field in the settlement/cardholder billing currency. This + * is the amount the issuer should authorize against unless the issuer is + * paying the acquirer fee on behalf of the cardholder. + * - `RISK_SCORE`: Network-provided score assessing risk level associated + * with a given authorization. Scores are on a range of 0-999, with 0 + * representing the lowest risk and 999 representing the highest risk. For + * Visa transactions, where the raw score has a range of 0-99, Lithic will + * normalize the score by multiplying the raw score by 10x. + * - `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in + * the trailing hour up and until the authorization. + * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in + * the trailing 24 hours up and until the authorization. + */ + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } /** The operation to apply to the attribute */ - fun operation(operation: Operation?) = apply { this.operation = operation } + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(value: Value) = value(JsonField.of(value)) /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - fun value(value: Value?) = apply { this.value = value } + fun value(value: JsonField) = apply { this.value = value } /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - fun value(string: String) = apply { this.value = Value.ofString(string) } + fun value(string: String) = value(Value.ofString(string)) /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ - fun value(long: Long) = apply { this.value = Value.ofLong(long) } + fun value(long: Long) = value(Value.ofLong(long)) /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ - fun valueOfStrings(strings: List) = apply { - this.value = Value.ofStrings(strings) - } + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) fun additionalProperties(additionalProperties: Map) = apply { @@ -2858,6 +3521,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun string(): String? = string /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ @@ -2889,6 +3554,15 @@ constructor( } } + fun validate(): Value = apply { + if (!validated) { + if (string == null && long == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2DraftParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2DraftParams.kt index b587e91f..c8964d11 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2DraftParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2DraftParams.kt @@ -18,6 +18,7 @@ import com.lithic.api.core.BaseSerializer import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.getOrThrow @@ -47,12 +48,15 @@ constructor( /** Parameters for the current version of the Auth Rule */ fun parameters(): Parameters? = body.parameters() + /** Parameters for the current version of the Auth Rule */ + fun _parameters(): JsonField = body._parameters() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): AuthRuleV2DraftBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -70,18 +74,34 @@ constructor( class AuthRuleV2DraftBody @JsonCreator internal constructor( - @JsonProperty("parameters") private val parameters: Parameters?, + @JsonProperty("parameters") + @ExcludeMissing + private val parameters: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") fun parameters(): Parameters? = parameters + fun parameters(): Parameters? = parameters.getNullable("parameters") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AuthRuleV2DraftBody = apply { + if (!validated) { + parameters() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -91,7 +111,7 @@ constructor( class Builder { - private var parameters: Parameters? = null + private var parameters: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(authRuleV2DraftBody: AuthRuleV2DraftBody) = apply { @@ -100,17 +120,18 @@ constructor( } /** Parameters for the current version of the Auth Rule */ - fun parameters(parameters: Parameters?) = apply { this.parameters = parameters } + fun parameters(parameters: Parameters?) = parameters(JsonField.ofNullable(parameters)) + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = - apply { - this.parameters = - Parameters.ofConditionalBlockParameters(conditionalBlockParameters) - } + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) - fun parameters(velocityLimitParams: VelocityLimitParams) = apply { - this.parameters = Parameters.ofVelocityLimitParams(velocityLimitParams) - } + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -180,6 +201,9 @@ constructor( /** Parameters for the current version of the Auth Rule */ fun parameters(parameters: Parameters?) = apply { body.parameters(parameters) } + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: JsonField) = apply { body.parameters(parameters) } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = apply { body.parameters(conditionalBlockParameters) } @@ -188,6 +212,25 @@ constructor( body.parameters(velocityLimitParams) } + 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) @@ -286,25 +329,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): AuthRuleV2DraftParams = AuthRuleV2DraftParams( checkNotNull(authRuleToken) { "`authRuleToken` is required but was not set" }, @@ -324,6 +348,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun conditionalBlockParameters(): ConditionalBlockParameters? = conditionalBlockParameters fun velocityLimitParams(): VelocityLimitParams? = velocityLimitParams @@ -349,6 +375,17 @@ constructor( } } + fun validate(): Parameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown Parameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -397,12 +434,14 @@ constructor( override fun ObjectCodec.deserialize(node: JsonNode): Parameters { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Parameters(conditionalBlockParameters = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Parameters(velocityLimitParams = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Parameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Parameters(velocityLimitParams = it, _json = json) + } return Parameters(_json = json) } @@ -430,17 +469,32 @@ constructor( class ConditionalBlockParameters @JsonCreator private constructor( - @JsonProperty("conditions") private val conditions: List, + @JsonProperty("conditions") + @ExcludeMissing + private val conditions: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("conditions") fun conditions(): List = conditions + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -450,21 +504,30 @@ constructor( class Builder { - private var conditions: MutableList? = null + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions.toMutableList() + conditions = conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } - fun conditions(conditions: List) = apply { - this.conditions = conditions.toMutableList() + fun conditions(conditions: List) = conditions(JsonField.of(conditions)) + + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions.map { it.toMutableList() } } fun addCondition(condition: Condition) = apply { - conditions = (conditions ?: mutableListOf()).apply { add(condition) } + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -492,7 +555,7 @@ constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( checkNotNull(conditions) { "`conditions` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -501,9 +564,15 @@ constructor( class Condition @JsonCreator private constructor( - @JsonProperty("attribute") private val attribute: Attribute?, - @JsonProperty("operation") private val operation: Operation?, - @JsonProperty("value") private val value: Value?, + @JsonProperty("attribute") + @ExcludeMissing + private val attribute: JsonField = JsonMissing.of(), + @JsonProperty("operation") + @ExcludeMissing + private val operation: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -544,18 +613,77 @@ constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") fun attribute(): Attribute? = attribute + fun attribute(): Attribute? = attribute.getNullable("attribute") + + /** The operation to apply to the attribute */ + fun operation(): Operation? = operation.getNullable("operation") + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(): Value? = value.getNullable("value") + + /** + * The attribute to target. + * + * The following attributes may be targeted: + * - `MCC`: A four-digit number listed in ISO 18245. An MCC is used to classify a + * business by the types of goods or services it provides. + * - `COUNTRY`: Country of entity of card acceptor. Possible values are: (1) all ISO + * 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and (3) ANT for Netherlands + * Antilles. + * - `CURRENCY`: 3-digit alphabetic ISO 4217 code for the merchant currency of the + * transaction. + * - `MERCHANT_ID`: Unique alphanumeric identifier for the payment card acceptor + * (merchant). + * - `DESCRIPTOR`: Short description of card acceptor. + * - `LIABILITY_SHIFT`: Indicates whether chargeback liability shift to the issuer + * applies to the transaction. Valid values are `NONE`, `3DS_AUTHENTICATED`, or + * `TOKEN_AUTHENTICATED`. + * - `PAN_ENTRY_MODE`: The method by which the cardholder's primary account number + * (PAN) was entered. Valid values are `AUTO_ENTRY`, `BAR_CODE`, `CONTACTLESS`, + * `ECOMMERCE`, `ERROR_KEYED`, `ERROR_MAGNETIC_STRIPE`, `ICC`, `KEY_ENTERED`, + * `MAGNETIC_STRIPE`, `MANUAL`, `OCR`, `SECURE_CARDLESS`, `UNSPECIFIED`, + * `UNKNOWN`, `CREDENTIAL_ON_FILE`, or `ECOMMERCE`. + * - `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the acquirer + * fee field in the settlement/cardholder billing currency. This is the amount the + * issuer should authorize against unless the issuer is paying the acquirer fee on + * behalf of the cardholder. + * - `RISK_SCORE`: Network-provided score assessing risk level associated with a + * given authorization. Scores are on a range of 0-999, with 0 representing the + * lowest risk and 999 representing the highest risk. For Visa transactions, where + * the raw score has a range of 0-99, Lithic will normalize the score by + * multiplying the raw score by 10x. + * - `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in the + * trailing hour up and until the authorization. + * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the + * trailing 24 hours up and until the authorization. + */ + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") fun operation(): Operation? = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") fun value(): Value? = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -565,9 +693,9 @@ constructor( class Builder { - private var attribute: Attribute? = null - private var operation: Operation? = null - private var value: Value? = null + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(condition: Condition) = apply { @@ -613,24 +741,70 @@ constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - fun attribute(attribute: Attribute?) = apply { this.attribute = attribute } + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** + * The attribute to target. + * + * The following attributes may be targeted: + * - `MCC`: A four-digit number listed in ISO 18245. An MCC is used to classify + * a business by the types of goods or services it provides. + * - `COUNTRY`: Country of entity of card acceptor. Possible values are: (1) all + * ISO 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and (3) ANT for + * Netherlands Antilles. + * - `CURRENCY`: 3-digit alphabetic ISO 4217 code for the merchant currency of + * the transaction. + * - `MERCHANT_ID`: Unique alphanumeric identifier for the payment card acceptor + * (merchant). + * - `DESCRIPTOR`: Short description of card acceptor. + * - `LIABILITY_SHIFT`: Indicates whether chargeback liability shift to the + * issuer applies to the transaction. Valid values are `NONE`, + * `3DS_AUTHENTICATED`, or `TOKEN_AUTHENTICATED`. + * - `PAN_ENTRY_MODE`: The method by which the cardholder's primary account + * number (PAN) was entered. Valid values are `AUTO_ENTRY`, `BAR_CODE`, + * `CONTACTLESS`, `ECOMMERCE`, `ERROR_KEYED`, `ERROR_MAGNETIC_STRIPE`, `ICC`, + * `KEY_ENTERED`, `MAGNETIC_STRIPE`, `MANUAL`, `OCR`, `SECURE_CARDLESS`, + * `UNSPECIFIED`, `UNKNOWN`, `CREDENTIAL_ON_FILE`, or `ECOMMERCE`. + * - `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the + * acquirer fee field in the settlement/cardholder billing currency. This is + * the amount the issuer should authorize against unless the issuer is paying + * the acquirer fee on behalf of the cardholder. + * - `RISK_SCORE`: Network-provided score assessing risk level associated with a + * given authorization. Scores are on a range of 0-999, with 0 representing + * the lowest risk and 999 representing the highest risk. For Visa + * transactions, where the raw score has a range of 0-99, Lithic will + * normalize the score by multiplying the raw score by 10x. + * - `CARD_TRANSACTION_COUNT_1H`: The number of transactions on the card in the + * trailing hour up and until the authorization. + * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the + * trailing 24 hours up and until the authorization. + */ + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } /** The operation to apply to the attribute */ - fun operation(operation: Operation?) = apply { this.operation = operation } + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + fun operation(operation: JsonField) = apply { + this.operation = operation + } /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - fun value(value: Value?) = apply { this.value = value } + fun value(value: Value) = value(JsonField.of(value)) /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - fun value(string: String) = apply { this.value = Value.ofString(string) } + fun value(value: JsonField) = apply { this.value = value } + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ - fun value(long: Long) = apply { this.value = Value.ofLong(long) } + fun value(long: Long) = value(Value.ofLong(long)) /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ - fun valueOfStrings(strings: List) = apply { - this.value = Value.ofStrings(strings) - } + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -868,6 +1042,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun string(): String? = string /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ @@ -899,6 +1075,15 @@ constructor( } } + fun validate(): Value = apply { + if (!validated) { + if (string == null && long == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2UpdateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2UpdateParams.kt index 1233e362..f1bd1bdb 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2UpdateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2UpdateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -41,12 +42,24 @@ constructor( */ fun state(): State? = body.state() - fun _additionalHeaders(): Headers = additionalHeaders + /** Auth Rule Name */ + fun _name(): JsonField = body._name() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * The desired state of the Auth Rule. + * + * Note that only deactivating an Auth Rule through this endpoint is supported at this time. If + * you need to (re-)activate an Auth Rule the /promote endpoint should be used to promote a + * draft to the currently active version. + */ + fun _state(): JsonField = body._state() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): AuthRuleV2UpdateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -64,14 +77,30 @@ constructor( class AuthRuleV2UpdateBody @JsonCreator internal constructor( - @JsonProperty("name") private val name: String?, - @JsonProperty("state") private val state: State?, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("state") + @ExcludeMissing + private val state: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Auth Rule Name */ - @JsonProperty("name") fun name(): String? = name + fun name(): String? = name.getNullable("name") + + /** + * The desired state of the Auth Rule. + * + * Note that only deactivating an Auth Rule through this endpoint is supported at this time. + * If you need to (re-)activate an Auth Rule the /promote endpoint should be used to promote + * a draft to the currently active version. + */ + fun state(): State? = state.getNullable("state") + + /** Auth Rule Name */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The desired state of the Auth Rule. @@ -80,12 +109,22 @@ constructor( * If you need to (re-)activate an Auth Rule the /promote endpoint should be used to promote * a draft to the currently active version. */ - @JsonProperty("state") fun state(): State? = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AuthRuleV2UpdateBody = apply { + if (!validated) { + name() + state() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -95,8 +134,8 @@ constructor( class Builder { - private var name: String? = null - private var state: State? = null + private var name: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(authRuleV2UpdateBody: AuthRuleV2UpdateBody) = apply { @@ -106,7 +145,19 @@ constructor( } /** Auth Rule Name */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Auth Rule Name */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The desired state of the Auth Rule. + * + * Note that only deactivating an Auth Rule through this endpoint is supported at this + * time. If you need to (re-)activate an Auth Rule the /promote endpoint should be used + * to promote a draft to the currently active version. + */ + fun state(state: State) = state(JsonField.of(state)) /** * The desired state of the Auth Rule. @@ -115,7 +166,7 @@ constructor( * time. If you need to (re-)activate an Auth Rule the /promote endpoint should be used * to promote a draft to the currently active version. */ - fun state(state: State?) = apply { this.state = state } + fun state(state: JsonField) = apply { this.state = state } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -189,6 +240,18 @@ constructor( /** Auth Rule Name */ fun name(name: String?) = apply { body.name(name) } + /** Auth Rule Name */ + fun name(name: JsonField) = apply { body.name(name) } + + /** + * The desired state of the Auth Rule. + * + * Note that only deactivating an Auth Rule through this endpoint is supported at this time. + * If you need to (re-)activate an Auth Rule the /promote endpoint should be used to promote + * a draft to the currently active version. + */ + fun state(state: State) = apply { body.state(state) } + /** * The desired state of the Auth Rule. * @@ -196,7 +259,26 @@ constructor( * If you need to (re-)activate an Auth Rule the /promote endpoint should be used to promote * a draft to the currently active version. */ - fun state(state: State?) = apply { body.state(state) } + fun state(state: JsonField) = apply { body.state(state) } + + 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() @@ -296,25 +378,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): AuthRuleV2UpdateParams = AuthRuleV2UpdateParams( checkNotNull(authRuleToken) { "`authRuleToken` is required but was not set" }, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthStreamSecret.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthStreamSecret.kt index 79607bb4..9d3a3139 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthStreamSecret.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthStreamSecret.kt @@ -29,7 +29,7 @@ private constructor( fun secret(): String? = secret.getNullable("secret") /** The shared HMAC ASA secret */ - @JsonProperty("secret") @ExcludeMissing fun _secret() = secret + @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthenticationRetrieveResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthenticationRetrieveResponse.kt index 305aeb7b..bb9668b5 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthenticationRetrieveResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthenticationRetrieveResponse.kt @@ -158,61 +158,73 @@ private constructor( fun transaction(): Transaction? = transaction.getNullable("transaction") /** Globally unique identifier for the 3DS authentication. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * Type of account/card that is being used for the transaction. Maps to EMV 3DS field * `acctType`. */ - @JsonProperty("account_type") @ExcludeMissing fun _accountType() = accountType + @JsonProperty("account_type") + @ExcludeMissing + fun _accountType(): JsonField = accountType /** Indicates the outcome of the 3DS authentication process. */ @JsonProperty("authentication_result") @ExcludeMissing - fun _authenticationResult() = authenticationResult + fun _authenticationResult(): JsonField = authenticationResult /** * Indicates whether the expiration date provided by the cardholder during checkout matches * Lithic's record of the card's expiration date. */ - @JsonProperty("card_expiry_check") @ExcludeMissing fun _cardExpiryCheck() = cardExpiryCheck + @JsonProperty("card_expiry_check") + @ExcludeMissing + fun _cardExpiryCheck(): JsonField = cardExpiryCheck /** Globally unique identifier for the card on which the 3DS authentication has occurred. */ - @JsonProperty("card_token") @ExcludeMissing fun _cardToken() = cardToken + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken /** Object containing data about the cardholder provided during the transaction. */ - @JsonProperty("cardholder") @ExcludeMissing fun _cardholder() = cardholder + @JsonProperty("cardholder") + @ExcludeMissing + fun _cardholder(): JsonField = cardholder /** Channel in which the authentication occurs. Maps to EMV 3DS field deviceChannel. */ - @JsonProperty("channel") @ExcludeMissing fun _channel() = channel + @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel /** Date and time when the authentication was created in Lithic's system. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Entity that made the authentication decision. */ - @JsonProperty("decision_made_by") @ExcludeMissing fun _decisionMadeBy() = decisionMadeBy + @JsonProperty("decision_made_by") + @ExcludeMissing + fun _decisionMadeBy(): JsonField = decisionMadeBy /** Object containing data about the merchant involved in the e-commerce transaction. */ - @JsonProperty("merchant") @ExcludeMissing fun _merchant() = merchant + @JsonProperty("merchant") @ExcludeMissing fun _merchant(): JsonField = merchant /** * Either PAYMENT_AUTHENTICATION or NON_PAYMENT_AUTHENTICATION. For NON_PAYMENT_AUTHENTICATION, * additional_data and transaction fields are not populated. */ - @JsonProperty("message_category") @ExcludeMissing fun _messageCategory() = messageCategory + @JsonProperty("message_category") + @ExcludeMissing + fun _messageCategory(): JsonField = messageCategory /** * Object containing additional data about the 3DS request that is beyond the EMV 3DS standard * spec (e.g., specific fields that only certain card networks send but are not required across * all 3DS requests). */ - @JsonProperty("additional_data") @ExcludeMissing fun _additionalData() = additionalData + @JsonProperty("additional_data") + @ExcludeMissing + fun _additionalData(): JsonField = additionalData /** * Object containing data about the app used in the e-commerce transaction. Present if the * channel is 'APP_BASED'. */ - @JsonProperty("app") @ExcludeMissing fun _app() = app + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app /** * Type of authentication request - i.e., the type of transaction or interaction is causing the @@ -221,13 +233,14 @@ private constructor( */ @JsonProperty("authentication_request_type") @ExcludeMissing - fun _authenticationRequestType() = authenticationRequestType + fun _authenticationRequestType(): JsonField = + authenticationRequestType /** * Object containing data about the browser used in the e-commerce transaction. Present if the * channel is 'BROWSER'. */ - @JsonProperty("browser") @ExcludeMissing fun _browser() = browser + @JsonProperty("browser") @ExcludeMissing fun _browser(): JsonField = browser /** * Type of 3DS Requestor Initiated (3RI) request i.e., a 3DS authentication that takes place at @@ -237,13 +250,15 @@ private constructor( */ @JsonProperty("three_ri_request_type") @ExcludeMissing - fun _threeRiRequestType() = threeRiRequestType + fun _threeRiRequestType(): JsonField = threeRiRequestType /** * Object containing data about the e-commerce transaction for which the merchant is requesting * authentication. */ - @JsonProperty("transaction") @ExcludeMissing fun _transaction() = transaction + @JsonProperty("transaction") + @ExcludeMissing + fun _transaction(): JsonField = transaction @JsonAnyGetter @ExcludeMissing @@ -283,17 +298,17 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountType: JsonField = JsonMissing.of() - private var authenticationResult: JsonField = JsonMissing.of() - private var cardExpiryCheck: JsonField = JsonMissing.of() - private var cardToken: JsonField = JsonMissing.of() - private var cardholder: JsonField = JsonMissing.of() - private var channel: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var decisionMadeBy: JsonField = JsonMissing.of() - private var merchant: JsonField = JsonMissing.of() - private var messageCategory: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var accountType: JsonField? = null + private var authenticationResult: JsonField? = null + private var cardExpiryCheck: JsonField? = null + private var cardToken: JsonField? = null + private var cardholder: JsonField? = null + private var channel: JsonField? = null + private var created: JsonField? = null + private var decisionMadeBy: JsonField? = null + private var merchant: JsonField? = null + private var messageCategory: JsonField? = null private var additionalData: JsonField = JsonMissing.of() private var app: JsonField = JsonMissing.of() private var authenticationRequestType: JsonField = @@ -335,7 +350,7 @@ private constructor( * Type of account/card that is being used for the transaction. Maps to EMV 3DS field * `acctType`. */ - fun accountType(accountType: AccountType) = accountType(JsonField.of(accountType)) + fun accountType(accountType: AccountType?) = accountType(JsonField.ofNullable(accountType)) /** * Type of account/card that is being used for the transaction. Maps to EMV 3DS field @@ -346,8 +361,8 @@ private constructor( } /** Indicates the outcome of the 3DS authentication process. */ - fun authenticationResult(authenticationResult: AuthenticationResult) = - authenticationResult(JsonField.of(authenticationResult)) + fun authenticationResult(authenticationResult: AuthenticationResult?) = + authenticationResult(JsonField.ofNullable(authenticationResult)) /** Indicates the outcome of the 3DS authentication process. */ fun authenticationResult(authenticationResult: JsonField) = apply { @@ -394,8 +409,8 @@ private constructor( fun created(created: JsonField) = apply { this.created = created } /** Entity that made the authentication decision. */ - fun decisionMadeBy(decisionMadeBy: DecisionMadeBy) = - decisionMadeBy(JsonField.of(decisionMadeBy)) + fun decisionMadeBy(decisionMadeBy: DecisionMadeBy?) = + decisionMadeBy(JsonField.ofNullable(decisionMadeBy)) /** Entity that made the authentication decision. */ fun decisionMadeBy(decisionMadeBy: JsonField) = apply { @@ -428,8 +443,8 @@ private constructor( * standard spec (e.g., specific fields that only certain card networks send but are not * required across all 3DS requests). */ - fun additionalData(additionalData: AdditionalData) = - additionalData(JsonField.of(additionalData)) + fun additionalData(additionalData: AdditionalData?) = + additionalData(JsonField.ofNullable(additionalData)) /** * Object containing additional data about the 3DS request that is beyond the EMV 3DS @@ -457,8 +472,8 @@ private constructor( * the merchant to request an authentication. Maps to EMV 3DS field * threeDSRequestorAuthenticationInd. */ - fun authenticationRequestType(authenticationRequestType: AuthenticationRequestType) = - authenticationRequestType(JsonField.of(authenticationRequestType)) + fun authenticationRequestType(authenticationRequestType: AuthenticationRequestType?) = + authenticationRequestType(JsonField.ofNullable(authenticationRequestType)) /** * Type of authentication request - i.e., the type of transaction or interaction is causing @@ -487,8 +502,8 @@ private constructor( * this is where a merchant is authenticating before billing for a recurring transaction * such as a pay TV subscription or a utility bill. Maps to EMV 3DS field threeRIInd. */ - fun threeRiRequestType(threeRiRequestType: ThreeRiRequestType) = - threeRiRequestType(JsonField.of(threeRiRequestType)) + fun threeRiRequestType(threeRiRequestType: ThreeRiRequestType?) = + threeRiRequestType(JsonField.ofNullable(threeRiRequestType)) /** * Type of 3DS Requestor Initiated (3RI) request i.e., a 3DS authentication that takes place @@ -504,7 +519,7 @@ private constructor( * Object containing data about the e-commerce transaction for which the merchant is * requesting authentication. */ - fun transaction(transaction: Transaction) = transaction(JsonField.of(transaction)) + fun transaction(transaction: Transaction?) = transaction(JsonField.ofNullable(transaction)) /** * Object containing data about the e-commerce transaction for which the merchant is @@ -535,17 +550,19 @@ private constructor( fun build(): AuthenticationRetrieveResponse = AuthenticationRetrieveResponse( - token, - accountType, - authenticationResult, - cardExpiryCheck, - cardToken, - cardholder, - channel, - created, - decisionMadeBy, - merchant, - messageCategory, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountType) { "`accountType` is required but was not set" }, + checkNotNull(authenticationResult) { + "`authenticationResult` is required but was not set" + }, + checkNotNull(cardExpiryCheck) { "`cardExpiryCheck` is required but was not set" }, + checkNotNull(cardToken) { "`cardToken` is required but was not set" }, + checkNotNull(cardholder) { "`cardholder` is required but was not set" }, + checkNotNull(channel) { "`channel` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(decisionMadeBy) { "`decisionMadeBy` is required but was not set" }, + checkNotNull(merchant) { "`merchant` is required but was not set" }, + checkNotNull(messageCategory) { "`messageCategory` is required but was not set" }, additionalData, app, authenticationRequestType, @@ -819,25 +836,31 @@ private constructor( * directly in the 3DS request and is not determined by Lithic. Maps to EMV 3DS field * addrMatch. */ - @JsonProperty("address_match") @ExcludeMissing fun _addressMatch() = addressMatch + @JsonProperty("address_match") + @ExcludeMissing + fun _addressMatch(): JsonField = addressMatch /** Object containing data on the billing address provided during the transaction. */ - @JsonProperty("billing_address") @ExcludeMissing fun _billingAddress() = billingAddress + @JsonProperty("billing_address") + @ExcludeMissing + fun _billingAddress(): JsonField = billingAddress /** * Email address that is either provided by the cardholder or is on file with the merchant * in a 3RI request. Maps to EMV 3DS field email. */ - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email /** Name of the cardholder. Maps to EMV 3DS field cardholderName. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Home phone number provided by the cardholder. Maps to EMV 3DS fields homePhone.cc and * homePhone.subscriber. */ - @JsonProperty("phone_number_home") @ExcludeMissing fun _phoneNumberHome() = phoneNumberHome + @JsonProperty("phone_number_home") + @ExcludeMissing + fun _phoneNumberHome(): JsonField = phoneNumberHome /** * Mobile/cell phone number provided by the cardholder. Maps to EMV 3DS fields @@ -845,16 +868,20 @@ private constructor( */ @JsonProperty("phone_number_mobile") @ExcludeMissing - fun _phoneNumberMobile() = phoneNumberMobile + fun _phoneNumberMobile(): JsonField = phoneNumberMobile /** * Work phone number provided by the cardholder. Maps to EMV 3DS fields workPhone.cc and * workPhone.subscriber. */ - @JsonProperty("phone_number_work") @ExcludeMissing fun _phoneNumberWork() = phoneNumberWork + @JsonProperty("phone_number_work") + @ExcludeMissing + fun _phoneNumberWork(): JsonField = phoneNumberWork /** Object containing data on the shipping address provided during the transaction. */ - @JsonProperty("shipping_address") @ExcludeMissing fun _shippingAddress() = shippingAddress + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress @JsonAnyGetter @ExcludeMissing @@ -913,7 +940,16 @@ private constructor( * provided directly in the 3DS request and is not determined by Lithic. Maps to EMV 3DS * field addrMatch. */ - fun addressMatch(addressMatch: Boolean) = addressMatch(JsonField.of(addressMatch)) + fun addressMatch(addressMatch: Boolean?) = + addressMatch(JsonField.ofNullable(addressMatch)) + + /** + * Indicates whether the shipping address and billing address provided by the cardholder + * are the same. This value - and assessment of whether the addresses match - is + * provided directly in the 3DS request and is not determined by Lithic. Maps to EMV 3DS + * field addrMatch. + */ + fun addressMatch(addressMatch: Boolean) = addressMatch(addressMatch as Boolean?) /** * Indicates whether the shipping address and billing address provided by the cardholder @@ -938,7 +974,7 @@ private constructor( * Email address that is either provided by the cardholder or is on file with the * merchant in a 3RI request. Maps to EMV 3DS field email. */ - fun email(email: String) = email(JsonField.of(email)) + fun email(email: String?) = email(JsonField.ofNullable(email)) /** * Email address that is either provided by the cardholder or is on file with the @@ -947,7 +983,7 @@ private constructor( fun email(email: JsonField) = apply { this.email = email } /** Name of the cardholder. Maps to EMV 3DS field cardholderName. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) /** Name of the cardholder. Maps to EMV 3DS field cardholderName. */ fun name(name: JsonField) = apply { this.name = name } @@ -956,8 +992,8 @@ private constructor( * Home phone number provided by the cardholder. Maps to EMV 3DS fields homePhone.cc and * homePhone.subscriber. */ - fun phoneNumberHome(phoneNumberHome: String) = - phoneNumberHome(JsonField.of(phoneNumberHome)) + fun phoneNumberHome(phoneNumberHome: String?) = + phoneNumberHome(JsonField.ofNullable(phoneNumberHome)) /** * Home phone number provided by the cardholder. Maps to EMV 3DS fields homePhone.cc and @@ -971,8 +1007,8 @@ private constructor( * Mobile/cell phone number provided by the cardholder. Maps to EMV 3DS fields * mobilePhone.cc and mobilePhone.subscriber. */ - fun phoneNumberMobile(phoneNumberMobile: String) = - phoneNumberMobile(JsonField.of(phoneNumberMobile)) + fun phoneNumberMobile(phoneNumberMobile: String?) = + phoneNumberMobile(JsonField.ofNullable(phoneNumberMobile)) /** * Mobile/cell phone number provided by the cardholder. Maps to EMV 3DS fields @@ -986,8 +1022,8 @@ private constructor( * Work phone number provided by the cardholder. Maps to EMV 3DS fields workPhone.cc and * workPhone.subscriber. */ - fun phoneNumberWork(phoneNumberWork: String) = - phoneNumberWork(JsonField.of(phoneNumberWork)) + fun phoneNumberWork(phoneNumberWork: String?) = + phoneNumberWork(JsonField.ofNullable(phoneNumberWork)) /** * Work phone number provided by the cardholder. Maps to EMV 3DS fields workPhone.cc and @@ -1088,25 +1124,27 @@ private constructor( fun postalCode(): String? = postalCode.getNullable("postal_code") /** First line of the street address provided by the cardholder. */ - @JsonProperty("address1") @ExcludeMissing fun _address1() = address1 + @JsonProperty("address1") @ExcludeMissing fun _address1(): JsonField = address1 /** Second line of the street address provided by the cardholder. */ - @JsonProperty("address2") @ExcludeMissing fun _address2() = address2 + @JsonProperty("address2") @ExcludeMissing fun _address2(): JsonField = address2 /** Third line of the street address provided by the cardholder. */ - @JsonProperty("address3") @ExcludeMissing fun _address3() = address3 + @JsonProperty("address3") @ExcludeMissing fun _address3(): JsonField = address3 /** City of the address provided by the cardholder. */ - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city /** * Country of the address provided by the cardholder in ISO 3166-1 alpha-3 format (e.g. * USA) */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** Postal code (e.g., ZIP code) of the address provided by the cardholder */ - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode @JsonAnyGetter @ExcludeMissing @@ -1154,25 +1192,25 @@ private constructor( } /** First line of the street address provided by the cardholder. */ - fun address1(address1: String) = address1(JsonField.of(address1)) + fun address1(address1: String?) = address1(JsonField.ofNullable(address1)) /** First line of the street address provided by the cardholder. */ fun address1(address1: JsonField) = apply { this.address1 = address1 } /** Second line of the street address provided by the cardholder. */ - fun address2(address2: String) = address2(JsonField.of(address2)) + fun address2(address2: String?) = address2(JsonField.ofNullable(address2)) /** Second line of the street address provided by the cardholder. */ fun address2(address2: JsonField) = apply { this.address2 = address2 } /** Third line of the street address provided by the cardholder. */ - fun address3(address3: String) = address3(JsonField.of(address3)) + fun address3(address3: String?) = address3(JsonField.ofNullable(address3)) /** Third line of the street address provided by the cardholder. */ fun address3(address3: JsonField) = apply { this.address3 = address3 } /** City of the address provided by the cardholder. */ - fun city(city: String) = city(JsonField.of(city)) + fun city(city: String?) = city(JsonField.ofNullable(city)) /** City of the address provided by the cardholder. */ fun city(city: JsonField) = apply { this.city = city } @@ -1181,7 +1219,7 @@ private constructor( * Country of the address provided by the cardholder in ISO 3166-1 alpha-3 format * (e.g. USA) */ - fun country(country: String) = country(JsonField.of(country)) + fun country(country: String?) = country(JsonField.ofNullable(country)) /** * Country of the address provided by the cardholder in ISO 3166-1 alpha-3 format @@ -1190,7 +1228,7 @@ private constructor( fun country(country: JsonField) = apply { this.country = country } /** Postal code (e.g., ZIP code) of the address provided by the cardholder */ - fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) /** Postal code (e.g., ZIP code) of the address provided by the cardholder */ fun postalCode(postalCode: JsonField) = apply { @@ -1456,28 +1494,30 @@ private constructor( * Merchant identifier as assigned by the acquirer. Maps to EMV 3DS field * acquirerMerchantId. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Country code of the merchant requesting 3DS authentication. Maps to EMV 3DS field * merchantCountryCode. */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** * Merchant category code assigned to the merchant that describes its business activity * type. Maps to EMV 3DS field mcc. */ - @JsonProperty("mcc") @ExcludeMissing fun _mcc() = mcc + @JsonProperty("mcc") @ExcludeMissing fun _mcc(): JsonField = mcc /** Name of the merchant. Maps to EMV 3DS field merchantName. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Object containing additional data indicating additional risk factors related to the * e-commerce transaction. */ - @JsonProperty("risk_indicator") @ExcludeMissing fun _riskIndicator() = riskIndicator + @JsonProperty("risk_indicator") + @ExcludeMissing + fun _riskIndicator(): JsonField = riskIndicator @JsonAnyGetter @ExcludeMissing @@ -1505,11 +1545,11 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var mcc: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var riskIndicator: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var country: JsonField? = null + private var mcc: JsonField? = null + private var name: JsonField? = null + private var riskIndicator: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(merchant: Merchant) = apply { @@ -1599,11 +1639,11 @@ private constructor( fun build(): Merchant = Merchant( - id, - country, - mcc, - name, - riskIndicator, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(mcc) { "`mcc` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(riskIndicator) { "`riskIndicator` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1712,26 +1752,30 @@ private constructor( */ @JsonProperty("delivery_email_address") @ExcludeMissing - fun _deliveryEmailAddress() = deliveryEmailAddress + fun _deliveryEmailAddress(): JsonField = deliveryEmailAddress /** * The delivery time frame for the merchandise. Maps to EMV 3DS field deliveryTimeframe. */ @JsonProperty("delivery_time_frame") @ExcludeMissing - fun _deliveryTimeFrame() = deliveryTimeFrame + fun _deliveryTimeFrame(): JsonField = deliveryTimeFrame /** * In prepaid or gift card purchase transactions, purchase amount total in major units * (e.g., a purchase of USD $205.10 would be 205). Maps to EMV 3DS field giftCardAmount. */ - @JsonProperty("gift_card_amount") @ExcludeMissing fun _giftCardAmount() = giftCardAmount + @JsonProperty("gift_card_amount") + @ExcludeMissing + fun _giftCardAmount(): JsonField = giftCardAmount /** * In prepaid or gift card purchase transactions, count of individual prepaid or gift * cards/codes purchased. Maps to EMV 3DS field giftCardCount. */ - @JsonProperty("gift_card_count") @ExcludeMissing fun _giftCardCount() = giftCardCount + @JsonProperty("gift_card_count") + @ExcludeMissing + fun _giftCardCount(): JsonField = giftCardCount /** * In prepaid or gift card purchase transactions, currency code of the gift card. Maps @@ -1739,7 +1783,7 @@ private constructor( */ @JsonProperty("gift_card_currency") @ExcludeMissing - fun _giftCardCurrency() = giftCardCurrency + fun _giftCardCurrency(): JsonField = giftCardCurrency /** * Indicates whether the purchase is for merchandise that is available now or at a @@ -1747,7 +1791,7 @@ private constructor( */ @JsonProperty("order_availability") @ExcludeMissing - fun _orderAvailability() = orderAvailability + fun _orderAvailability(): JsonField = orderAvailability /** * In pre-order purchase transactions, the expected date that the merchandise will be @@ -1755,13 +1799,15 @@ private constructor( */ @JsonProperty("pre_order_available_date") @ExcludeMissing - fun _preOrderAvailableDate() = preOrderAvailableDate + fun _preOrderAvailableDate(): JsonField = preOrderAvailableDate /** * Indicates whether the cardholder is reordering previously purchased merchandise. Maps * to EMV 3DS field reorderItemsInd. */ - @JsonProperty("reorder_items") @ExcludeMissing fun _reorderItems() = reorderItems + @JsonProperty("reorder_items") + @ExcludeMissing + fun _reorderItems(): JsonField = reorderItems /** * Shipping method that the cardholder chose for the transaction. If purchase includes @@ -1769,7 +1815,9 @@ private constructor( * includes digital goods, this indicator is used to describe the most expensive item * purchased. Maps to EMV 3DS field shipIndicator. */ - @JsonProperty("shipping_method") @ExcludeMissing fun _shippingMethod() = shippingMethod + @JsonProperty("shipping_method") + @ExcludeMissing + fun _shippingMethod(): JsonField = shippingMethod @JsonAnyGetter @ExcludeMissing @@ -1829,8 +1877,8 @@ private constructor( * In transactions with electronic delivery, email address to which merchandise is * delivered. Maps to EMV 3DS field deliveryEmailAddress. */ - fun deliveryEmailAddress(deliveryEmailAddress: String) = - deliveryEmailAddress(JsonField.of(deliveryEmailAddress)) + fun deliveryEmailAddress(deliveryEmailAddress: String?) = + deliveryEmailAddress(JsonField.ofNullable(deliveryEmailAddress)) /** * In transactions with electronic delivery, email address to which merchandise is @@ -1844,8 +1892,8 @@ private constructor( * The delivery time frame for the merchandise. Maps to EMV 3DS field * deliveryTimeframe. */ - fun deliveryTimeFrame(deliveryTimeFrame: DeliveryTimeFrame) = - deliveryTimeFrame(JsonField.of(deliveryTimeFrame)) + fun deliveryTimeFrame(deliveryTimeFrame: DeliveryTimeFrame?) = + deliveryTimeFrame(JsonField.ofNullable(deliveryTimeFrame)) /** * The delivery time frame for the merchandise. Maps to EMV 3DS field @@ -1860,8 +1908,15 @@ private constructor( * units (e.g., a purchase of USD $205.10 would be 205). Maps to EMV 3DS field * giftCardAmount. */ - fun giftCardAmount(giftCardAmount: Long) = - giftCardAmount(JsonField.of(giftCardAmount)) + fun giftCardAmount(giftCardAmount: Long?) = + giftCardAmount(JsonField.ofNullable(giftCardAmount)) + + /** + * In prepaid or gift card purchase transactions, purchase amount total in major + * units (e.g., a purchase of USD $205.10 would be 205). Maps to EMV 3DS field + * giftCardAmount. + */ + fun giftCardAmount(giftCardAmount: Long) = giftCardAmount(giftCardAmount as Long?) /** * In prepaid or gift card purchase transactions, purchase amount total in major @@ -1876,7 +1931,14 @@ private constructor( * In prepaid or gift card purchase transactions, count of individual prepaid or * gift cards/codes purchased. Maps to EMV 3DS field giftCardCount. */ - fun giftCardCount(giftCardCount: Long) = giftCardCount(JsonField.of(giftCardCount)) + fun giftCardCount(giftCardCount: Long?) = + giftCardCount(JsonField.ofNullable(giftCardCount)) + + /** + * In prepaid or gift card purchase transactions, count of individual prepaid or + * gift cards/codes purchased. Maps to EMV 3DS field giftCardCount. + */ + fun giftCardCount(giftCardCount: Long) = giftCardCount(giftCardCount as Long?) /** * In prepaid or gift card purchase transactions, count of individual prepaid or @@ -1890,8 +1952,8 @@ private constructor( * In prepaid or gift card purchase transactions, currency code of the gift card. * Maps to EMV 3DS field giftCardCurr. */ - fun giftCardCurrency(giftCardCurrency: String) = - giftCardCurrency(JsonField.of(giftCardCurrency)) + fun giftCardCurrency(giftCardCurrency: String?) = + giftCardCurrency(JsonField.ofNullable(giftCardCurrency)) /** * In prepaid or gift card purchase transactions, currency code of the gift card. @@ -1905,8 +1967,8 @@ private constructor( * Indicates whether the purchase is for merchandise that is available now or at a * future date. Maps to EMV 3DS field preOrderPurchaseInd. */ - fun orderAvailability(orderAvailability: OrderAvailability) = - orderAvailability(JsonField.of(orderAvailability)) + fun orderAvailability(orderAvailability: OrderAvailability?) = + orderAvailability(JsonField.ofNullable(orderAvailability)) /** * Indicates whether the purchase is for merchandise that is available now or at a @@ -1920,8 +1982,8 @@ private constructor( * In pre-order purchase transactions, the expected date that the merchandise will * be available. Maps to EMV 3DS field preOrderDate. */ - fun preOrderAvailableDate(preOrderAvailableDate: OffsetDateTime) = - preOrderAvailableDate(JsonField.of(preOrderAvailableDate)) + fun preOrderAvailableDate(preOrderAvailableDate: OffsetDateTime?) = + preOrderAvailableDate(JsonField.ofNullable(preOrderAvailableDate)) /** * In pre-order purchase transactions, the expected date that the merchandise will @@ -1936,8 +1998,8 @@ private constructor( * Indicates whether the cardholder is reordering previously purchased merchandise. * Maps to EMV 3DS field reorderItemsInd. */ - fun reorderItems(reorderItems: ReorderItems) = - reorderItems(JsonField.of(reorderItems)) + fun reorderItems(reorderItems: ReorderItems?) = + reorderItems(JsonField.ofNullable(reorderItems)) /** * Indicates whether the cardholder is reordering previously purchased merchandise. @@ -1953,8 +2015,8 @@ private constructor( * purchase only includes digital goods, this indicator is used to describe the most * expensive item purchased. Maps to EMV 3DS field shipIndicator. */ - fun shippingMethod(shippingMethod: ShippingMethod) = - shippingMethod(JsonField.of(shippingMethod)) + fun shippingMethod(shippingMethod: ShippingMethod?) = + shippingMethod(JsonField.ofNullable(shippingMethod)) /** * Shipping method that the cardholder chose for the transaction. If purchase @@ -2415,7 +2477,9 @@ private constructor( * Mastercard only: Indicates whether the network would have considered the authentication * request to be low risk or not. */ - @JsonProperty("network_decision") @ExcludeMissing fun _networkDecision() = networkDecision + @JsonProperty("network_decision") + @ExcludeMissing + fun _networkDecision(): JsonField = networkDecision /** * Mastercard only: Assessment by the network of the authentication risk level, with a @@ -2423,7 +2487,7 @@ private constructor( */ @JsonProperty("network_risk_score") @ExcludeMissing - fun _networkRiskScore() = networkRiskScore + fun _networkRiskScore(): JsonField = networkRiskScore @JsonAnyGetter @ExcludeMissing @@ -2462,8 +2526,8 @@ private constructor( * Mastercard only: Indicates whether the network would have considered the * authentication request to be low risk or not. */ - fun networkDecision(networkDecision: NetworkDecision) = - networkDecision(JsonField.of(networkDecision)) + fun networkDecision(networkDecision: NetworkDecision?) = + networkDecision(JsonField.ofNullable(networkDecision)) /** * Mastercard only: Indicates whether the network would have considered the @@ -2473,12 +2537,19 @@ private constructor( this.networkDecision = networkDecision } + /** + * Mastercard only: Assessment by the network of the authentication risk level, with a + * higher value indicating a higher amount of risk. + */ + fun networkRiskScore(networkRiskScore: Long?) = + networkRiskScore(JsonField.ofNullable(networkRiskScore)) + /** * Mastercard only: Assessment by the network of the authentication risk level, with a * higher value indicating a higher amount of risk. */ fun networkRiskScore(networkRiskScore: Long) = - networkRiskScore(JsonField.of(networkRiskScore)) + networkRiskScore(networkRiskScore as Long?) /** * Mastercard only: Assessment by the network of the authentication risk level, with a @@ -2622,13 +2693,15 @@ private constructor( * Device information gathered from the cardholder's device - JSON name/value pairs that is * Base64url encoded. Maps to EMV 3DS field deviceInfo. */ - @JsonProperty("device_info") @ExcludeMissing fun _deviceInfo() = deviceInfo + @JsonProperty("device_info") + @ExcludeMissing + fun _deviceInfo(): JsonField = deviceInfo /** * External IP address used by the app generating the 3DS authentication request. Maps to * EMV 3DS field appIp. */ - @JsonProperty("ip") @ExcludeMissing fun _ip() = ip + @JsonProperty("ip") @ExcludeMissing fun _ip(): JsonField = ip @JsonAnyGetter @ExcludeMissing @@ -2667,7 +2740,7 @@ private constructor( * Device information gathered from the cardholder's device - JSON name/value pairs that * is Base64url encoded. Maps to EMV 3DS field deviceInfo. */ - fun deviceInfo(deviceInfo: String) = deviceInfo(JsonField.of(deviceInfo)) + fun deviceInfo(deviceInfo: String?) = deviceInfo(JsonField.ofNullable(deviceInfo)) /** * Device information gathered from the cardholder's device - JSON name/value pairs that @@ -2904,13 +2977,15 @@ private constructor( * IP address of the browser as returned by the HTTP headers to the 3DS requestor (e.g., * merchant or digital wallet). Maps to EMV 3DS field browserIP. */ - @JsonProperty("ip") @ExcludeMissing fun _ip() = ip + @JsonProperty("ip") @ExcludeMissing fun _ip(): JsonField = ip /** * Indicates whether the cardholder's browser has the ability to execute Java. Maps to EMV * 3DS field browserJavaEnabled. */ - @JsonProperty("java_enabled") @ExcludeMissing fun _javaEnabled() = javaEnabled + @JsonProperty("java_enabled") + @ExcludeMissing + fun _javaEnabled(): JsonField = javaEnabled /** * Indicates whether the cardholder's browser has the ability to execute JavaScript. Maps to @@ -2918,23 +2993,23 @@ private constructor( */ @JsonProperty("javascript_enabled") @ExcludeMissing - fun _javascriptEnabled() = javascriptEnabled + fun _javascriptEnabled(): JsonField = javascriptEnabled /** * Language of the cardholder's browser as defined in IETF BCP47. Maps to EMV 3DS field * browserLanguage. */ - @JsonProperty("language") @ExcludeMissing fun _language() = language + @JsonProperty("language") @ExcludeMissing fun _language(): JsonField = language /** * Time zone of the cardholder's browser offset in minutes between UTC and the cardholder * browser's local time. The offset is positive if the local time is behind UTC and negative * if it is ahead. Maps to EMV 3DS field browserTz. */ - @JsonProperty("time_zone") @ExcludeMissing fun _timeZone() = timeZone + @JsonProperty("time_zone") @ExcludeMissing fun _timeZone(): JsonField = timeZone /** Content of the HTTP user-agent header. Maps to EMV 3DS field browserUserAgent. */ - @JsonProperty("user_agent") @ExcludeMissing fun _userAgent() = userAgent + @JsonProperty("user_agent") @ExcludeMissing fun _userAgent(): JsonField = userAgent @JsonAnyGetter @ExcludeMissing @@ -2985,7 +3060,7 @@ private constructor( * IP address of the browser as returned by the HTTP headers to the 3DS requestor (e.g., * merchant or digital wallet). Maps to EMV 3DS field browserIP. */ - fun ip(ip: String) = ip(JsonField.of(ip)) + fun ip(ip: String?) = ip(JsonField.ofNullable(ip)) /** * IP address of the browser as returned by the HTTP headers to the 3DS requestor (e.g., @@ -2997,7 +3072,13 @@ private constructor( * Indicates whether the cardholder's browser has the ability to execute Java. Maps to * EMV 3DS field browserJavaEnabled. */ - fun javaEnabled(javaEnabled: Boolean) = javaEnabled(JsonField.of(javaEnabled)) + fun javaEnabled(javaEnabled: Boolean?) = javaEnabled(JsonField.ofNullable(javaEnabled)) + + /** + * Indicates whether the cardholder's browser has the ability to execute Java. Maps to + * EMV 3DS field browserJavaEnabled. + */ + fun javaEnabled(javaEnabled: Boolean) = javaEnabled(javaEnabled as Boolean?) /** * Indicates whether the cardholder's browser has the ability to execute Java. Maps to @@ -3007,12 +3088,19 @@ private constructor( this.javaEnabled = javaEnabled } + /** + * Indicates whether the cardholder's browser has the ability to execute JavaScript. + * Maps to EMV 3DS field browserJavascriptEnabled. + */ + fun javascriptEnabled(javascriptEnabled: Boolean?) = + javascriptEnabled(JsonField.ofNullable(javascriptEnabled)) + /** * Indicates whether the cardholder's browser has the ability to execute JavaScript. * Maps to EMV 3DS field browserJavascriptEnabled. */ fun javascriptEnabled(javascriptEnabled: Boolean) = - javascriptEnabled(JsonField.of(javascriptEnabled)) + javascriptEnabled(javascriptEnabled as Boolean?) /** * Indicates whether the cardholder's browser has the ability to execute JavaScript. @@ -3026,7 +3114,7 @@ private constructor( * Language of the cardholder's browser as defined in IETF BCP47. Maps to EMV 3DS field * browserLanguage. */ - fun language(language: String) = language(JsonField.of(language)) + fun language(language: String?) = language(JsonField.ofNullable(language)) /** * Language of the cardholder's browser as defined in IETF BCP47. Maps to EMV 3DS field @@ -3039,7 +3127,7 @@ private constructor( * cardholder browser's local time. The offset is positive if the local time is behind * UTC and negative if it is ahead. Maps to EMV 3DS field browserTz. */ - fun timeZone(timeZone: String) = timeZone(JsonField.of(timeZone)) + fun timeZone(timeZone: String?) = timeZone(JsonField.ofNullable(timeZone)) /** * Time zone of the cardholder's browser offset in minutes between UTC and the @@ -3049,7 +3137,7 @@ private constructor( fun timeZone(timeZone: JsonField) = apply { this.timeZone = timeZone } /** Content of the HTTP user-agent header. Maps to EMV 3DS field browserUserAgent. */ - fun userAgent(userAgent: String) = userAgent(JsonField.of(userAgent)) + fun userAgent(userAgent: String?) = userAgent(JsonField.ofNullable(userAgent)) /** Content of the HTTP user-agent header. Maps to EMV 3DS field browserUserAgent. */ fun userAgent(userAgent: JsonField) = apply { this.userAgent = userAgent } @@ -3300,10 +3388,10 @@ private constructor( * Amount of the purchase in minor units of currency with all punctuation removed. Maps to * EMV 3DS field purchaseAmount. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** Currency of the purchase. Maps to EMV 3DS field purchaseCurrency. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * Minor units of currency, as specified in ISO 4217 currency exponent. Maps to EMV 3DS @@ -3311,19 +3399,21 @@ private constructor( */ @JsonProperty("currency_exponent") @ExcludeMissing - fun _currencyExponent() = currencyExponent + fun _currencyExponent(): JsonField = currencyExponent /** * Date and time when the authentication was generated by the merchant/acquirer's 3DS * server. Maps to EMV 3DS field purchaseDate. */ - @JsonProperty("date_time") @ExcludeMissing fun _dateTime() = dateTime + @JsonProperty("date_time") + @ExcludeMissing + fun _dateTime(): JsonField = dateTime /** * Type of the transaction for which a 3DS authentication request is occurring. Maps to EMV * 3DS field transType. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -3351,11 +3441,11 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var currencyExponent: JsonField = JsonMissing.of() - private var dateTime: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var currency: JsonField? = null + private var currencyExponent: JsonField? = null + private var dateTime: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(transaction: Transaction) = apply { @@ -3416,7 +3506,7 @@ private constructor( * Type of the transaction for which a 3DS authentication request is occurring. Maps to * EMV 3DS field transType. */ - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: Type?) = type(JsonField.ofNullable(type)) /** * Type of the transaction for which a 3DS authentication request is occurring. Maps to @@ -3445,11 +3535,13 @@ private constructor( fun build(): Transaction = Transaction( - amount, - currency, - currencyExponent, - dateTime, - type, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(currencyExponent) { + "`currencyExponent` is required but was not set" + }, + checkNotNull(dateTime) { "`dateTime` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthenticationSimulateResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthenticationSimulateResponse.kt index c764dfba..c2a79f16 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthenticationSimulateResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthenticationSimulateResponse.kt @@ -33,7 +33,7 @@ private constructor( * A unique token to reference this transaction with later calls to void or clear the * authorization. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BacktestCreateResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BacktestCreateResponse.kt index cd785c2a..44507d94 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BacktestCreateResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BacktestCreateResponse.kt @@ -29,7 +29,9 @@ private constructor( fun backtestToken(): String? = backtestToken.getNullable("backtest_token") /** Auth Rule Backtest Token */ - @JsonProperty("backtest_token") @ExcludeMissing fun _backtestToken() = backtestToken + @JsonProperty("backtest_token") + @ExcludeMissing + fun _backtestToken(): JsonField = backtestToken @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BacktestResults.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BacktestResults.kt index 01a760e6..d4672552 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BacktestResults.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BacktestResults.kt @@ -41,13 +41,15 @@ private constructor( simulationParameters.getRequired("simulation_parameters") /** Auth Rule Backtest Token */ - @JsonProperty("backtest_token") @ExcludeMissing fun _backtestToken() = backtestToken + @JsonProperty("backtest_token") + @ExcludeMissing + fun _backtestToken(): JsonField = backtestToken - @JsonProperty("results") @ExcludeMissing fun _results() = results + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField = results @JsonProperty("simulation_parameters") @ExcludeMissing - fun _simulationParameters() = simulationParameters + fun _simulationParameters(): JsonField = simulationParameters @JsonAnyGetter @ExcludeMissing @@ -73,9 +75,9 @@ private constructor( class Builder { - private var backtestToken: JsonField = JsonMissing.of() - private var results: JsonField = JsonMissing.of() - private var simulationParameters: JsonField = JsonMissing.of() + private var backtestToken: JsonField? = null + private var results: JsonField? = null + private var simulationParameters: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(backtestResults: BacktestResults) = apply { @@ -125,9 +127,11 @@ private constructor( fun build(): BacktestResults = BacktestResults( - backtestToken, - results, - simulationParameters, + checkNotNull(backtestToken) { "`backtestToken` is required but was not set" }, + checkNotNull(results) { "`results` is required but was not set" }, + checkNotNull(simulationParameters) { + "`simulationParameters` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -150,9 +154,13 @@ private constructor( fun draftVersion(): RuleStats? = draftVersion.getNullable("draft_version") - @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + @JsonProperty("current_version") + @ExcludeMissing + fun _currentVersion(): JsonField = currentVersion - @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + @JsonProperty("draft_version") + @ExcludeMissing + fun _draftVersion(): JsonField = draftVersion @JsonAnyGetter @ExcludeMissing @@ -187,14 +195,15 @@ private constructor( additionalProperties = results.additionalProperties.toMutableMap() } - fun currentVersion(currentVersion: RuleStats) = - currentVersion(JsonField.of(currentVersion)) + fun currentVersion(currentVersion: RuleStats?) = + currentVersion(JsonField.ofNullable(currentVersion)) fun currentVersion(currentVersion: JsonField) = apply { this.currentVersion = currentVersion } - fun draftVersion(draftVersion: RuleStats) = draftVersion(JsonField.of(draftVersion)) + fun draftVersion(draftVersion: RuleStats?) = + draftVersion(JsonField.ofNullable(draftVersion)) fun draftVersion(draftVersion: JsonField) = apply { this.draftVersion = draftVersion @@ -274,22 +283,24 @@ private constructor( * period, or the number of transactions that would have been approved if the rule was * evaluated in shadow mode. */ - @JsonProperty("approved") @ExcludeMissing fun _approved() = approved + @JsonProperty("approved") @ExcludeMissing fun _approved(): JsonField = approved /** * The total number of historical transactions declined by this rule during the backtest * period, or the number of transactions that would have been declined if the rule was * evaluated in shadow mode. */ - @JsonProperty("declined") @ExcludeMissing fun _declined() = declined + @JsonProperty("declined") @ExcludeMissing fun _declined(): JsonField = declined /** Example authorization request events that would have been approved or declined. */ - @JsonProperty("examples") @ExcludeMissing fun _examples() = examples + @JsonProperty("examples") + @ExcludeMissing + fun _examples(): JsonField> = examples /** * The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -318,14 +329,14 @@ private constructor( private var approved: JsonField = JsonMissing.of() private var declined: JsonField = JsonMissing.of() - private var examples: JsonField> = JsonMissing.of() + private var examples: JsonField>? = null private var version: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(ruleStats: RuleStats) = apply { approved = ruleStats.approved declined = ruleStats.declined - examples = ruleStats.examples + examples = ruleStats.examples.map { it.toMutableList() } version = ruleStats.version additionalProperties = ruleStats.additionalProperties.toMutableMap() } @@ -367,7 +378,21 @@ private constructor( * Example authorization request events that would have been approved or declined. */ fun examples(examples: JsonField>) = apply { - this.examples = examples + this.examples = examples.map { it.toMutableList() } + } + + /** + * Example authorization request events that would have been approved or declined. + */ + fun addExample(example: Example) = apply { + examples = + (examples ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(example) + } } /** @@ -408,7 +433,7 @@ private constructor( RuleStats( approved, declined, - examples.map { it.toImmutable() }, + (examples ?: JsonMissing.of()).map { it.toImmutable() }, version, additionalProperties.toImmutable(), ) @@ -441,13 +466,19 @@ private constructor( fun timestamp(): OffsetDateTime? = timestamp.getNullable("timestamp") /** Whether the rule would have approved the authorization request. */ - @JsonProperty("approved") @ExcludeMissing fun _approved() = approved + @JsonProperty("approved") + @ExcludeMissing + fun _approved(): JsonField = approved /** The authorization request event token. */ - @JsonProperty("event_token") @ExcludeMissing fun _eventToken() = eventToken + @JsonProperty("event_token") + @ExcludeMissing + fun _eventToken(): JsonField = eventToken /** The timestamp of the authorization request event. */ - @JsonProperty("timestamp") @ExcludeMissing fun _timestamp() = timestamp + @JsonProperty("timestamp") + @ExcludeMissing + fun _timestamp(): JsonField = timestamp @JsonAnyGetter @ExcludeMissing @@ -619,13 +650,15 @@ private constructor( fun start(): OffsetDateTime? = start.getNullable("start") /** Auth Rule Token */ - @JsonProperty("auth_rule_token") @ExcludeMissing fun _authRuleToken() = authRuleToken + @JsonProperty("auth_rule_token") + @ExcludeMissing + fun _authRuleToken(): JsonField = authRuleToken /** The end time of the simulation. */ - @JsonProperty("end") @ExcludeMissing fun _end() = end + @JsonProperty("end") @ExcludeMissing fun _end(): JsonField = end /** The start time of the simulation. */ - @JsonProperty("start") @ExcludeMissing fun _start() = start + @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Balance.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Balance.kt index dec2bac1..032799c0 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Balance.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Balance.kt @@ -99,23 +99,25 @@ private constructor( fun updated(): OffsetDateTime = updated.getRequired("updated") /** Funds available for spend in the currency's smallest unit (e.g., cents for USD) */ - @JsonProperty("available_amount") @ExcludeMissing fun _availableAmount() = availableAmount + @JsonProperty("available_amount") + @ExcludeMissing + fun _availableAmount(): JsonField = availableAmount /** Date and time for when the balance was first created. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** 3-digit alphabetic ISO 4217 code for the local currency of the balance. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** Globally unique identifier for the financial account that holds this balance. */ @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken /** Type of financial account. */ @JsonProperty("financial_account_type") @ExcludeMissing - fun _financialAccountType() = financialAccountType + fun _financialAccountType(): JsonField = financialAccountType /** * Globally unique identifier for the last financial transaction event that impacted this @@ -123,27 +125,29 @@ private constructor( */ @JsonProperty("last_transaction_event_token") @ExcludeMissing - fun _lastTransactionEventToken() = lastTransactionEventToken + fun _lastTransactionEventToken(): JsonField = lastTransactionEventToken /** Globally unique identifier for the last financial transaction that impacted this balance. */ @JsonProperty("last_transaction_token") @ExcludeMissing - fun _lastTransactionToken() = lastTransactionToken + fun _lastTransactionToken(): JsonField = lastTransactionToken /** * Funds not available for spend due to card authorizations or pending ACH release. Shown in the * currency's smallest unit (e.g., cents for USD). */ - @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount /** * The sum of available and pending balance in the currency's smallest unit (e.g., cents for * USD). */ - @JsonProperty("total_amount") @ExcludeMissing fun _totalAmount() = totalAmount + @JsonProperty("total_amount") @ExcludeMissing fun _totalAmount(): JsonField = totalAmount /** Date and time for when the balance was last updated. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated @JsonAnyGetter @ExcludeMissing @@ -176,16 +180,16 @@ private constructor( class Builder { - private var availableAmount: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var financialAccountToken: JsonField = JsonMissing.of() - private var financialAccountType: JsonField = JsonMissing.of() - private var lastTransactionEventToken: JsonField = JsonMissing.of() - private var lastTransactionToken: JsonField = JsonMissing.of() - private var pendingAmount: JsonField = JsonMissing.of() - private var totalAmount: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() + private var availableAmount: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var financialAccountToken: JsonField? = null + private var financialAccountType: JsonField? = null + private var lastTransactionEventToken: JsonField? = null + private var lastTransactionToken: JsonField? = null + private var pendingAmount: JsonField? = null + private var totalAmount: JsonField? = null + private var updated: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(balance: Balance) = apply { @@ -321,16 +325,24 @@ private constructor( fun build(): Balance = Balance( - availableAmount, - created, - currency, - financialAccountToken, - financialAccountType, - lastTransactionEventToken, - lastTransactionToken, - pendingAmount, - totalAmount, - updated, + checkNotNull(availableAmount) { "`availableAmount` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + checkNotNull(financialAccountType) { + "`financialAccountType` is required but was not set" + }, + checkNotNull(lastTransactionEventToken) { + "`lastTransactionEventToken` is required but was not set" + }, + checkNotNull(lastTransactionToken) { + "`lastTransactionToken` is required but was not set" + }, + checkNotNull(pendingAmount) { "`pendingAmount` is required but was not set" }, + checkNotNull(totalAmount) { "`totalAmount` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BalanceListResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BalanceListResponse.kt index d7c38948..d902ed90 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BalanceListResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BalanceListResponse.kt @@ -93,16 +93,18 @@ private constructor( fun updated(): OffsetDateTime = updated.getRequired("updated") /** Globally unique identifier for the financial account that holds this balance. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Funds available for spend in the currency's smallest unit (e.g., cents for USD) */ - @JsonProperty("available_amount") @ExcludeMissing fun _availableAmount() = availableAmount + @JsonProperty("available_amount") + @ExcludeMissing + fun _availableAmount(): JsonField = availableAmount /** Date and time for when the balance was first created. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** 3-digit alphabetic ISO 4217 code for the local currency of the balance. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * Globally unique identifier for the last financial transaction event that impacted this @@ -110,30 +112,32 @@ private constructor( */ @JsonProperty("last_transaction_event_token") @ExcludeMissing - fun _lastTransactionEventToken() = lastTransactionEventToken + fun _lastTransactionEventToken(): JsonField = lastTransactionEventToken /** Globally unique identifier for the last financial transaction that impacted this balance. */ @JsonProperty("last_transaction_token") @ExcludeMissing - fun _lastTransactionToken() = lastTransactionToken + fun _lastTransactionToken(): JsonField = lastTransactionToken /** * Funds not available for spend due to card authorizations or pending ACH release. Shown in the * currency's smallest unit (e.g., cents for USD). */ - @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount /** * The sum of available and pending balance in the currency's smallest unit (e.g., cents for * USD). */ - @JsonProperty("total_amount") @ExcludeMissing fun _totalAmount() = totalAmount + @JsonProperty("total_amount") @ExcludeMissing fun _totalAmount(): JsonField = totalAmount /** Type of financial account. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** Date and time for when the balance was last updated. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated @JsonAnyGetter @ExcludeMissing @@ -166,16 +170,16 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var availableAmount: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var lastTransactionEventToken: JsonField = JsonMissing.of() - private var lastTransactionToken: JsonField = JsonMissing.of() - private var pendingAmount: JsonField = JsonMissing.of() - private var totalAmount: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var availableAmount: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var lastTransactionEventToken: JsonField? = null + private var lastTransactionToken: JsonField? = null + private var pendingAmount: JsonField? = null + private var totalAmount: JsonField? = null + private var type: JsonField? = null + private var updated: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(balanceListResponse: BalanceListResponse) = apply { @@ -305,16 +309,20 @@ private constructor( fun build(): BalanceListResponse = BalanceListResponse( - token, - availableAmount, - created, - currency, - lastTransactionEventToken, - lastTransactionToken, - pendingAmount, - totalAmount, - type, - updated, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(availableAmount) { "`availableAmount` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(lastTransactionEventToken) { + "`lastTransactionEventToken` is required but was not set" + }, + checkNotNull(lastTransactionToken) { + "`lastTransactionToken` is required but was not set" + }, + checkNotNull(pendingAmount) { "`pendingAmount` is required but was not set" }, + checkNotNull(totalAmount) { "`totalAmount` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BookTransferCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BookTransferCreateParams.kt index cc8bc3f8..affffe64 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BookTransferCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BookTransferCreateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -62,12 +63,48 @@ constructor( /** Optional descriptor for the transfer. */ fun memo(): String? = body.memo() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This should + * always be a positive value. + */ + fun _amount(): JsonField = body._amount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Category of the book transfer */ + fun _category(): JsonField = body._category() + + /** + * Globally unique identifier for the financial account or card that will send the funds. + * Accepted type dependent on the program's use case. + */ + fun _fromFinancialAccountToken(): JsonField = body._fromFinancialAccountToken() + + /** The program specific subtype code for the specified category/type. */ + fun _subtype(): JsonField = body._subtype() + + /** + * Globally unique identifier for the financial account or card that will receive the funds. + * Accepted type dependent on the program's use case. + */ + fun _toFinancialAccountToken(): JsonField = body._toFinancialAccountToken() + + /** Type of book_transfer */ + fun _type(): JsonField = body._type() + + /** + * Customer-provided token that will serve as an idempotency token. This token will become the + * transaction token. + */ + fun _token(): JsonField = body._token() + + /** Optional descriptor for the transfer. */ + fun _memo(): JsonField = body._memo() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): BookTransferCreateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -78,14 +115,28 @@ constructor( class BookTransferCreateBody @JsonCreator internal constructor( - @JsonProperty("amount") private val amount: Long, - @JsonProperty("category") private val category: Category, - @JsonProperty("from_financial_account_token") private val fromFinancialAccountToken: String, - @JsonProperty("subtype") private val subtype: String, - @JsonProperty("to_financial_account_token") private val toFinancialAccountToken: String, - @JsonProperty("type") private val type: Type, - @JsonProperty("token") private val token: String?, - @JsonProperty("memo") private val memo: String?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + private val category: JsonField = JsonMissing.of(), + @JsonProperty("from_financial_account_token") + @ExcludeMissing + private val fromFinancialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("subtype") + @ExcludeMissing + private val subtype: JsonField = JsonMissing.of(), + @JsonProperty("to_financial_account_token") + @ExcludeMissing + private val toFinancialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("token") + @ExcludeMissing + private val token: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -94,44 +145,100 @@ constructor( * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This * should always be a positive value. */ - @JsonProperty("amount") fun amount(): Long = amount + fun amount(): Long = amount.getRequired("amount") + + /** Category of the book transfer */ + fun category(): Category = category.getRequired("category") + + /** + * Globally unique identifier for the financial account or card that will send the funds. + * Accepted type dependent on the program's use case. + */ + fun fromFinancialAccountToken(): String = + fromFinancialAccountToken.getRequired("from_financial_account_token") + + /** The program specific subtype code for the specified category/type. */ + fun subtype(): String = subtype.getRequired("subtype") + + /** + * Globally unique identifier for the financial account or card that will receive the funds. + * Accepted type dependent on the program's use case. + */ + fun toFinancialAccountToken(): String = + toFinancialAccountToken.getRequired("to_financial_account_token") + + /** Type of book_transfer */ + fun type(): Type = type.getRequired("type") + + /** + * Customer-provided token that will serve as an idempotency token. This token will become + * the transaction token. + */ + fun token(): String? = token.getNullable("token") + + /** Optional descriptor for the transfer. */ + fun memo(): String? = memo.getNullable("memo") + + /** + * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This + * should always be a positive value. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** Category of the book transfer */ - @JsonProperty("category") fun category(): Category = category + @JsonProperty("category") @ExcludeMissing fun _category(): JsonField = category /** * Globally unique identifier for the financial account or card that will send the funds. * Accepted type dependent on the program's use case. */ @JsonProperty("from_financial_account_token") - fun fromFinancialAccountToken(): String = fromFinancialAccountToken + @ExcludeMissing + fun _fromFinancialAccountToken(): JsonField = fromFinancialAccountToken /** The program specific subtype code for the specified category/type. */ - @JsonProperty("subtype") fun subtype(): String = subtype + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype /** * Globally unique identifier for the financial account or card that will receive the funds. * Accepted type dependent on the program's use case. */ @JsonProperty("to_financial_account_token") - fun toFinancialAccountToken(): String = toFinancialAccountToken + @ExcludeMissing + fun _toFinancialAccountToken(): JsonField = toFinancialAccountToken /** Type of book_transfer */ - @JsonProperty("type") fun type(): Type = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Customer-provided token that will serve as an idempotency token. This token will become * the transaction token. */ - @JsonProperty("token") fun token(): String? = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Optional descriptor for the transfer. */ - @JsonProperty("memo") fun memo(): String? = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BookTransferCreateBody = apply { + if (!validated) { + amount() + category() + fromFinancialAccountToken() + subtype() + toFinancialAccountToken() + type() + token() + memo() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -141,14 +248,14 @@ constructor( class Builder { - private var amount: Long? = null - private var category: Category? = null - private var fromFinancialAccountToken: String? = null - private var subtype: String? = null - private var toFinancialAccountToken: String? = null - private var type: Type? = null - private var token: String? = null - private var memo: String? = null + private var amount: JsonField? = null + private var category: JsonField? = null + private var fromFinancialAccountToken: JsonField? = null + private var subtype: JsonField? = null + private var toFinancialAccountToken: JsonField? = null + private var type: JsonField? = null + private var token: JsonField = JsonMissing.of() + private var memo: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(bookTransferCreateBody: BookTransferCreateBody) = apply { @@ -167,41 +274,79 @@ constructor( * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This * should always be a positive value. */ - fun amount(amount: Long) = apply { this.amount = amount } + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This + * should always be a positive value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Category of the book transfer */ + fun category(category: Category) = category(JsonField.of(category)) /** Category of the book transfer */ - fun category(category: Category) = apply { this.category = category } + fun category(category: JsonField) = apply { this.category = category } + + /** + * Globally unique identifier for the financial account or card that will send the + * funds. Accepted type dependent on the program's use case. + */ + fun fromFinancialAccountToken(fromFinancialAccountToken: String) = + fromFinancialAccountToken(JsonField.of(fromFinancialAccountToken)) /** * Globally unique identifier for the financial account or card that will send the * funds. Accepted type dependent on the program's use case. */ - fun fromFinancialAccountToken(fromFinancialAccountToken: String) = apply { + fun fromFinancialAccountToken(fromFinancialAccountToken: JsonField) = apply { this.fromFinancialAccountToken = fromFinancialAccountToken } /** The program specific subtype code for the specified category/type. */ - fun subtype(subtype: String) = apply { this.subtype = subtype } + fun subtype(subtype: String) = subtype(JsonField.of(subtype)) + + /** The program specific subtype code for the specified category/type. */ + fun subtype(subtype: JsonField) = apply { this.subtype = subtype } /** * Globally unique identifier for the financial account or card that will receive the * funds. Accepted type dependent on the program's use case. */ - fun toFinancialAccountToken(toFinancialAccountToken: String) = apply { + fun toFinancialAccountToken(toFinancialAccountToken: String) = + toFinancialAccountToken(JsonField.of(toFinancialAccountToken)) + + /** + * Globally unique identifier for the financial account or card that will receive the + * funds. Accepted type dependent on the program's use case. + */ + fun toFinancialAccountToken(toFinancialAccountToken: JsonField) = apply { this.toFinancialAccountToken = toFinancialAccountToken } /** Type of book_transfer */ - fun type(type: Type) = apply { this.type = type } + fun type(type: Type) = type(JsonField.of(type)) + + /** Type of book_transfer */ + fun type(type: JsonField) = apply { this.type = type } + + /** + * Customer-provided token that will serve as an idempotency token. This token will + * become the transaction token. + */ + fun token(token: String) = token(JsonField.of(token)) /** * Customer-provided token that will serve as an idempotency token. This token will * become the transaction token. */ - fun token(token: String?) = apply { this.token = token } + fun token(token: JsonField) = apply { this.token = token } /** Optional descriptor for the transfer. */ - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String) = memo(JsonField.of(memo)) + + /** Optional descriptor for the transfer. */ + fun memo(memo: JsonField) = apply { this.memo = memo } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -284,9 +429,18 @@ constructor( */ fun amount(amount: Long) = apply { body.amount(amount) } + /** + * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This + * should always be a positive value. + */ + fun amount(amount: JsonField) = apply { body.amount(amount) } + /** Category of the book transfer */ fun category(category: Category) = apply { body.category(category) } + /** Category of the book transfer */ + fun category(category: JsonField) = apply { body.category(category) } + /** * Globally unique identifier for the financial account or card that will send the funds. * Accepted type dependent on the program's use case. @@ -295,9 +449,20 @@ constructor( body.fromFinancialAccountToken(fromFinancialAccountToken) } + /** + * Globally unique identifier for the financial account or card that will send the funds. + * Accepted type dependent on the program's use case. + */ + fun fromFinancialAccountToken(fromFinancialAccountToken: JsonField) = apply { + body.fromFinancialAccountToken(fromFinancialAccountToken) + } + /** The program specific subtype code for the specified category/type. */ fun subtype(subtype: String) = apply { body.subtype(subtype) } + /** The program specific subtype code for the specified category/type. */ + fun subtype(subtype: JsonField) = apply { body.subtype(subtype) } + /** * Globally unique identifier for the financial account or card that will receive the funds. * Accepted type dependent on the program's use case. @@ -306,17 +471,56 @@ constructor( body.toFinancialAccountToken(toFinancialAccountToken) } + /** + * Globally unique identifier for the financial account or card that will receive the funds. + * Accepted type dependent on the program's use case. + */ + fun toFinancialAccountToken(toFinancialAccountToken: JsonField) = apply { + body.toFinancialAccountToken(toFinancialAccountToken) + } + /** Type of book_transfer */ fun type(type: Type) = apply { body.type(type) } + /** Type of book_transfer */ + fun type(type: JsonField) = apply { body.type(type) } + + /** + * Customer-provided token that will serve as an idempotency token. This token will become + * the transaction token. + */ + fun token(token: String) = apply { body.token(token) } + /** * Customer-provided token that will serve as an idempotency token. This token will become * the transaction token. */ - fun token(token: String?) = apply { body.token(token) } + fun token(token: JsonField) = apply { body.token(token) } /** Optional descriptor for the transfer. */ - fun memo(memo: String?) = apply { body.memo(memo) } + fun memo(memo: String) = apply { body.memo(memo) } + + /** Optional descriptor for the transfer. */ + fun memo(memo: JsonField) = apply { body.memo(memo) } + + 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() @@ -416,25 +620,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): BookTransferCreateParams = BookTransferCreateParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BookTransferResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BookTransferResponse.kt index dc991604..fb9d0b92 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BookTransferResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BookTransferResponse.kt @@ -109,6 +109,14 @@ private constructor( */ fun status(): Status = status.getRequired("status") + /** + * Globally unique identifier for the financial account or card that will receive the funds. + * Accepted type dependent on the program's use case. + */ + @JsonProperty("to_financial_account_token") + @ExcludeMissing + fun _toFinancialAccountToken(): JsonValue = toFinancialAccountToken + /** Date and time when the financial transaction was last updated. UTC time zone. */ fun updated(): OffsetDateTime = updated.getRequired("updated") @@ -116,19 +124,21 @@ private constructor( * Customer-provided token that will serve as an idempotency token. This token will become the * transaction token. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Category of the book transfer */ - @JsonProperty("category") @ExcludeMissing fun _category() = category + @JsonProperty("category") @ExcludeMissing fun _category(): JsonField = category /** Date and time when the transfer occurred. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** 3-digit alphabetic ISO 4217 code for the settling currency of the transaction. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** A list of all financial events that have modified this transfer. */ - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events /** * Globally unique identifier for the financial account or card that will send the funds. @@ -136,43 +146,39 @@ private constructor( */ @JsonProperty("from_financial_account_token") @ExcludeMissing - fun _fromFinancialAccountToken() = fromFinancialAccountToken + fun _fromFinancialAccountToken(): JsonField = fromFinancialAccountToken /** * Pending amount of the transaction in the currency's smallest unit (e.g., cents), including * any acquirer fees. The value of this field will go to zero over time once the financial * transaction is settled. */ - @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount /** * APPROVED transactions were successful while DECLINED transactions were declined by user, * Lithic, or the network. */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** * Amount of the transaction that has been settled in the currency's smallest unit (e.g., * cents). */ - @JsonProperty("settled_amount") @ExcludeMissing fun _settledAmount() = settledAmount + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount /** * Status types: _ `DECLINED` - The transfer was declined. _ `REVERSED` - The transfer was * reversed \* `SETTLED` - The transfer is completed. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** - * Globally unique identifier for the financial account or card that will receive the funds. - * Accepted type dependent on the program's use case. - */ - @JsonProperty("to_financial_account_token") - @ExcludeMissing - fun _toFinancialAccountToken() = toFinancialAccountToken + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** Date and time when the financial transaction was last updated. UTC time zone. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated @JsonAnyGetter @ExcludeMissing @@ -206,18 +212,18 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var category: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var events: JsonField> = JsonMissing.of() - private var fromFinancialAccountToken: JsonField = JsonMissing.of() - private var pendingAmount: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var settledAmount: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var toFinancialAccountToken: JsonValue = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var events: JsonField>? = null + private var fromFinancialAccountToken: JsonField? = null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var toFinancialAccountToken: JsonValue? = null + private var updated: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(bookTransferResponse: BookTransferResponse) = apply { @@ -225,7 +231,7 @@ private constructor( category = bookTransferResponse.category created = bookTransferResponse.created currency = bookTransferResponse.currency - events = bookTransferResponse.events + events = bookTransferResponse.events.map { it.toMutableList() } fromFinancialAccountToken = bookTransferResponse.fromFinancialAccountToken pendingAmount = bookTransferResponse.pendingAmount result = bookTransferResponse.result @@ -270,7 +276,21 @@ private constructor( fun events(events: List) = events(JsonField.of(events)) /** A list of all financial events that have modified this transfer. */ - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** A list of all financial events that have modified this transfer. */ + fun addEvent(event: BookTransferEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(event) + } + } /** * Globally unique identifier for the financial account or card that will send the funds. @@ -376,18 +396,23 @@ private constructor( fun build(): BookTransferResponse = BookTransferResponse( - token, - category, - created, - currency, - events.map { it.toImmutable() }, - fromFinancialAccountToken, - pendingAmount, - result, - settledAmount, - status, - toFinancialAccountToken, - updated, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(category) { "`category` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(events) { "`events` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(fromFinancialAccountToken) { + "`fromFinancialAccountToken` is required but was not set" + }, + checkNotNull(pendingAmount) { "`pendingAmount` is required but was not set" }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(settledAmount) { "`settledAmount` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(toFinancialAccountToken) { + "`toFinancialAccountToken` is required but was not set" + }, + checkNotNull(updated) { "`updated` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -543,34 +568,36 @@ private constructor( fun type(): String = type.getRequired("type") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * Amount of the financial event that has been settled in the currency's smallest unit * (e.g., cents). */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** Date and time when the financial event occurred. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Detailed Results */ - @JsonProperty("detailed_results") @ExcludeMissing fun _detailedResults() = detailedResults + @JsonProperty("detailed_results") + @ExcludeMissing + fun _detailedResults(): JsonField> = detailedResults /** Memo for the transfer. */ - @JsonProperty("memo") @ExcludeMissing fun _memo() = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo /** * APPROVED financial events were successful while DECLINED financial events were declined * by user, Lithic, or the network. */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** The program specific subtype code for the specified category/type. */ - @JsonProperty("subtype") @ExcludeMissing fun _subtype() = subtype + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype /** Type of the book transfer */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -601,21 +628,21 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var detailedResults: JsonField> = JsonMissing.of() - private var memo: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var subtype: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var amount: JsonField? = null + private var created: JsonField? = null + private var detailedResults: JsonField>? = null + private var memo: JsonField? = null + private var result: JsonField? = null + private var subtype: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(bookTransferEvent: BookTransferEvent) = apply { token = bookTransferEvent.token amount = bookTransferEvent.amount created = bookTransferEvent.created - detailedResults = bookTransferEvent.detailedResults + detailedResults = bookTransferEvent.detailedResults.map { it.toMutableList() } memo = bookTransferEvent.memo result = bookTransferEvent.result subtype = bookTransferEvent.subtype @@ -653,7 +680,19 @@ private constructor( /** Detailed Results */ fun detailedResults(detailedResults: JsonField>) = apply { - this.detailedResults = detailedResults + this.detailedResults = detailedResults.map { it.toMutableList() } + } + + /** Detailed Results */ + fun addDetailedResult(detailedResult: DetailedResult) = apply { + detailedResults = + (detailedResults ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(detailedResult) + } } /** Memo for the transfer. */ @@ -707,14 +746,17 @@ private constructor( fun build(): BookTransferEvent = BookTransferEvent( - token, - amount, - created, - detailedResults.map { it.toImmutable() }, - memo, - result, - subtype, - type, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(detailedResults) { + "`detailedResults` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(memo) { "`memo` is required but was not set" }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(subtype) { "`subtype` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BookTransferReverseParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BookTransferReverseParams.kt index 8bde7330..a161e918 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BookTransferReverseParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BookTransferReverseParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -29,12 +31,15 @@ constructor( /** Optional descriptor for the reversal. */ fun memo(): String? = body.memo() + /** Optional descriptor for the reversal. */ + fun _memo(): JsonField = body._memo() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): BookTransferReverseBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -52,18 +57,32 @@ constructor( class BookTransferReverseBody @JsonCreator internal constructor( - @JsonProperty("memo") private val memo: String?, + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Optional descriptor for the reversal. */ - @JsonProperty("memo") fun memo(): String? = memo + fun memo(): String? = memo.getNullable("memo") + + /** Optional descriptor for the reversal. */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BookTransferReverseBody = apply { + if (!validated) { + memo() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -73,7 +92,7 @@ constructor( class Builder { - private var memo: String? = null + private var memo: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(bookTransferReverseBody: BookTransferReverseBody) = apply { @@ -82,7 +101,10 @@ constructor( } /** Optional descriptor for the reversal. */ - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String) = memo(JsonField.of(memo)) + + /** Optional descriptor for the reversal. */ + fun memo(memo: JsonField) = apply { this.memo = memo } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -152,7 +174,29 @@ constructor( } /** Optional descriptor for the reversal. */ - fun memo(memo: String?) = apply { body.memo(memo) } + fun memo(memo: String) = apply { body.memo(memo) } + + /** Optional descriptor for the reversal. */ + fun memo(memo: JsonField) = apply { body.memo(memo) } + + 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() @@ -252,25 +296,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): BookTransferReverseParams = BookTransferReverseParams( checkNotNull(bookTransferToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Card.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Card.kt index 8a9595ef..54b0d0ae 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Card.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Card.kt @@ -222,33 +222,37 @@ private constructor( fun replacementFor(): String? = replacementFor.getNullable("replacement_for") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Globally unique identifier for the account to which the card belongs. */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** Globally unique identifier for the card program on which the card exists. */ - @JsonProperty("card_program_token") @ExcludeMissing fun _cardProgramToken() = cardProgramToken + @JsonProperty("card_program_token") + @ExcludeMissing + fun _cardProgramToken(): JsonField = cardProgramToken /** An RFC 3339 timestamp for when the card was created. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Deprecated: Funding account for the card. */ - @JsonProperty("funding") @ExcludeMissing fun _funding() = funding + @JsonProperty("funding") @ExcludeMissing fun _funding(): JsonField = funding /** Last four digits of the card number. */ - @JsonProperty("last_four") @ExcludeMissing fun _lastFour() = lastFour + @JsonProperty("last_four") @ExcludeMissing fun _lastFour(): JsonField = lastFour /** * Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect attempts). */ - @JsonProperty("pin_status") @ExcludeMissing fun _pinStatus() = pinStatus + @JsonProperty("pin_status") @ExcludeMissing fun _pinStatus(): JsonField = pinStatus /** * Amount (in cents) to limit approved authorizations. Transaction requests above the spend * limit will be declined. */ - @JsonProperty("spend_limit") @ExcludeMissing fun _spendLimit() = spendLimit + @JsonProperty("spend_limit") @ExcludeMissing fun _spendLimit(): JsonField = spendLimit /** * Spend limit duration values: @@ -263,7 +267,7 @@ private constructor( */ @JsonProperty("spend_limit_duration") @ExcludeMissing - fun _spendLimitDuration() = spendLimitDuration + fun _spendLimitDuration(): JsonField = spendLimitDuration /** * Card state values: @@ -282,7 +286,7 @@ private constructor( * * In sandbox, the same daily batch fulfillment occurs, but no cards are actually manufactured. */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** * Card types: @@ -298,7 +302,7 @@ private constructor( * - `DIGITAL_WALLET` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use VIRTUAL * instead. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * List of identifiers for the Auth Rule(s) that are applied on the card. This field is @@ -306,15 +310,17 @@ private constructor( * the schema in a future release. Use the `/auth_rules` endpoints to fetch Auth Rule * information instead. */ - @JsonProperty("auth_rule_tokens") @ExcludeMissing fun _authRuleTokens() = authRuleTokens + @JsonProperty("auth_rule_tokens") + @ExcludeMissing + fun _authRuleTokens(): JsonField> = authRuleTokens /** 3-digit alphabetic ISO 4217 code for the currency of the cardholder. */ @JsonProperty("cardholder_currency") @ExcludeMissing - fun _cardholderCurrency() = cardholderCurrency + fun _cardholderCurrency(): JsonField = cardholderCurrency /** Three digit cvv printed on the back of the card. */ - @JsonProperty("cvv") @ExcludeMissing fun _cvv() = cvv + @JsonProperty("cvv") @ExcludeMissing fun _cvv(): JsonField = cvv /** * Specifies the digital card art to be displayed in the user’s digital wallet after @@ -324,46 +330,50 @@ private constructor( */ @JsonProperty("digital_card_art_token") @ExcludeMissing - fun _digitalCardArtToken() = digitalCardArtToken + fun _digitalCardArtToken(): JsonField = digitalCardArtToken /** Two digit (MM) expiry month. */ - @JsonProperty("exp_month") @ExcludeMissing fun _expMonth() = expMonth + @JsonProperty("exp_month") @ExcludeMissing fun _expMonth(): JsonField = expMonth /** Four digit (yyyy) expiry year. */ - @JsonProperty("exp_year") @ExcludeMissing fun _expYear() = expYear + @JsonProperty("exp_year") @ExcludeMissing fun _expYear(): JsonField = expYear /** Hostname of card’s locked merchant (will be empty if not applicable). */ - @JsonProperty("hostname") @ExcludeMissing fun _hostname() = hostname + @JsonProperty("hostname") @ExcludeMissing fun _hostname(): JsonField = hostname /** Friendly name to identify the card. */ - @JsonProperty("memo") @ExcludeMissing fun _memo() = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo /** * Primary Account Number (PAN) (i.e. the card number). Customers must be PCI compliant to have * PAN returned as a field in production. Please contact * [support@lithic.com](mailto:support@lithic.com) for questions. */ - @JsonProperty("pan") @ExcludeMissing fun _pan() = pan + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan /** * Indicates if there are offline PIN changes pending card interaction with an offline PIN * terminal. Possible commands are: CHANGE_PIN, UNBLOCK_PIN. Applicable only to cards issued in * markets supporting offline PINs. */ - @JsonProperty("pending_commands") @ExcludeMissing fun _pendingCommands() = pendingCommands + @JsonProperty("pending_commands") + @ExcludeMissing + fun _pendingCommands(): JsonField> = pendingCommands /** * Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic before use. * Specifies the configuration (i.e., physical card art) that the card should be manufactured * with. */ - @JsonProperty("product_id") @ExcludeMissing fun _productId() = productId + @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId /** * If the card is a replacement for another card, the globally unique identifier for the card * that was replaced. */ - @JsonProperty("replacement_for") @ExcludeMissing fun _replacementFor() = replacementFor + @JsonProperty("replacement_for") + @ExcludeMissing + fun _replacementFor(): JsonField = replacementFor @JsonAnyGetter @ExcludeMissing @@ -409,18 +419,18 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountToken: JsonField = JsonMissing.of() - private var cardProgramToken: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var funding: JsonField = JsonMissing.of() - private var lastFour: JsonField = JsonMissing.of() - private var pinStatus: JsonField = JsonMissing.of() - private var spendLimit: JsonField = JsonMissing.of() - private var spendLimitDuration: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var authRuleTokens: JsonField> = JsonMissing.of() + private var token: JsonField? = null + private var accountToken: JsonField? = null + private var cardProgramToken: JsonField? = null + private var created: JsonField? = null + private var funding: JsonField? = null + private var lastFour: JsonField? = null + private var pinStatus: JsonField? = null + private var spendLimit: JsonField? = null + private var spendLimitDuration: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var authRuleTokens: JsonField>? = null private var cardholderCurrency: JsonField = JsonMissing.of() private var cvv: JsonField = JsonMissing.of() private var digitalCardArtToken: JsonField = JsonMissing.of() @@ -429,7 +439,7 @@ private constructor( private var hostname: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() private var pan: JsonField = JsonMissing.of() - private var pendingCommands: JsonField> = JsonMissing.of() + private var pendingCommands: JsonField>? = null private var productId: JsonField = JsonMissing.of() private var replacementFor: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -446,7 +456,7 @@ private constructor( spendLimitDuration = card.spendLimitDuration state = card.state type = card.type - authRuleTokens = card.authRuleTokens + authRuleTokens = card.authRuleTokens.map { it.toMutableList() } cardholderCurrency = card.cardholderCurrency cvv = card.cvv digitalCardArtToken = card.digitalCardArtToken @@ -455,7 +465,7 @@ private constructor( hostname = card.hostname memo = card.memo pan = card.pan - pendingCommands = card.pendingCommands + pendingCommands = card.pendingCommands.map { it.toMutableList() } productId = card.productId replacementFor = card.replacementFor additionalProperties = card.additionalProperties.toMutableMap() @@ -649,7 +659,24 @@ private constructor( * information instead. */ fun authRuleTokens(authRuleTokens: JsonField>) = apply { - this.authRuleTokens = authRuleTokens + this.authRuleTokens = authRuleTokens.map { it.toMutableList() } + } + + /** + * List of identifiers for the Auth Rule(s) that are applied on the card. This field is + * deprecated and will no longer be populated in the `Card` object. The key will be removed + * from the schema in a future release. Use the `/auth_rules` endpoints to fetch Auth Rule + * information instead. + */ + fun addAuthRuleToken(authRuleToken: String) = apply { + authRuleTokens = + (authRuleTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(authRuleToken) + } } /** 3-digit alphabetic ISO 4217 code for the currency of the cardholder. */ @@ -738,7 +765,23 @@ private constructor( * in markets supporting offline PINs. */ fun pendingCommands(pendingCommands: JsonField>) = apply { - this.pendingCommands = pendingCommands + this.pendingCommands = pendingCommands.map { it.toMutableList() } + } + + /** + * Indicates if there are offline PIN changes pending card interaction with an offline PIN + * terminal. Possible commands are: CHANGE_PIN, UNBLOCK_PIN. Applicable only to cards issued + * in markets supporting offline PINs. + */ + fun addPendingCommand(pendingCommand: String) = apply { + pendingCommands = + (pendingCommands ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(pendingCommand) + } } /** @@ -759,7 +802,8 @@ private constructor( * If the card is a replacement for another card, the globally unique identifier for the * card that was replaced. */ - fun replacementFor(replacementFor: String) = replacementFor(JsonField.of(replacementFor)) + fun replacementFor(replacementFor: String?) = + replacementFor(JsonField.ofNullable(replacementFor)) /** * If the card is a replacement for another card, the globally unique identifier for the @@ -790,18 +834,20 @@ private constructor( fun build(): Card = Card( - token, - accountToken, - cardProgramToken, - created, - funding, - lastFour, - pinStatus, - spendLimit, - spendLimitDuration, - state, - type, - authRuleTokens.map { it.toImmutable() }, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountToken) { "`accountToken` is required but was not set" }, + checkNotNull(cardProgramToken) { "`cardProgramToken` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(funding) { "`funding` is required but was not set" }, + checkNotNull(lastFour) { "`lastFour` is required but was not set" }, + checkNotNull(pinStatus) { "`pinStatus` is required but was not set" }, + checkNotNull(spendLimit) { "`spendLimit` is required but was not set" }, + checkNotNull(spendLimitDuration) { + "`spendLimitDuration` is required but was not set" + }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + (authRuleTokens ?: JsonMissing.of()).map { it.toImmutable() }, cardholderCurrency, cvv, digitalCardArtToken, @@ -810,7 +856,7 @@ private constructor( hostname, memo, pan, - pendingCommands.map { it.toImmutable() }, + (pendingCommands ?: JsonMissing.of()).map { it.toImmutable() }, productId, replacementFor, additionalProperties.toImmutable(), @@ -885,19 +931,19 @@ private constructor( fun nickname(): String? = nickname.getNullable("nickname") /** A globally unique identifier for this FundingAccount. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * An RFC 3339 string representing when this funding source was added to the Lithic account. * This may be `null`. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** * The last 4 digits of the account (e.g. bank account, debit card) associated with this * FundingAccount. This may be null. */ - @JsonProperty("last_four") @ExcludeMissing fun _lastFour() = lastFour + @JsonProperty("last_four") @ExcludeMissing fun _lastFour(): JsonField = lastFour /** * State of funding source. @@ -908,20 +954,22 @@ private constructor( * verification. * - `DELETED` - The founding account has been deleted. */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** * Types of funding source: * - `DEPOSITORY_CHECKING` - Bank checking account. * - `DEPOSITORY_SAVINGS` - Bank savings account. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** Account name identifying the funding source. This may be `null`. */ - @JsonProperty("account_name") @ExcludeMissing fun _accountName() = accountName + @JsonProperty("account_name") + @ExcludeMissing + fun _accountName(): JsonField = accountName /** The nickname given to the `FundingAccount` or `null` if it has no nickname. */ - @JsonProperty("nickname") @ExcludeMissing fun _nickname() = nickname + @JsonProperty("nickname") @ExcludeMissing fun _nickname(): JsonField = nickname @JsonAnyGetter @ExcludeMissing @@ -951,11 +999,11 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var lastFour: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var created: JsonField? = null + private var lastFour: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null private var accountName: JsonField = JsonMissing.of() private var nickname: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1074,11 +1122,11 @@ private constructor( fun build(): FundingAccount = FundingAccount( - token, - created, - lastFour, - state, - type, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(lastFour) { "`lastFour` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, accountName, nickname, additionalProperties.toImmutable(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardConvertPhysicalParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardConvertPhysicalParams.kt index 6690f02d..9e22c646 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardConvertPhysicalParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardConvertPhysicalParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -63,12 +64,37 @@ constructor( */ fun shippingMethod(): ShippingMethod? = body.shippingMethod() - fun _additionalHeaders(): Headers = additionalHeaders + /** The shipping address this card will be sent to. */ + fun _shippingAddress(): JsonField = body._shippingAddress() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** If omitted, the previous carrier will be used. */ + fun _carrier(): JsonField = body._carrier() + + /** + * Specifies the configuration (e.g. physical card art) that the card should be manufactured + * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic + * before use. + */ + fun _productId(): JsonField = body._productId() + + /** + * Shipping method for the card. Use of options besides `STANDARD` require additional + * permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking + */ + fun _shippingMethod(): JsonField = body._shippingMethod() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): CardConvertPhysicalBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -86,26 +112,62 @@ constructor( class CardConvertPhysicalBody @JsonCreator internal constructor( - @JsonProperty("shipping_address") private val shippingAddress: ShippingAddress, - @JsonProperty("carrier") private val carrier: Carrier?, - @JsonProperty("product_id") private val productId: String?, - @JsonProperty("shipping_method") private val shippingMethod: ShippingMethod?, + @JsonProperty("shipping_address") + @ExcludeMissing + private val shippingAddress: JsonField = JsonMissing.of(), + @JsonProperty("carrier") + @ExcludeMissing + private val carrier: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + private val productId: JsonField = JsonMissing.of(), + @JsonProperty("shipping_method") + @ExcludeMissing + private val shippingMethod: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The shipping address this card will be sent to. */ - @JsonProperty("shipping_address") fun shippingAddress(): ShippingAddress = shippingAddress + fun shippingAddress(): ShippingAddress = shippingAddress.getRequired("shipping_address") + + /** If omitted, the previous carrier will be used. */ + fun carrier(): Carrier? = carrier.getNullable("carrier") + + /** + * Specifies the configuration (e.g. physical card art) that the card should be manufactured + * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic + * before use. + */ + fun productId(): String? = productId.getNullable("product_id") + + /** + * Shipping method for the card. Use of options besides `STANDARD` require additional + * permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with + * tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking + */ + fun shippingMethod(): ShippingMethod? = shippingMethod.getNullable("shipping_method") + + /** The shipping address this card will be sent to. */ + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress /** If omitted, the previous carrier will be used. */ - @JsonProperty("carrier") fun carrier(): Carrier? = carrier + @JsonProperty("carrier") @ExcludeMissing fun _carrier(): JsonField = carrier /** * Specifies the configuration (e.g. physical card art) that the card should be manufactured * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic * before use. */ - @JsonProperty("product_id") fun productId(): String? = productId + @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId /** * Shipping method for the card. Use of options besides `STANDARD` require additional @@ -118,12 +180,26 @@ constructor( * - `2_DAY` - FedEx 2-day shipping, with tracking * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking */ - @JsonProperty("shipping_method") fun shippingMethod(): ShippingMethod? = shippingMethod + @JsonProperty("shipping_method") + @ExcludeMissing + fun _shippingMethod(): JsonField = shippingMethod @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CardConvertPhysicalBody = apply { + if (!validated) { + shippingAddress().validate() + carrier()?.validate() + productId() + shippingMethod() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -133,10 +209,10 @@ constructor( class Builder { - private var shippingAddress: ShippingAddress? = null - private var carrier: Carrier? = null - private var productId: String? = null - private var shippingMethod: ShippingMethod? = null + private var shippingAddress: JsonField? = null + private var carrier: JsonField = JsonMissing.of() + private var productId: JsonField = JsonMissing.of() + private var shippingMethod: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cardConvertPhysicalBody: CardConvertPhysicalBody) = apply { @@ -148,19 +224,48 @@ constructor( } /** The shipping address this card will be sent to. */ - fun shippingAddress(shippingAddress: ShippingAddress) = apply { + fun shippingAddress(shippingAddress: ShippingAddress) = + shippingAddress(JsonField.of(shippingAddress)) + + /** The shipping address this card will be sent to. */ + fun shippingAddress(shippingAddress: JsonField) = apply { this.shippingAddress = shippingAddress } /** If omitted, the previous carrier will be used. */ - fun carrier(carrier: Carrier?) = apply { this.carrier = carrier } + fun carrier(carrier: Carrier) = carrier(JsonField.of(carrier)) + + /** If omitted, the previous carrier will be used. */ + fun carrier(carrier: JsonField) = apply { this.carrier = carrier } + + /** + * Specifies the configuration (e.g. physical card art) that the card should be + * manufactured with, and only applies to cards of type `PHYSICAL`. This must be + * configured with Lithic before use. + */ + fun productId(productId: String) = productId(JsonField.of(productId)) /** * Specifies the configuration (e.g. physical card art) that the card should be * manufactured with, and only applies to cards of type `PHYSICAL`. This must be * configured with Lithic before use. */ - fun productId(productId: String?) = apply { this.productId = productId } + fun productId(productId: JsonField) = apply { this.productId = productId } + + /** + * Shipping method for the card. Use of options besides `STANDARD` require additional + * permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with + * tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with + * tracking + */ + fun shippingMethod(shippingMethod: ShippingMethod) = + shippingMethod(JsonField.of(shippingMethod)) /** * Shipping method for the card. Use of options besides `STANDARD` require additional @@ -174,7 +279,7 @@ constructor( * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with * tracking */ - fun shippingMethod(shippingMethod: ShippingMethod?) = apply { + fun shippingMethod(shippingMethod: JsonField) = apply { this.shippingMethod = shippingMethod } @@ -256,15 +361,45 @@ constructor( body.shippingAddress(shippingAddress) } + /** The shipping address this card will be sent to. */ + fun shippingAddress(shippingAddress: JsonField) = apply { + body.shippingAddress(shippingAddress) + } + + /** If omitted, the previous carrier will be used. */ + fun carrier(carrier: Carrier) = apply { body.carrier(carrier) } + /** If omitted, the previous carrier will be used. */ - fun carrier(carrier: Carrier?) = apply { body.carrier(carrier) } + fun carrier(carrier: JsonField) = apply { body.carrier(carrier) } + + /** + * Specifies the configuration (e.g. physical card art) that the card should be manufactured + * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic + * before use. + */ + fun productId(productId: String) = apply { body.productId(productId) } /** * Specifies the configuration (e.g. physical card art) that the card should be manufactured * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic * before use. */ - fun productId(productId: String?) = apply { body.productId(productId) } + fun productId(productId: JsonField) = apply { body.productId(productId) } + + /** + * Shipping method for the card. Use of options besides `STANDARD` require additional + * permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with + * tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking + */ + fun shippingMethod(shippingMethod: ShippingMethod) = apply { + body.shippingMethod(shippingMethod) + } /** * Shipping method for the card. Use of options besides `STANDARD` require additional @@ -277,10 +412,29 @@ constructor( * - `2_DAY` - FedEx 2-day shipping, with tracking * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking */ - fun shippingMethod(shippingMethod: ShippingMethod?) = apply { + fun shippingMethod(shippingMethod: JsonField) = apply { body.shippingMethod(shippingMethod) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -379,25 +533,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): CardConvertPhysicalParams = CardConvertPhysicalParams( checkNotNull(cardToken) { "`cardToken` is required but was not set" }, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardCreateParams.kt index e9c1beff..791c31e9 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardCreateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -158,12 +159,141 @@ constructor( */ fun state(): State? = body.state() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * Card types: + * - `VIRTUAL` - Card will authorize at any merchant and can be added to a digital wallet like + * Apple Pay or Google Pay (if the card program is digital wallet-enabled). + * - `PHYSICAL` - Manufactured and sent to the cardholder. We offer white label branding, + * credit, ATM, PIN debit, chip/EMV, NFC and magstripe functionality. Reach out at + * [lithic.com/contact](https://lithic.com/contact) for more information. + * - `SINGLE_USE` - Card is closed upon first successful authorization. + * - `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that successfully + * authorizes the card. + * - `UNLOCKED` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use VIRTUAL instead. + * - `DIGITAL_WALLET` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use VIRTUAL + * instead. + */ + fun _type(): JsonField = body._type() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Globally unique identifier for the account that the card will be associated with. Required + * for programs enrolling users using the + * [/account_holders endpoint](https://docs.lithic.com/docs/account-holders-kyc). See + * [Managing Your Program](doc:managing-your-program) for more information. + */ + fun _accountToken(): JsonField = body._accountToken() + + /** + * For card programs with more than one BIN range. This must be configured with Lithic before + * use. Identifies the card program/BIN range under which to create the card. If omitted, will + * utilize the program's default `card_program_token`. In Sandbox, use + * 00000000-0000-0000-1000-000000000000 and 00000000-0000-0000-2000-000000000000 to test + * creating cards on specific card programs. + */ + fun _cardProgramToken(): JsonField = body._cardProgramToken() + + fun _carrier(): JsonField = body._carrier() + + /** + * Specifies the digital card art to be displayed in the user’s digital wallet after + * tokenization. This artwork must be approved by Mastercard and configured by Lithic to use. + * See + * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). + */ + fun _digitalCardArtToken(): JsonField = body._digitalCardArtToken() + + /** + * Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an expiration + * date will be generated. + */ + fun _expMonth(): JsonField = body._expMonth() + + /** + * Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an + * expiration date will be generated. + */ + fun _expYear(): JsonField = body._expYear() + + /** Friendly name to identify the card. */ + fun _memo(): JsonField = body._memo() + + /** + * Encrypted PIN block (in base64). Applies to cards of type `PHYSICAL` and `VIRTUAL`. See + * [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block). + */ + fun _pin(): JsonField = body._pin() + + /** + * Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic before use. + * Specifies the configuration (i.e., physical card art) that the card should be manufactured + * with. + */ + fun _productId(): JsonField = body._productId() + + /** + * Restricted field limited to select use cases. Lithic will reach out directly if this field + * should be used. Globally unique identifier for the replacement card's account. If this field + * is specified, `replacement_for` must also be specified. If `replacement_for` is specified and + * this field is omitted, the replacement card's account will be inferred from the card being + * replaced. + */ + fun _replacementAccountToken(): JsonField = body._replacementAccountToken() + + /** + * Globally unique identifier for the card that this card will replace. If the card type is + * `PHYSICAL` it will be replaced by a `PHYSICAL` card. If the card type is `VIRTUAL` it will be + * replaced by a `VIRTUAL` card. + */ + fun _replacementFor(): JsonField = body._replacementFor() + + fun _shippingAddress(): JsonField = body._shippingAddress() + + /** + * Shipping method for the card. Only applies to cards of type PHYSICAL. Use of options besides + * `STANDARD` require additional permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking + */ + fun _shippingMethod(): JsonField = body._shippingMethod() + + /** + * Amount (in cents) to limit approved authorizations. Transaction requests above the spend + * limit will be declined. Note that a spend limit of 0 is effectively no limit, and should only + * be used to reset or remove a prior limit. Only a limit of 1 or above will result in declined + * transactions due to checks against the card limit. + */ + fun _spendLimit(): JsonField = body._spendLimit() + + /** + * Spend limit duration values: + * - `ANNUALLY` - Card will authorize transactions up to spend limit for the trailing year. + * - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime of the card. + * - `MONTHLY` - Card will authorize transactions up to spend limit for the trailing month. To + * support recurring monthly payments, which can occur on different day every month, the time + * window we consider for monthly velocity starts 6 days after the current calendar date one + * month prior. + * - `TRANSACTION` - Card will authorize multiple transactions if each individual transaction is + * under the spend limit. + */ + fun _spendLimitDuration(): JsonField = body._spendLimitDuration() + + /** + * Card state values: + * - `OPEN` - Card will approve authorizations (if they match card and account parameters). + * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. + */ + fun _state(): JsonField = body._state() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): CardCreateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -174,23 +304,53 @@ constructor( class CardCreateBody @JsonCreator internal constructor( - @JsonProperty("type") private val type: Type, - @JsonProperty("account_token") private val accountToken: String?, - @JsonProperty("card_program_token") private val cardProgramToken: String?, - @JsonProperty("carrier") private val carrier: Carrier?, - @JsonProperty("digital_card_art_token") private val digitalCardArtToken: String?, - @JsonProperty("exp_month") private val expMonth: String?, - @JsonProperty("exp_year") private val expYear: String?, - @JsonProperty("memo") private val memo: String?, - @JsonProperty("pin") private val pin: String?, - @JsonProperty("product_id") private val productId: String?, - @JsonProperty("replacement_account_token") private val replacementAccountToken: String?, - @JsonProperty("replacement_for") private val replacementFor: String?, - @JsonProperty("shipping_address") private val shippingAddress: ShippingAddress?, - @JsonProperty("shipping_method") private val shippingMethod: ShippingMethod?, - @JsonProperty("spend_limit") private val spendLimit: Long?, - @JsonProperty("spend_limit_duration") private val spendLimitDuration: SpendLimitDuration?, - @JsonProperty("state") private val state: State?, + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + private val accountToken: JsonField = JsonMissing.of(), + @JsonProperty("card_program_token") + @ExcludeMissing + private val cardProgramToken: JsonField = JsonMissing.of(), + @JsonProperty("carrier") + @ExcludeMissing + private val carrier: JsonField = JsonMissing.of(), + @JsonProperty("digital_card_art_token") + @ExcludeMissing + private val digitalCardArtToken: JsonField = JsonMissing.of(), + @JsonProperty("exp_month") + @ExcludeMissing + private val expMonth: JsonField = JsonMissing.of(), + @JsonProperty("exp_year") + @ExcludeMissing + private val expYear: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), + @JsonProperty("pin") @ExcludeMissing private val pin: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + private val productId: JsonField = JsonMissing.of(), + @JsonProperty("replacement_account_token") + @ExcludeMissing + private val replacementAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("replacement_for") + @ExcludeMissing + private val replacementFor: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + private val shippingAddress: JsonField = JsonMissing.of(), + @JsonProperty("shipping_method") + @ExcludeMissing + private val shippingMethod: JsonField = JsonMissing.of(), + @JsonProperty("spend_limit") + @ExcludeMissing + private val spendLimit: JsonField = JsonMissing.of(), + @JsonProperty("spend_limit_duration") + @ExcludeMissing + private val spendLimitDuration: JsonField = JsonMissing.of(), + @JsonProperty("state") + @ExcludeMissing + private val state: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -210,7 +370,7 @@ constructor( * - `DIGITAL_WALLET` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use VIRTUAL * instead. */ - @JsonProperty("type") fun type(): Type = type + fun type(): Type = type.getRequired("type") /** * Globally unique identifier for the account that the card will be associated with. @@ -218,7 +378,7 @@ constructor( * [/account_holders endpoint](https://docs.lithic.com/docs/account-holders-kyc). See * [Managing Your Program](doc:managing-your-program) for more information. */ - @JsonProperty("account_token") fun accountToken(): String? = accountToken + fun accountToken(): String? = accountToken.getNullable("account_token") /** * For card programs with more than one BIN range. This must be configured with Lithic @@ -227,9 +387,148 @@ constructor( * 00000000-0000-0000-1000-000000000000 and 00000000-0000-0000-2000-000000000000 to test * creating cards on specific card programs. */ - @JsonProperty("card_program_token") fun cardProgramToken(): String? = cardProgramToken + fun cardProgramToken(): String? = cardProgramToken.getNullable("card_program_token") - @JsonProperty("carrier") fun carrier(): Carrier? = carrier + fun carrier(): Carrier? = carrier.getNullable("carrier") + + /** + * Specifies the digital card art to be displayed in the user’s digital wallet after + * tokenization. This artwork must be approved by Mastercard and configured by Lithic to + * use. See + * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). + */ + fun digitalCardArtToken(): String? = + digitalCardArtToken.getNullable("digital_card_art_token") + + /** + * Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an + * expiration date will be generated. + */ + fun expMonth(): String? = expMonth.getNullable("exp_month") + + /** + * Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an + * expiration date will be generated. + */ + fun expYear(): String? = expYear.getNullable("exp_year") + + /** Friendly name to identify the card. */ + fun memo(): String? = memo.getNullable("memo") + + /** + * Encrypted PIN block (in base64). Applies to cards of type `PHYSICAL` and `VIRTUAL`. See + * [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block). + */ + fun pin(): String? = pin.getNullable("pin") + + /** + * Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic before + * use. Specifies the configuration (i.e., physical card art) that the card should be + * manufactured with. + */ + fun productId(): String? = productId.getNullable("product_id") + + /** + * Restricted field limited to select use cases. Lithic will reach out directly if this + * field should be used. Globally unique identifier for the replacement card's account. If + * this field is specified, `replacement_for` must also be specified. If `replacement_for` + * is specified and this field is omitted, the replacement card's account will be inferred + * from the card being replaced. + */ + fun replacementAccountToken(): String? = + replacementAccountToken.getNullable("replacement_account_token") + + /** + * Globally unique identifier for the card that this card will replace. If the card type is + * `PHYSICAL` it will be replaced by a `PHYSICAL` card. If the card type is `VIRTUAL` it + * will be replaced by a `VIRTUAL` card. + */ + fun replacementFor(): String? = replacementFor.getNullable("replacement_for") + + fun shippingAddress(): ShippingAddress? = shippingAddress.getNullable("shipping_address") + + /** + * Shipping method for the card. Only applies to cards of type PHYSICAL. Use of options + * besides `STANDARD` require additional permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with + * tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking + */ + fun shippingMethod(): ShippingMethod? = shippingMethod.getNullable("shipping_method") + + /** + * Amount (in cents) to limit approved authorizations. Transaction requests above the spend + * limit will be declined. Note that a spend limit of 0 is effectively no limit, and should + * only be used to reset or remove a prior limit. Only a limit of 1 or above will result in + * declined transactions due to checks against the card limit. + */ + fun spendLimit(): Long? = spendLimit.getNullable("spend_limit") + + /** + * Spend limit duration values: + * - `ANNUALLY` - Card will authorize transactions up to spend limit for the trailing year. + * - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime of the + * card. + * - `MONTHLY` - Card will authorize transactions up to spend limit for the trailing month. + * To support recurring monthly payments, which can occur on different day every month, + * the time window we consider for monthly velocity starts 6 days after the current + * calendar date one month prior. + * - `TRANSACTION` - Card will authorize multiple transactions if each individual + * transaction is under the spend limit. + */ + fun spendLimitDuration(): SpendLimitDuration? = + spendLimitDuration.getNullable("spend_limit_duration") + + /** + * Card state values: + * - `OPEN` - Card will approve authorizations (if they match card and account parameters). + * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. + */ + fun state(): State? = state.getNullable("state") + + /** + * Card types: + * - `VIRTUAL` - Card will authorize at any merchant and can be added to a digital wallet + * like Apple Pay or Google Pay (if the card program is digital wallet-enabled). + * - `PHYSICAL` - Manufactured and sent to the cardholder. We offer white label branding, + * credit, ATM, PIN debit, chip/EMV, NFC and magstripe functionality. Reach out at + * [lithic.com/contact](https://lithic.com/contact) for more information. + * - `SINGLE_USE` - Card is closed upon first successful authorization. + * - `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that + * successfully authorizes the card. + * - `UNLOCKED` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use VIRTUAL + * instead. + * - `DIGITAL_WALLET` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use VIRTUAL + * instead. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Globally unique identifier for the account that the card will be associated with. + * Required for programs enrolling users using the + * [/account_holders endpoint](https://docs.lithic.com/docs/account-holders-kyc). See + * [Managing Your Program](doc:managing-your-program) for more information. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * For card programs with more than one BIN range. This must be configured with Lithic + * before use. Identifies the card program/BIN range under which to create the card. If + * omitted, will utilize the program's default `card_program_token`. In Sandbox, use + * 00000000-0000-0000-1000-000000000000 and 00000000-0000-0000-2000-000000000000 to test + * creating cards on specific card programs. + */ + @JsonProperty("card_program_token") + @ExcludeMissing + fun _cardProgramToken(): JsonField = cardProgramToken + + @JsonProperty("carrier") @ExcludeMissing fun _carrier(): JsonField = carrier /** * Specifies the digital card art to be displayed in the user’s digital wallet after @@ -238,35 +537,36 @@ constructor( * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). */ @JsonProperty("digital_card_art_token") - fun digitalCardArtToken(): String? = digitalCardArtToken + @ExcludeMissing + fun _digitalCardArtToken(): JsonField = digitalCardArtToken /** * Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an * expiration date will be generated. */ - @JsonProperty("exp_month") fun expMonth(): String? = expMonth + @JsonProperty("exp_month") @ExcludeMissing fun _expMonth(): JsonField = expMonth /** * Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an * expiration date will be generated. */ - @JsonProperty("exp_year") fun expYear(): String? = expYear + @JsonProperty("exp_year") @ExcludeMissing fun _expYear(): JsonField = expYear /** Friendly name to identify the card. */ - @JsonProperty("memo") fun memo(): String? = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo /** * Encrypted PIN block (in base64). Applies to cards of type `PHYSICAL` and `VIRTUAL`. See * [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block). */ - @JsonProperty("pin") fun pin(): String? = pin + @JsonProperty("pin") @ExcludeMissing fun _pin(): JsonField = pin /** * Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic before * use. Specifies the configuration (i.e., physical card art) that the card should be * manufactured with. */ - @JsonProperty("product_id") fun productId(): String? = productId + @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId /** * Restricted field limited to select use cases. Lithic will reach out directly if this @@ -276,16 +576,21 @@ constructor( * from the card being replaced. */ @JsonProperty("replacement_account_token") - fun replacementAccountToken(): String? = replacementAccountToken + @ExcludeMissing + fun _replacementAccountToken(): JsonField = replacementAccountToken /** * Globally unique identifier for the card that this card will replace. If the card type is * `PHYSICAL` it will be replaced by a `PHYSICAL` card. If the card type is `VIRTUAL` it * will be replaced by a `VIRTUAL` card. */ - @JsonProperty("replacement_for") fun replacementFor(): String? = replacementFor + @JsonProperty("replacement_for") + @ExcludeMissing + fun _replacementFor(): JsonField = replacementFor - @JsonProperty("shipping_address") fun shippingAddress(): ShippingAddress? = shippingAddress + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress /** * Shipping method for the card. Only applies to cards of type PHYSICAL. Use of options @@ -298,7 +603,9 @@ constructor( * - `2_DAY` - FedEx 2-day shipping, with tracking * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking */ - @JsonProperty("shipping_method") fun shippingMethod(): ShippingMethod? = shippingMethod + @JsonProperty("shipping_method") + @ExcludeMissing + fun _shippingMethod(): JsonField = shippingMethod /** * Amount (in cents) to limit approved authorizations. Transaction requests above the spend @@ -306,7 +613,7 @@ constructor( * only be used to reset or remove a prior limit. Only a limit of 1 or above will result in * declined transactions due to checks against the card limit. */ - @JsonProperty("spend_limit") fun spendLimit(): Long? = spendLimit + @JsonProperty("spend_limit") @ExcludeMissing fun _spendLimit(): JsonField = spendLimit /** * Spend limit duration values: @@ -321,19 +628,45 @@ constructor( * transaction is under the spend limit. */ @JsonProperty("spend_limit_duration") - fun spendLimitDuration(): SpendLimitDuration? = spendLimitDuration + @ExcludeMissing + fun _spendLimitDuration(): JsonField = spendLimitDuration /** * Card state values: * - `OPEN` - Card will approve authorizations (if they match card and account parameters). * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. */ - @JsonProperty("state") fun state(): State? = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CardCreateBody = apply { + if (!validated) { + type() + accountToken() + cardProgramToken() + carrier()?.validate() + digitalCardArtToken() + expMonth() + expYear() + memo() + pin() + productId() + replacementAccountToken() + replacementFor() + shippingAddress()?.validate() + shippingMethod() + spendLimit() + spendLimitDuration() + state() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -343,23 +676,23 @@ constructor( class Builder { - private var type: Type? = null - private var accountToken: String? = null - private var cardProgramToken: String? = null - private var carrier: Carrier? = null - private var digitalCardArtToken: String? = null - private var expMonth: String? = null - private var expYear: String? = null - private var memo: String? = null - private var pin: String? = null - private var productId: String? = null - private var replacementAccountToken: String? = null - private var replacementFor: String? = null - private var shippingAddress: ShippingAddress? = null - private var shippingMethod: ShippingMethod? = null - private var spendLimit: Long? = null - private var spendLimitDuration: SpendLimitDuration? = null - private var state: State? = null + private var type: JsonField? = null + private var accountToken: JsonField = JsonMissing.of() + private var cardProgramToken: JsonField = JsonMissing.of() + private var carrier: JsonField = JsonMissing.of() + private var digitalCardArtToken: JsonField = JsonMissing.of() + private var expMonth: JsonField = JsonMissing.of() + private var expYear: JsonField = JsonMissing.of() + private var memo: JsonField = JsonMissing.of() + private var pin: JsonField = JsonMissing.of() + private var productId: JsonField = JsonMissing.of() + private var replacementAccountToken: JsonField = JsonMissing.of() + private var replacementFor: JsonField = JsonMissing.of() + private var shippingAddress: JsonField = JsonMissing.of() + private var shippingMethod: JsonField = JsonMissing.of() + private var spendLimit: JsonField = JsonMissing.of() + private var spendLimitDuration: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cardCreateBody: CardCreateBody) = apply { @@ -399,7 +732,25 @@ constructor( * - `DIGITAL_WALLET` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use * VIRTUAL instead. */ - fun type(type: Type) = apply { this.type = type } + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Card types: + * - `VIRTUAL` - Card will authorize at any merchant and can be added to a digital + * wallet like Apple Pay or Google Pay (if the card program is digital + * wallet-enabled). + * - `PHYSICAL` - Manufactured and sent to the cardholder. We offer white label + * branding, credit, ATM, PIN debit, chip/EMV, NFC and magstripe functionality. Reach + * out at [lithic.com/contact](https://lithic.com/contact) for more information. + * - `SINGLE_USE` - Card is closed upon first successful authorization. + * - `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that + * successfully authorizes the card. + * - `UNLOCKED` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use VIRTUAL + * instead. + * - `DIGITAL_WALLET` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use + * VIRTUAL instead. + */ + fun type(type: JsonField) = apply { this.type = type } /** * Globally unique identifier for the account that the card will be associated with. @@ -407,7 +758,27 @@ constructor( * [/account_holders endpoint](https://docs.lithic.com/docs/account-holders-kyc). See * [Managing Your Program](doc:managing-your-program) for more information. */ - fun accountToken(accountToken: String?) = apply { this.accountToken = accountToken } + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Globally unique identifier for the account that the card will be associated with. + * Required for programs enrolling users using the + * [/account_holders endpoint](https://docs.lithic.com/docs/account-holders-kyc). See + * [Managing Your Program](doc:managing-your-program) for more information. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** + * For card programs with more than one BIN range. This must be configured with Lithic + * before use. Identifies the card program/BIN range under which to create the card. If + * omitted, will utilize the program's default `card_program_token`. In Sandbox, use + * 00000000-0000-0000-1000-000000000000 and 00000000-0000-0000-2000-000000000000 to test + * creating cards on specific card programs. + */ + fun cardProgramToken(cardProgramToken: String) = + cardProgramToken(JsonField.of(cardProgramToken)) /** * For card programs with more than one BIN range. This must be configured with Lithic @@ -416,11 +787,22 @@ constructor( * 00000000-0000-0000-1000-000000000000 and 00000000-0000-0000-2000-000000000000 to test * creating cards on specific card programs. */ - fun cardProgramToken(cardProgramToken: String?) = apply { + fun cardProgramToken(cardProgramToken: JsonField) = apply { this.cardProgramToken = cardProgramToken } - fun carrier(carrier: Carrier?) = apply { this.carrier = carrier } + fun carrier(carrier: Carrier) = carrier(JsonField.of(carrier)) + + fun carrier(carrier: JsonField) = apply { this.carrier = carrier } + + /** + * Specifies the digital card art to be displayed in the user’s digital wallet after + * tokenization. This artwork must be approved by Mastercard and configured by Lithic to + * use. See + * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). + */ + fun digitalCardArtToken(digitalCardArtToken: String) = + digitalCardArtToken(JsonField.of(digitalCardArtToken)) /** * Specifies the digital card art to be displayed in the user’s digital wallet after @@ -428,7 +810,7 @@ constructor( * use. See * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). */ - fun digitalCardArtToken(digitalCardArtToken: String?) = apply { + fun digitalCardArtToken(digitalCardArtToken: JsonField) = apply { this.digitalCardArtToken = digitalCardArtToken } @@ -436,29 +818,67 @@ constructor( * Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an * expiration date will be generated. */ - fun expMonth(expMonth: String?) = apply { this.expMonth = expMonth } + fun expMonth(expMonth: String) = expMonth(JsonField.of(expMonth)) + + /** + * Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an + * expiration date will be generated. + */ + fun expMonth(expMonth: JsonField) = apply { this.expMonth = expMonth } + + /** + * Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an + * expiration date will be generated. + */ + fun expYear(expYear: String) = expYear(JsonField.of(expYear)) /** * Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an * expiration date will be generated. */ - fun expYear(expYear: String?) = apply { this.expYear = expYear } + fun expYear(expYear: JsonField) = apply { this.expYear = expYear } + + /** Friendly name to identify the card. */ + fun memo(memo: String) = memo(JsonField.of(memo)) /** Friendly name to identify the card. */ - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: JsonField) = apply { this.memo = memo } + + /** + * Encrypted PIN block (in base64). Applies to cards of type `PHYSICAL` and `VIRTUAL`. + * See [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block). + */ + fun pin(pin: String) = pin(JsonField.of(pin)) /** * Encrypted PIN block (in base64). Applies to cards of type `PHYSICAL` and `VIRTUAL`. * See [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block). */ - fun pin(pin: String?) = apply { this.pin = pin } + fun pin(pin: JsonField) = apply { this.pin = pin } + + /** + * Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic + * before use. Specifies the configuration (i.e., physical card art) that the card + * should be manufactured with. + */ + fun productId(productId: String) = productId(JsonField.of(productId)) /** * Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic * before use. Specifies the configuration (i.e., physical card art) that the card * should be manufactured with. */ - fun productId(productId: String?) = apply { this.productId = productId } + fun productId(productId: JsonField) = apply { this.productId = productId } + + /** + * Restricted field limited to select use cases. Lithic will reach out directly if this + * field should be used. Globally unique identifier for the replacement card's account. + * If this field is specified, `replacement_for` must also be specified. If + * `replacement_for` is specified and this field is omitted, the replacement card's + * account will be inferred from the card being replaced. + */ + fun replacementAccountToken(replacementAccountToken: String) = + replacementAccountToken(JsonField.of(replacementAccountToken)) /** * Restricted field limited to select use cases. Lithic will reach out directly if this @@ -467,7 +887,7 @@ constructor( * `replacement_for` is specified and this field is omitted, the replacement card's * account will be inferred from the card being replaced. */ - fun replacementAccountToken(replacementAccountToken: String?) = apply { + fun replacementAccountToken(replacementAccountToken: JsonField) = apply { this.replacementAccountToken = replacementAccountToken } @@ -476,11 +896,22 @@ constructor( * is `PHYSICAL` it will be replaced by a `PHYSICAL` card. If the card type is `VIRTUAL` * it will be replaced by a `VIRTUAL` card. */ - fun replacementFor(replacementFor: String?) = apply { + fun replacementFor(replacementFor: String) = + replacementFor(JsonField.of(replacementFor)) + + /** + * Globally unique identifier for the card that this card will replace. If the card type + * is `PHYSICAL` it will be replaced by a `PHYSICAL` card. If the card type is `VIRTUAL` + * it will be replaced by a `VIRTUAL` card. + */ + fun replacementFor(replacementFor: JsonField) = apply { this.replacementFor = replacementFor } - fun shippingAddress(shippingAddress: ShippingAddress?) = apply { + fun shippingAddress(shippingAddress: ShippingAddress) = + shippingAddress(JsonField.of(shippingAddress)) + + fun shippingAddress(shippingAddress: JsonField) = apply { this.shippingAddress = shippingAddress } @@ -496,7 +927,22 @@ constructor( * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with * tracking */ - fun shippingMethod(shippingMethod: ShippingMethod?) = apply { + fun shippingMethod(shippingMethod: ShippingMethod) = + shippingMethod(JsonField.of(shippingMethod)) + + /** + * Shipping method for the card. Only applies to cards of type PHYSICAL. Use of options + * besides `STANDARD` require additional permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with + * tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with + * tracking + */ + fun shippingMethod(shippingMethod: JsonField) = apply { this.shippingMethod = shippingMethod } @@ -506,7 +952,7 @@ constructor( * and should only be used to reset or remove a prior limit. Only a limit of 1 or above * will result in declined transactions due to checks against the card limit. */ - fun spendLimit(spendLimit: Long?) = apply { this.spendLimit = spendLimit } + fun spendLimit(spendLimit: Long) = spendLimit(JsonField.of(spendLimit)) /** * Amount (in cents) to limit approved authorizations. Transaction requests above the @@ -514,7 +960,23 @@ constructor( * and should only be used to reset or remove a prior limit. Only a limit of 1 or above * will result in declined transactions due to checks against the card limit. */ - fun spendLimit(spendLimit: Long) = spendLimit(spendLimit as Long?) + fun spendLimit(spendLimit: JsonField) = apply { this.spendLimit = spendLimit } + + /** + * Spend limit duration values: + * - `ANNUALLY` - Card will authorize transactions up to spend limit for the trailing + * year. + * - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime of + * the card. + * - `MONTHLY` - Card will authorize transactions up to spend limit for the trailing + * month. To support recurring monthly payments, which can occur on different day + * every month, the time window we consider for monthly velocity starts 6 days after + * the current calendar date one month prior. + * - `TRANSACTION` - Card will authorize multiple transactions if each individual + * transaction is under the spend limit. + */ + fun spendLimitDuration(spendLimitDuration: SpendLimitDuration) = + spendLimitDuration(JsonField.of(spendLimitDuration)) /** * Spend limit duration values: @@ -529,7 +991,7 @@ constructor( * - `TRANSACTION` - Card will authorize multiple transactions if each individual * transaction is under the spend limit. */ - fun spendLimitDuration(spendLimitDuration: SpendLimitDuration?) = apply { + fun spendLimitDuration(spendLimitDuration: JsonField) = apply { this.spendLimitDuration = spendLimitDuration } @@ -539,7 +1001,15 @@ constructor( * parameters). * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. */ - fun state(state: State?) = apply { this.state = state } + fun state(state: State) = state(JsonField.of(state)) + + /** + * Card state values: + * - `OPEN` - Card will approve authorizations (if they match card and account + * parameters). + * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. + */ + fun state(state: JsonField) = apply { this.state = state } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -638,13 +1108,51 @@ constructor( */ fun type(type: Type) = apply { body.type(type) } + /** + * Card types: + * - `VIRTUAL` - Card will authorize at any merchant and can be added to a digital wallet + * like Apple Pay or Google Pay (if the card program is digital wallet-enabled). + * - `PHYSICAL` - Manufactured and sent to the cardholder. We offer white label branding, + * credit, ATM, PIN debit, chip/EMV, NFC and magstripe functionality. Reach out at + * [lithic.com/contact](https://lithic.com/contact) for more information. + * - `SINGLE_USE` - Card is closed upon first successful authorization. + * - `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that + * successfully authorizes the card. + * - `UNLOCKED` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use VIRTUAL + * instead. + * - `DIGITAL_WALLET` - _[Deprecated]_ Similar behavior to VIRTUAL cards, please use VIRTUAL + * instead. + */ + fun type(type: JsonField) = apply { body.type(type) } + /** * Globally unique identifier for the account that the card will be associated with. * Required for programs enrolling users using the * [/account_holders endpoint](https://docs.lithic.com/docs/account-holders-kyc). See * [Managing Your Program](doc:managing-your-program) for more information. */ - fun accountToken(accountToken: String?) = apply { body.accountToken(accountToken) } + fun accountToken(accountToken: String) = apply { body.accountToken(accountToken) } + + /** + * Globally unique identifier for the account that the card will be associated with. + * Required for programs enrolling users using the + * [/account_holders endpoint](https://docs.lithic.com/docs/account-holders-kyc). See + * [Managing Your Program](doc:managing-your-program) for more information. + */ + fun accountToken(accountToken: JsonField) = apply { + body.accountToken(accountToken) + } + + /** + * For card programs with more than one BIN range. This must be configured with Lithic + * before use. Identifies the card program/BIN range under which to create the card. If + * omitted, will utilize the program's default `card_program_token`. In Sandbox, use + * 00000000-0000-0000-1000-000000000000 and 00000000-0000-0000-2000-000000000000 to test + * creating cards on specific card programs. + */ + fun cardProgramToken(cardProgramToken: String) = apply { + body.cardProgramToken(cardProgramToken) + } /** * For card programs with more than one BIN range. This must be configured with Lithic @@ -653,11 +1161,23 @@ constructor( * 00000000-0000-0000-1000-000000000000 and 00000000-0000-0000-2000-000000000000 to test * creating cards on specific card programs. */ - fun cardProgramToken(cardProgramToken: String?) = apply { + fun cardProgramToken(cardProgramToken: JsonField) = apply { body.cardProgramToken(cardProgramToken) } - fun carrier(carrier: Carrier?) = apply { body.carrier(carrier) } + fun carrier(carrier: Carrier) = apply { body.carrier(carrier) } + + fun carrier(carrier: JsonField) = apply { body.carrier(carrier) } + + /** + * Specifies the digital card art to be displayed in the user’s digital wallet after + * tokenization. This artwork must be approved by Mastercard and configured by Lithic to + * use. See + * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). + */ + fun digitalCardArtToken(digitalCardArtToken: String) = apply { + body.digitalCardArtToken(digitalCardArtToken) + } /** * Specifies the digital card art to be displayed in the user’s digital wallet after @@ -665,7 +1185,7 @@ constructor( * use. See * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). */ - fun digitalCardArtToken(digitalCardArtToken: String?) = apply { + fun digitalCardArtToken(digitalCardArtToken: JsonField) = apply { body.digitalCardArtToken(digitalCardArtToken) } @@ -673,29 +1193,68 @@ constructor( * Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an * expiration date will be generated. */ - fun expMonth(expMonth: String?) = apply { body.expMonth(expMonth) } + fun expMonth(expMonth: String) = apply { body.expMonth(expMonth) } + + /** + * Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an + * expiration date will be generated. + */ + fun expMonth(expMonth: JsonField) = apply { body.expMonth(expMonth) } + + /** + * Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an + * expiration date will be generated. + */ + fun expYear(expYear: String) = apply { body.expYear(expYear) } /** * Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an * expiration date will be generated. */ - fun expYear(expYear: String?) = apply { body.expYear(expYear) } + fun expYear(expYear: JsonField) = apply { body.expYear(expYear) } + + /** Friendly name to identify the card. */ + fun memo(memo: String) = apply { body.memo(memo) } /** Friendly name to identify the card. */ - fun memo(memo: String?) = apply { body.memo(memo) } + fun memo(memo: JsonField) = apply { body.memo(memo) } /** * Encrypted PIN block (in base64). Applies to cards of type `PHYSICAL` and `VIRTUAL`. See * [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block). */ - fun pin(pin: String?) = apply { body.pin(pin) } + fun pin(pin: String) = apply { body.pin(pin) } + + /** + * Encrypted PIN block (in base64). Applies to cards of type `PHYSICAL` and `VIRTUAL`. See + * [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block). + */ + fun pin(pin: JsonField) = apply { body.pin(pin) } + + /** + * Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic before + * use. Specifies the configuration (i.e., physical card art) that the card should be + * manufactured with. + */ + fun productId(productId: String) = apply { body.productId(productId) } /** * Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic before * use. Specifies the configuration (i.e., physical card art) that the card should be * manufactured with. */ - fun productId(productId: String?) = apply { body.productId(productId) } + fun productId(productId: JsonField) = apply { body.productId(productId) } + + /** + * Restricted field limited to select use cases. Lithic will reach out directly if this + * field should be used. Globally unique identifier for the replacement card's account. If + * this field is specified, `replacement_for` must also be specified. If `replacement_for` + * is specified and this field is omitted, the replacement card's account will be inferred + * from the card being replaced. + */ + fun replacementAccountToken(replacementAccountToken: String) = apply { + body.replacementAccountToken(replacementAccountToken) + } /** * Restricted field limited to select use cases. Lithic will reach out directly if this @@ -704,7 +1263,7 @@ constructor( * is specified and this field is omitted, the replacement card's account will be inferred * from the card being replaced. */ - fun replacementAccountToken(replacementAccountToken: String?) = apply { + fun replacementAccountToken(replacementAccountToken: JsonField) = apply { body.replacementAccountToken(replacementAccountToken) } @@ -713,12 +1272,40 @@ constructor( * `PHYSICAL` it will be replaced by a `PHYSICAL` card. If the card type is `VIRTUAL` it * will be replaced by a `VIRTUAL` card. */ - fun replacementFor(replacementFor: String?) = apply { body.replacementFor(replacementFor) } + fun replacementFor(replacementFor: String) = apply { body.replacementFor(replacementFor) } + + /** + * Globally unique identifier for the card that this card will replace. If the card type is + * `PHYSICAL` it will be replaced by a `PHYSICAL` card. If the card type is `VIRTUAL` it + * will be replaced by a `VIRTUAL` card. + */ + fun replacementFor(replacementFor: JsonField) = apply { + body.replacementFor(replacementFor) + } - fun shippingAddress(shippingAddress: ShippingAddress?) = apply { + fun shippingAddress(shippingAddress: ShippingAddress) = apply { body.shippingAddress(shippingAddress) } + fun shippingAddress(shippingAddress: JsonField) = apply { + body.shippingAddress(shippingAddress) + } + + /** + * Shipping method for the card. Only applies to cards of type PHYSICAL. Use of options + * besides `STANDARD` require additional permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with + * tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking + */ + fun shippingMethod(shippingMethod: ShippingMethod) = apply { + body.shippingMethod(shippingMethod) + } + /** * Shipping method for the card. Only applies to cards of type PHYSICAL. Use of options * besides `STANDARD` require additional permissions. @@ -730,7 +1317,7 @@ constructor( * - `2_DAY` - FedEx 2-day shipping, with tracking * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking */ - fun shippingMethod(shippingMethod: ShippingMethod?) = apply { + fun shippingMethod(shippingMethod: JsonField) = apply { body.shippingMethod(shippingMethod) } @@ -740,7 +1327,7 @@ constructor( * only be used to reset or remove a prior limit. Only a limit of 1 or above will result in * declined transactions due to checks against the card limit. */ - fun spendLimit(spendLimit: Long?) = apply { body.spendLimit(spendLimit) } + fun spendLimit(spendLimit: Long) = apply { body.spendLimit(spendLimit) } /** * Amount (in cents) to limit approved authorizations. Transaction requests above the spend @@ -748,7 +1335,23 @@ constructor( * only be used to reset or remove a prior limit. Only a limit of 1 or above will result in * declined transactions due to checks against the card limit. */ - fun spendLimit(spendLimit: Long) = spendLimit(spendLimit as Long?) + fun spendLimit(spendLimit: JsonField) = apply { body.spendLimit(spendLimit) } + + /** + * Spend limit duration values: + * - `ANNUALLY` - Card will authorize transactions up to spend limit for the trailing year. + * - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime of the + * card. + * - `MONTHLY` - Card will authorize transactions up to spend limit for the trailing month. + * To support recurring monthly payments, which can occur on different day every month, + * the time window we consider for monthly velocity starts 6 days after the current + * calendar date one month prior. + * - `TRANSACTION` - Card will authorize multiple transactions if each individual + * transaction is under the spend limit. + */ + fun spendLimitDuration(spendLimitDuration: SpendLimitDuration) = apply { + body.spendLimitDuration(spendLimitDuration) + } /** * Spend limit duration values: @@ -762,7 +1365,7 @@ constructor( * - `TRANSACTION` - Card will authorize multiple transactions if each individual * transaction is under the spend limit. */ - fun spendLimitDuration(spendLimitDuration: SpendLimitDuration?) = apply { + fun spendLimitDuration(spendLimitDuration: JsonField) = apply { body.spendLimitDuration(spendLimitDuration) } @@ -771,7 +1374,33 @@ constructor( * - `OPEN` - Card will approve authorizations (if they match card and account parameters). * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. */ - fun state(state: State?) = apply { body.state(state) } + fun state(state: State) = apply { body.state(state) } + + /** + * Card state values: + * - `OPEN` - Card will approve authorizations (if they match card and account parameters). + * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. + */ + fun state(state: JsonField) = apply { body.state(state) } + + 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() @@ -871,25 +1500,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): CardCreateParams = CardCreateParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProgram.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProgram.kt index 070d33c2..da19f9be 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProgram.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProgram.kt @@ -66,24 +66,28 @@ private constructor( settlementCurrencies.getNullable("settlement_currencies") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Timestamp of when the card program was created. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** The name of the card program. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The first digits of the card number that this card program ends with. */ - @JsonProperty("pan_range_end") @ExcludeMissing fun _panRangeEnd() = panRangeEnd + @JsonProperty("pan_range_end") + @ExcludeMissing + fun _panRangeEnd(): JsonField = panRangeEnd /** The first digits of the card number that this card program starts with. */ - @JsonProperty("pan_range_start") @ExcludeMissing fun _panRangeStart() = panRangeStart + @JsonProperty("pan_range_start") + @ExcludeMissing + fun _panRangeStart(): JsonField = panRangeStart /** 3-digit alphabetic ISO 4217 code for the currency of the cardholder. */ @JsonProperty("cardholder_currency") @ExcludeMissing - fun _cardholderCurrency() = cardholderCurrency + fun _cardholderCurrency(): JsonField = cardholderCurrency /** * List of 3-digit alphabetic ISO 4217 codes for the currencies that the card program supports @@ -91,7 +95,7 @@ private constructor( */ @JsonProperty("settlement_currencies") @ExcludeMissing - fun _settlementCurrencies() = settlementCurrencies + fun _settlementCurrencies(): JsonField> = settlementCurrencies @JsonAnyGetter @ExcludeMissing @@ -121,13 +125,13 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var panRangeEnd: JsonField = JsonMissing.of() - private var panRangeStart: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var created: JsonField? = null + private var name: JsonField? = null + private var panRangeEnd: JsonField? = null + private var panRangeStart: JsonField? = null private var cardholderCurrency: JsonField = JsonMissing.of() - private var settlementCurrencies: JsonField> = JsonMissing.of() + private var settlementCurrencies: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cardProgram: CardProgram) = apply { @@ -137,7 +141,7 @@ private constructor( panRangeEnd = cardProgram.panRangeEnd panRangeStart = cardProgram.panRangeStart cardholderCurrency = cardProgram.cardholderCurrency - settlementCurrencies = cardProgram.settlementCurrencies + settlementCurrencies = cardProgram.settlementCurrencies.map { it.toMutableList() } additionalProperties = cardProgram.additionalProperties.toMutableMap() } @@ -194,7 +198,22 @@ private constructor( * supports for settlement. */ fun settlementCurrencies(settlementCurrencies: JsonField>) = apply { - this.settlementCurrencies = settlementCurrencies + this.settlementCurrencies = settlementCurrencies.map { it.toMutableList() } + } + + /** + * List of 3-digit alphabetic ISO 4217 codes for the currencies that the card program + * supports for settlement. + */ + fun addSettlementCurrency(settlementCurrency: String) = apply { + settlementCurrencies = + (settlementCurrencies ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(settlementCurrency) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -218,13 +237,13 @@ private constructor( fun build(): CardProgram = CardProgram( - token, - created, - name, - panRangeEnd, - panRangeStart, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(panRangeEnd) { "`panRangeEnd` is required but was not set" }, + checkNotNull(panRangeStart) { "`panRangeStart` is required but was not set" }, cardholderCurrency, - settlementCurrencies.map { it.toImmutable() }, + (settlementCurrencies ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProvisionParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProvisionParams.kt index 069c18ff..2268e1d2 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProvisionParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProvisionParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -70,12 +71,46 @@ constructor( */ fun nonceSignature(): String? = body.nonceSignature() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only `activationData` in + * the response. Apple's public leaf certificate. Base64 encoded in PEM format with headers + * `(-----BEGIN CERTIFICATE-----)` and trailers omitted. Provided by the device's wallet. + */ + fun _certificate(): JsonField = body._certificate() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Only applicable if `digital_wallet` is `GOOGLE_PAY` or `SAMSUNG_PAY` and the card is on the + * Visa network. Stable device identification set by the wallet provider. + */ + fun _clientDeviceId(): JsonField = body._clientDeviceId() + + /** + * Only applicable if `digital_wallet` is `GOOGLE_PAY` or `SAMSUNG_PAY` and the card is on the + * Visa network. Consumer ID that identifies the wallet account holder entity. + */ + fun _clientWalletAccountId(): JsonField = body._clientWalletAccountId() + + /** Name of digital wallet provider. */ + fun _digitalWallet(): JsonField = body._digitalWallet() + + /** + * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only `activationData` in + * the response. Base64 cryptographic nonce provided by the device's wallet. + */ + fun _nonce(): JsonField = body._nonce() + + /** + * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only `activationData` in + * the response. Base64 cryptographic nonce provided by the device's wallet. + */ + fun _nonceSignature(): JsonField = body._nonceSignature() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): CardProvisionBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -93,12 +128,24 @@ constructor( class CardProvisionBody @JsonCreator internal constructor( - @JsonProperty("certificate") private val certificate: String?, - @JsonProperty("client_device_id") private val clientDeviceId: String?, - @JsonProperty("client_wallet_account_id") private val clientWalletAccountId: String?, - @JsonProperty("digital_wallet") private val digitalWallet: DigitalWallet?, - @JsonProperty("nonce") private val nonce: String?, - @JsonProperty("nonce_signature") private val nonceSignature: String?, + @JsonProperty("certificate") + @ExcludeMissing + private val certificate: JsonField = JsonMissing.of(), + @JsonProperty("client_device_id") + @ExcludeMissing + private val clientDeviceId: JsonField = JsonMissing.of(), + @JsonProperty("client_wallet_account_id") + @ExcludeMissing + private val clientWalletAccountId: JsonField = JsonMissing.of(), + @JsonProperty("digital_wallet") + @ExcludeMissing + private val digitalWallet: JsonField = JsonMissing.of(), + @JsonProperty("nonce") + @ExcludeMissing + private val nonce: JsonField = JsonMissing.of(), + @JsonProperty("nonce_signature") + @ExcludeMissing + private val nonceSignature: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -109,40 +156,99 @@ constructor( * headers `(-----BEGIN CERTIFICATE-----)` and trailers omitted. Provided by the device's * wallet. */ - @JsonProperty("certificate") fun certificate(): String? = certificate + fun certificate(): String? = certificate.getNullable("certificate") /** * Only applicable if `digital_wallet` is `GOOGLE_PAY` or `SAMSUNG_PAY` and the card is on * the Visa network. Stable device identification set by the wallet provider. */ - @JsonProperty("client_device_id") fun clientDeviceId(): String? = clientDeviceId + fun clientDeviceId(): String? = clientDeviceId.getNullable("client_device_id") + + /** + * Only applicable if `digital_wallet` is `GOOGLE_PAY` or `SAMSUNG_PAY` and the card is on + * the Visa network. Consumer ID that identifies the wallet account holder entity. + */ + fun clientWalletAccountId(): String? = + clientWalletAccountId.getNullable("client_wallet_account_id") + + /** Name of digital wallet provider. */ + fun digitalWallet(): DigitalWallet? = digitalWallet.getNullable("digital_wallet") + + /** + * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only `activationData` + * in the response. Base64 cryptographic nonce provided by the device's wallet. + */ + fun nonce(): String? = nonce.getNullable("nonce") + + /** + * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only `activationData` + * in the response. Base64 cryptographic nonce provided by the device's wallet. + */ + fun nonceSignature(): String? = nonceSignature.getNullable("nonce_signature") + + /** + * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only `activationData` + * in the response. Apple's public leaf certificate. Base64 encoded in PEM format with + * headers `(-----BEGIN CERTIFICATE-----)` and trailers omitted. Provided by the device's + * wallet. + */ + @JsonProperty("certificate") + @ExcludeMissing + fun _certificate(): JsonField = certificate + + /** + * Only applicable if `digital_wallet` is `GOOGLE_PAY` or `SAMSUNG_PAY` and the card is on + * the Visa network. Stable device identification set by the wallet provider. + */ + @JsonProperty("client_device_id") + @ExcludeMissing + fun _clientDeviceId(): JsonField = clientDeviceId /** * Only applicable if `digital_wallet` is `GOOGLE_PAY` or `SAMSUNG_PAY` and the card is on * the Visa network. Consumer ID that identifies the wallet account holder entity. */ @JsonProperty("client_wallet_account_id") - fun clientWalletAccountId(): String? = clientWalletAccountId + @ExcludeMissing + fun _clientWalletAccountId(): JsonField = clientWalletAccountId /** Name of digital wallet provider. */ - @JsonProperty("digital_wallet") fun digitalWallet(): DigitalWallet? = digitalWallet + @JsonProperty("digital_wallet") + @ExcludeMissing + fun _digitalWallet(): JsonField = digitalWallet /** * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only `activationData` * in the response. Base64 cryptographic nonce provided by the device's wallet. */ - @JsonProperty("nonce") fun nonce(): String? = nonce + @JsonProperty("nonce") @ExcludeMissing fun _nonce(): JsonField = nonce /** * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only `activationData` * in the response. Base64 cryptographic nonce provided by the device's wallet. */ - @JsonProperty("nonce_signature") fun nonceSignature(): String? = nonceSignature + @JsonProperty("nonce_signature") + @ExcludeMissing + fun _nonceSignature(): JsonField = nonceSignature @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CardProvisionBody = apply { + if (!validated) { + certificate() + clientDeviceId() + clientWalletAccountId() + digitalWallet() + nonce() + nonceSignature() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -152,12 +258,12 @@ constructor( class Builder { - private var certificate: String? = null - private var clientDeviceId: String? = null - private var clientWalletAccountId: String? = null - private var digitalWallet: DigitalWallet? = null - private var nonce: String? = null - private var nonceSignature: String? = null + private var certificate: JsonField = JsonMissing.of() + private var clientDeviceId: JsonField = JsonMissing.of() + private var clientWalletAccountId: JsonField = JsonMissing.of() + private var digitalWallet: JsonField = JsonMissing.of() + private var nonce: JsonField = JsonMissing.of() + private var nonceSignature: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cardProvisionBody: CardProvisionBody) = apply { @@ -176,13 +282,30 @@ constructor( * PEM format with headers `(-----BEGIN CERTIFICATE-----)` and trailers omitted. * Provided by the device's wallet. */ - fun certificate(certificate: String?) = apply { this.certificate = certificate } + fun certificate(certificate: String) = certificate(JsonField.of(certificate)) + + /** + * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only + * `activationData` in the response. Apple's public leaf certificate. Base64 encoded in + * PEM format with headers `(-----BEGIN CERTIFICATE-----)` and trailers omitted. + * Provided by the device's wallet. + */ + fun certificate(certificate: JsonField) = apply { + this.certificate = certificate + } /** * Only applicable if `digital_wallet` is `GOOGLE_PAY` or `SAMSUNG_PAY` and the card is * on the Visa network. Stable device identification set by the wallet provider. */ - fun clientDeviceId(clientDeviceId: String?) = apply { + fun clientDeviceId(clientDeviceId: String) = + clientDeviceId(JsonField.of(clientDeviceId)) + + /** + * Only applicable if `digital_wallet` is `GOOGLE_PAY` or `SAMSUNG_PAY` and the card is + * on the Visa network. Stable device identification set by the wallet provider. + */ + fun clientDeviceId(clientDeviceId: JsonField) = apply { this.clientDeviceId = clientDeviceId } @@ -190,12 +313,23 @@ constructor( * Only applicable if `digital_wallet` is `GOOGLE_PAY` or `SAMSUNG_PAY` and the card is * on the Visa network. Consumer ID that identifies the wallet account holder entity. */ - fun clientWalletAccountId(clientWalletAccountId: String?) = apply { + fun clientWalletAccountId(clientWalletAccountId: String) = + clientWalletAccountId(JsonField.of(clientWalletAccountId)) + + /** + * Only applicable if `digital_wallet` is `GOOGLE_PAY` or `SAMSUNG_PAY` and the card is + * on the Visa network. Consumer ID that identifies the wallet account holder entity. + */ + fun clientWalletAccountId(clientWalletAccountId: JsonField) = apply { this.clientWalletAccountId = clientWalletAccountId } /** Name of digital wallet provider. */ - fun digitalWallet(digitalWallet: DigitalWallet?) = apply { + fun digitalWallet(digitalWallet: DigitalWallet) = + digitalWallet(JsonField.of(digitalWallet)) + + /** Name of digital wallet provider. */ + fun digitalWallet(digitalWallet: JsonField) = apply { this.digitalWallet = digitalWallet } @@ -204,14 +338,29 @@ constructor( * `activationData` in the response. Base64 cryptographic nonce provided by the device's * wallet. */ - fun nonce(nonce: String?) = apply { this.nonce = nonce } + fun nonce(nonce: String) = nonce(JsonField.of(nonce)) + + /** + * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only + * `activationData` in the response. Base64 cryptographic nonce provided by the device's + * wallet. + */ + fun nonce(nonce: JsonField) = apply { this.nonce = nonce } /** * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only * `activationData` in the response. Base64 cryptographic nonce provided by the device's * wallet. */ - fun nonceSignature(nonceSignature: String?) = apply { + fun nonceSignature(nonceSignature: String) = + nonceSignature(JsonField.of(nonceSignature)) + + /** + * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only + * `activationData` in the response. Base64 cryptographic nonce provided by the device's + * wallet. + */ + fun nonceSignature(nonceSignature: JsonField) = apply { this.nonceSignature = nonceSignature } @@ -294,38 +443,100 @@ constructor( * headers `(-----BEGIN CERTIFICATE-----)` and trailers omitted. Provided by the device's * wallet. */ - fun certificate(certificate: String?) = apply { body.certificate(certificate) } + fun certificate(certificate: String) = apply { body.certificate(certificate) } + + /** + * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only `activationData` + * in the response. Apple's public leaf certificate. Base64 encoded in PEM format with + * headers `(-----BEGIN CERTIFICATE-----)` and trailers omitted. Provided by the device's + * wallet. + */ + fun certificate(certificate: JsonField) = apply { body.certificate(certificate) } + + /** + * Only applicable if `digital_wallet` is `GOOGLE_PAY` or `SAMSUNG_PAY` and the card is on + * the Visa network. Stable device identification set by the wallet provider. + */ + fun clientDeviceId(clientDeviceId: String) = apply { body.clientDeviceId(clientDeviceId) } /** * Only applicable if `digital_wallet` is `GOOGLE_PAY` or `SAMSUNG_PAY` and the card is on * the Visa network. Stable device identification set by the wallet provider. */ - fun clientDeviceId(clientDeviceId: String?) = apply { body.clientDeviceId(clientDeviceId) } + fun clientDeviceId(clientDeviceId: JsonField) = apply { + body.clientDeviceId(clientDeviceId) + } + + /** + * Only applicable if `digital_wallet` is `GOOGLE_PAY` or `SAMSUNG_PAY` and the card is on + * the Visa network. Consumer ID that identifies the wallet account holder entity. + */ + fun clientWalletAccountId(clientWalletAccountId: String) = apply { + body.clientWalletAccountId(clientWalletAccountId) + } /** * Only applicable if `digital_wallet` is `GOOGLE_PAY` or `SAMSUNG_PAY` and the card is on * the Visa network. Consumer ID that identifies the wallet account holder entity. */ - fun clientWalletAccountId(clientWalletAccountId: String?) = apply { + fun clientWalletAccountId(clientWalletAccountId: JsonField) = apply { body.clientWalletAccountId(clientWalletAccountId) } /** Name of digital wallet provider. */ - fun digitalWallet(digitalWallet: DigitalWallet?) = apply { + fun digitalWallet(digitalWallet: DigitalWallet) = apply { body.digitalWallet(digitalWallet) } + /** Name of digital wallet provider. */ + fun digitalWallet(digitalWallet: JsonField) = apply { + body.digitalWallet(digitalWallet) + } + + /** + * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only `activationData` + * in the response. Base64 cryptographic nonce provided by the device's wallet. + */ + fun nonce(nonce: String) = apply { body.nonce(nonce) } + + /** + * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only `activationData` + * in the response. Base64 cryptographic nonce provided by the device's wallet. + */ + fun nonce(nonce: JsonField) = apply { body.nonce(nonce) } + /** * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only `activationData` * in the response. Base64 cryptographic nonce provided by the device's wallet. */ - fun nonce(nonce: String?) = apply { body.nonce(nonce) } + fun nonceSignature(nonceSignature: String) = apply { body.nonceSignature(nonceSignature) } /** * Only applicable if `digital_wallet` is `APPLE_PAY`. Omit to receive only `activationData` * in the response. Base64 cryptographic nonce provided by the device's wallet. */ - fun nonceSignature(nonceSignature: String?) = apply { body.nonceSignature(nonceSignature) } + fun nonceSignature(nonceSignature: JsonField) = apply { + body.nonceSignature(nonceSignature) + } + + 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() @@ -425,25 +636,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): CardProvisionParams = CardProvisionParams( checkNotNull(cardToken) { "`cardToken` is required but was not set" }, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProvisionResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProvisionResponse.kt index 8317c7e8..486e09a0 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProvisionResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProvisionResponse.kt @@ -29,7 +29,7 @@ private constructor( @JsonProperty("provisioning_payload") @ExcludeMissing - fun _provisioningPayload() = provisioningPayload + fun _provisioningPayload(): JsonField = provisioningPayload @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardReissueParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardReissueParams.kt index 00ee4f36..d6f9b82e 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardReissueParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardReissueParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -59,12 +60,37 @@ constructor( */ fun shippingMethod(): ShippingMethod? = body.shippingMethod() - fun _additionalHeaders(): Headers = additionalHeaders + /** If omitted, the previous carrier will be used. */ + fun _carrier(): JsonField = body._carrier() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Specifies the configuration (e.g. physical card art) that the card should be manufactured + * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic + * before use. + */ + fun _productId(): JsonField = body._productId() + + /** If omitted, the previous shipping address will be used. */ + fun _shippingAddress(): JsonField = body._shippingAddress() + + /** + * Shipping method for the card. Use of options besides `STANDARD` require additional + * permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking + */ + fun _shippingMethod(): JsonField = body._shippingMethod() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): CardReissueBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -82,26 +108,62 @@ constructor( class CardReissueBody @JsonCreator internal constructor( - @JsonProperty("carrier") private val carrier: Carrier?, - @JsonProperty("product_id") private val productId: String?, - @JsonProperty("shipping_address") private val shippingAddress: ShippingAddress?, - @JsonProperty("shipping_method") private val shippingMethod: ShippingMethod?, + @JsonProperty("carrier") + @ExcludeMissing + private val carrier: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + private val productId: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + private val shippingAddress: JsonField = JsonMissing.of(), + @JsonProperty("shipping_method") + @ExcludeMissing + private val shippingMethod: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** If omitted, the previous carrier will be used. */ - @JsonProperty("carrier") fun carrier(): Carrier? = carrier + fun carrier(): Carrier? = carrier.getNullable("carrier") + + /** + * Specifies the configuration (e.g. physical card art) that the card should be manufactured + * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic + * before use. + */ + fun productId(): String? = productId.getNullable("product_id") + + /** If omitted, the previous shipping address will be used. */ + fun shippingAddress(): ShippingAddress? = shippingAddress.getNullable("shipping_address") + + /** + * Shipping method for the card. Use of options besides `STANDARD` require additional + * permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with + * tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking + */ + fun shippingMethod(): ShippingMethod? = shippingMethod.getNullable("shipping_method") + + /** If omitted, the previous carrier will be used. */ + @JsonProperty("carrier") @ExcludeMissing fun _carrier(): JsonField = carrier /** * Specifies the configuration (e.g. physical card art) that the card should be manufactured * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic * before use. */ - @JsonProperty("product_id") fun productId(): String? = productId + @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId /** If omitted, the previous shipping address will be used. */ - @JsonProperty("shipping_address") fun shippingAddress(): ShippingAddress? = shippingAddress + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress /** * Shipping method for the card. Use of options besides `STANDARD` require additional @@ -114,12 +176,26 @@ constructor( * - `2_DAY` - FedEx 2-day shipping, with tracking * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking */ - @JsonProperty("shipping_method") fun shippingMethod(): ShippingMethod? = shippingMethod + @JsonProperty("shipping_method") + @ExcludeMissing + fun _shippingMethod(): JsonField = shippingMethod @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CardReissueBody = apply { + if (!validated) { + carrier()?.validate() + productId() + shippingAddress()?.validate() + shippingMethod() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -129,10 +205,10 @@ constructor( class Builder { - private var carrier: Carrier? = null - private var productId: String? = null - private var shippingAddress: ShippingAddress? = null - private var shippingMethod: ShippingMethod? = null + private var carrier: JsonField = JsonMissing.of() + private var productId: JsonField = JsonMissing.of() + private var shippingAddress: JsonField = JsonMissing.of() + private var shippingMethod: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cardReissueBody: CardReissueBody) = apply { @@ -144,17 +220,31 @@ constructor( } /** If omitted, the previous carrier will be used. */ - fun carrier(carrier: Carrier?) = apply { this.carrier = carrier } + fun carrier(carrier: Carrier) = carrier(JsonField.of(carrier)) + + /** If omitted, the previous carrier will be used. */ + fun carrier(carrier: JsonField) = apply { this.carrier = carrier } + + /** + * Specifies the configuration (e.g. physical card art) that the card should be + * manufactured with, and only applies to cards of type `PHYSICAL`. This must be + * configured with Lithic before use. + */ + fun productId(productId: String) = productId(JsonField.of(productId)) /** * Specifies the configuration (e.g. physical card art) that the card should be * manufactured with, and only applies to cards of type `PHYSICAL`. This must be * configured with Lithic before use. */ - fun productId(productId: String?) = apply { this.productId = productId } + fun productId(productId: JsonField) = apply { this.productId = productId } /** If omitted, the previous shipping address will be used. */ - fun shippingAddress(shippingAddress: ShippingAddress?) = apply { + fun shippingAddress(shippingAddress: ShippingAddress) = + shippingAddress(JsonField.of(shippingAddress)) + + /** If omitted, the previous shipping address will be used. */ + fun shippingAddress(shippingAddress: JsonField) = apply { this.shippingAddress = shippingAddress } @@ -170,7 +260,22 @@ constructor( * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with * tracking */ - fun shippingMethod(shippingMethod: ShippingMethod?) = apply { + fun shippingMethod(shippingMethod: ShippingMethod) = + shippingMethod(JsonField.of(shippingMethod)) + + /** + * Shipping method for the card. Use of options besides `STANDARD` require additional + * permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with + * tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with + * tracking + */ + fun shippingMethod(shippingMethod: JsonField) = apply { this.shippingMethod = shippingMethod } @@ -246,17 +351,32 @@ constructor( fun cardToken(cardToken: String) = apply { this.cardToken = cardToken } /** If omitted, the previous carrier will be used. */ - fun carrier(carrier: Carrier?) = apply { body.carrier(carrier) } + fun carrier(carrier: Carrier) = apply { body.carrier(carrier) } + + /** If omitted, the previous carrier will be used. */ + fun carrier(carrier: JsonField) = apply { body.carrier(carrier) } /** * Specifies the configuration (e.g. physical card art) that the card should be manufactured * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic * before use. */ - fun productId(productId: String?) = apply { body.productId(productId) } + fun productId(productId: String) = apply { body.productId(productId) } + + /** + * Specifies the configuration (e.g. physical card art) that the card should be manufactured + * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic + * before use. + */ + fun productId(productId: JsonField) = apply { body.productId(productId) } + + /** If omitted, the previous shipping address will be used. */ + fun shippingAddress(shippingAddress: ShippingAddress) = apply { + body.shippingAddress(shippingAddress) + } /** If omitted, the previous shipping address will be used. */ - fun shippingAddress(shippingAddress: ShippingAddress?) = apply { + fun shippingAddress(shippingAddress: JsonField) = apply { body.shippingAddress(shippingAddress) } @@ -271,10 +391,44 @@ constructor( * - `2_DAY` - FedEx 2-day shipping, with tracking * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking */ - fun shippingMethod(shippingMethod: ShippingMethod?) = apply { + fun shippingMethod(shippingMethod: ShippingMethod) = apply { + body.shippingMethod(shippingMethod) + } + + /** + * Shipping method for the card. Use of options besides `STANDARD` require additional + * permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with + * tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking + */ + fun shippingMethod(shippingMethod: JsonField) = apply { body.shippingMethod(shippingMethod) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -373,25 +527,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): CardReissueParams = CardReissueParams( checkNotNull(cardToken) { "`cardToken` is required but was not set" }, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardRenewParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardRenewParams.kt index 7786ac4a..fd17903d 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardRenewParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardRenewParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -72,12 +73,49 @@ constructor( */ fun shippingMethod(): ShippingMethod? = body.shippingMethod() - fun _additionalHeaders(): Headers = additionalHeaders + /** The shipping address this card will be sent to. */ + fun _shippingAddress(): JsonField = body._shippingAddress() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** If omitted, the previous carrier will be used. */ + fun _carrier(): JsonField = body._carrier() + + /** + * Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an expiration + * date six years in the future will be generated. + */ + fun _expMonth(): JsonField = body._expMonth() + + /** + * Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an + * expiration date six years in the future will be generated. + */ + fun _expYear(): JsonField = body._expYear() + + /** + * Specifies the configuration (e.g. physical card art) that the card should be manufactured + * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic + * before use. + */ + fun _productId(): JsonField = body._productId() + + /** + * Shipping method for the card. Use of options besides `STANDARD` require additional + * permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking + */ + fun _shippingMethod(): JsonField = body._shippingMethod() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): CardRenewBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -95,40 +133,52 @@ constructor( class CardRenewBody @JsonCreator internal constructor( - @JsonProperty("shipping_address") private val shippingAddress: ShippingAddress, - @JsonProperty("carrier") private val carrier: Carrier?, - @JsonProperty("exp_month") private val expMonth: String?, - @JsonProperty("exp_year") private val expYear: String?, - @JsonProperty("product_id") private val productId: String?, - @JsonProperty("shipping_method") private val shippingMethod: ShippingMethod?, + @JsonProperty("shipping_address") + @ExcludeMissing + private val shippingAddress: JsonField = JsonMissing.of(), + @JsonProperty("carrier") + @ExcludeMissing + private val carrier: JsonField = JsonMissing.of(), + @JsonProperty("exp_month") + @ExcludeMissing + private val expMonth: JsonField = JsonMissing.of(), + @JsonProperty("exp_year") + @ExcludeMissing + private val expYear: JsonField = JsonMissing.of(), + @JsonProperty("product_id") + @ExcludeMissing + private val productId: JsonField = JsonMissing.of(), + @JsonProperty("shipping_method") + @ExcludeMissing + private val shippingMethod: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The shipping address this card will be sent to. */ - @JsonProperty("shipping_address") fun shippingAddress(): ShippingAddress = shippingAddress + fun shippingAddress(): ShippingAddress = shippingAddress.getRequired("shipping_address") /** If omitted, the previous carrier will be used. */ - @JsonProperty("carrier") fun carrier(): Carrier? = carrier + fun carrier(): Carrier? = carrier.getNullable("carrier") /** * Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an * expiration date six years in the future will be generated. */ - @JsonProperty("exp_month") fun expMonth(): String? = expMonth + fun expMonth(): String? = expMonth.getNullable("exp_month") /** * Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an * expiration date six years in the future will be generated. */ - @JsonProperty("exp_year") fun expYear(): String? = expYear + fun expYear(): String? = expYear.getNullable("exp_year") /** * Specifies the configuration (e.g. physical card art) that the card should be manufactured * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic * before use. */ - @JsonProperty("product_id") fun productId(): String? = productId + fun productId(): String? = productId.getNullable("product_id") /** * Shipping method for the card. Use of options besides `STANDARD` require additional @@ -141,12 +191,68 @@ constructor( * - `2_DAY` - FedEx 2-day shipping, with tracking * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking */ - @JsonProperty("shipping_method") fun shippingMethod(): ShippingMethod? = shippingMethod + fun shippingMethod(): ShippingMethod? = shippingMethod.getNullable("shipping_method") + + /** The shipping address this card will be sent to. */ + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress + + /** If omitted, the previous carrier will be used. */ + @JsonProperty("carrier") @ExcludeMissing fun _carrier(): JsonField = carrier + + /** + * Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an + * expiration date six years in the future will be generated. + */ + @JsonProperty("exp_month") @ExcludeMissing fun _expMonth(): JsonField = expMonth + + /** + * Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an + * expiration date six years in the future will be generated. + */ + @JsonProperty("exp_year") @ExcludeMissing fun _expYear(): JsonField = expYear + + /** + * Specifies the configuration (e.g. physical card art) that the card should be manufactured + * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic + * before use. + */ + @JsonProperty("product_id") @ExcludeMissing fun _productId(): JsonField = productId + + /** + * Shipping method for the card. Use of options besides `STANDARD` require additional + * permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with + * tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking + */ + @JsonProperty("shipping_method") + @ExcludeMissing + fun _shippingMethod(): JsonField = shippingMethod @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CardRenewBody = apply { + if (!validated) { + shippingAddress().validate() + carrier()?.validate() + expMonth() + expYear() + productId() + shippingMethod() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -156,12 +262,12 @@ constructor( class Builder { - private var shippingAddress: ShippingAddress? = null - private var carrier: Carrier? = null - private var expMonth: String? = null - private var expYear: String? = null - private var productId: String? = null - private var shippingMethod: ShippingMethod? = null + private var shippingAddress: JsonField? = null + private var carrier: JsonField = JsonMissing.of() + private var expMonth: JsonField = JsonMissing.of() + private var expYear: JsonField = JsonMissing.of() + private var productId: JsonField = JsonMissing.of() + private var shippingMethod: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cardRenewBody: CardRenewBody) = apply { @@ -175,31 +281,57 @@ constructor( } /** The shipping address this card will be sent to. */ - fun shippingAddress(shippingAddress: ShippingAddress) = apply { + fun shippingAddress(shippingAddress: ShippingAddress) = + shippingAddress(JsonField.of(shippingAddress)) + + /** The shipping address this card will be sent to. */ + fun shippingAddress(shippingAddress: JsonField) = apply { this.shippingAddress = shippingAddress } /** If omitted, the previous carrier will be used. */ - fun carrier(carrier: Carrier?) = apply { this.carrier = carrier } + fun carrier(carrier: Carrier) = carrier(JsonField.of(carrier)) + + /** If omitted, the previous carrier will be used. */ + fun carrier(carrier: JsonField) = apply { this.carrier = carrier } /** * Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an * expiration date six years in the future will be generated. */ - fun expMonth(expMonth: String?) = apply { this.expMonth = expMonth } + fun expMonth(expMonth: String) = expMonth(JsonField.of(expMonth)) + + /** + * Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an + * expiration date six years in the future will be generated. + */ + fun expMonth(expMonth: JsonField) = apply { this.expMonth = expMonth } /** * Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an * expiration date six years in the future will be generated. */ - fun expYear(expYear: String?) = apply { this.expYear = expYear } + fun expYear(expYear: String) = expYear(JsonField.of(expYear)) + + /** + * Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an + * expiration date six years in the future will be generated. + */ + fun expYear(expYear: JsonField) = apply { this.expYear = expYear } /** * Specifies the configuration (e.g. physical card art) that the card should be * manufactured with, and only applies to cards of type `PHYSICAL`. This must be * configured with Lithic before use. */ - fun productId(productId: String?) = apply { this.productId = productId } + fun productId(productId: String) = productId(JsonField.of(productId)) + + /** + * Specifies the configuration (e.g. physical card art) that the card should be + * manufactured with, and only applies to cards of type `PHYSICAL`. This must be + * configured with Lithic before use. + */ + fun productId(productId: JsonField) = apply { this.productId = productId } /** * Shipping method for the card. Use of options besides `STANDARD` require additional @@ -213,7 +345,22 @@ constructor( * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with * tracking */ - fun shippingMethod(shippingMethod: ShippingMethod?) = apply { + fun shippingMethod(shippingMethod: ShippingMethod) = + shippingMethod(JsonField.of(shippingMethod)) + + /** + * Shipping method for the card. Use of options besides `STANDARD` require additional + * permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with + * tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with + * tracking + */ + fun shippingMethod(shippingMethod: JsonField) = apply { this.shippingMethod = shippingMethod } @@ -297,27 +444,69 @@ constructor( body.shippingAddress(shippingAddress) } + /** The shipping address this card will be sent to. */ + fun shippingAddress(shippingAddress: JsonField) = apply { + body.shippingAddress(shippingAddress) + } + + /** If omitted, the previous carrier will be used. */ + fun carrier(carrier: Carrier) = apply { body.carrier(carrier) } + /** If omitted, the previous carrier will be used. */ - fun carrier(carrier: Carrier?) = apply { body.carrier(carrier) } + fun carrier(carrier: JsonField) = apply { body.carrier(carrier) } + + /** + * Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an + * expiration date six years in the future will be generated. + */ + fun expMonth(expMonth: String) = apply { body.expMonth(expMonth) } /** * Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an * expiration date six years in the future will be generated. */ - fun expMonth(expMonth: String?) = apply { body.expMonth(expMonth) } + fun expMonth(expMonth: JsonField) = apply { body.expMonth(expMonth) } /** * Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an * expiration date six years in the future will be generated. */ - fun expYear(expYear: String?) = apply { body.expYear(expYear) } + fun expYear(expYear: String) = apply { body.expYear(expYear) } + + /** + * Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an + * expiration date six years in the future will be generated. + */ + fun expYear(expYear: JsonField) = apply { body.expYear(expYear) } /** * Specifies the configuration (e.g. physical card art) that the card should be manufactured * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic * before use. */ - fun productId(productId: String?) = apply { body.productId(productId) } + fun productId(productId: String) = apply { body.productId(productId) } + + /** + * Specifies the configuration (e.g. physical card art) that the card should be manufactured + * with, and only applies to cards of type `PHYSICAL`. This must be configured with Lithic + * before use. + */ + fun productId(productId: JsonField) = apply { body.productId(productId) } + + /** + * Shipping method for the card. Use of options besides `STANDARD` require additional + * permissions. + * - `STANDARD` - USPS regular mail or similar international option, with no tracking + * - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with + * tracking + * - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking + * - `EXPRESS` - FedEx Express, 3-day shipping, with tracking + * - `2_DAY` - FedEx 2-day shipping, with tracking + * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking + */ + fun shippingMethod(shippingMethod: ShippingMethod) = apply { + body.shippingMethod(shippingMethod) + } /** * Shipping method for the card. Use of options besides `STANDARD` require additional @@ -330,10 +519,29 @@ constructor( * - `2_DAY` - FedEx 2-day shipping, with tracking * - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking */ - fun shippingMethod(shippingMethod: ShippingMethod?) = apply { + fun shippingMethod(shippingMethod: JsonField) = apply { body.shippingMethod(shippingMethod) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -432,25 +640,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): CardRenewParams = CardRenewParams( checkNotNull(cardToken) { "`cardToken` is required but was not set" }, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardSearchByPanParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardSearchByPanParams.kt index b0dd6f7b..de705414 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardSearchByPanParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardSearchByPanParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -31,12 +33,15 @@ constructor( /** The PAN for the card being retrieved. */ fun pan(): String = body.pan() + /** The PAN for the card being retrieved. */ + fun _pan(): JsonField = body._pan() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): CardSearchByPanBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -47,18 +52,30 @@ constructor( class CardSearchByPanBody @JsonCreator internal constructor( - @JsonProperty("pan") private val pan: String, + @JsonProperty("pan") @ExcludeMissing private val pan: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The PAN for the card being retrieved. */ - @JsonProperty("pan") fun pan(): String = pan + fun pan(): String = pan.getRequired("pan") + + /** The PAN for the card being retrieved. */ + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CardSearchByPanBody = apply { + if (!validated) { + pan() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -68,7 +85,7 @@ constructor( class Builder { - private var pan: String? = null + private var pan: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cardSearchByPanBody: CardSearchByPanBody) = apply { @@ -77,7 +94,10 @@ constructor( } /** The PAN for the card being retrieved. */ - fun pan(pan: String) = apply { this.pan = pan } + fun pan(pan: String) = pan(JsonField.of(pan)) + + /** The PAN for the card being retrieved. */ + fun pan(pan: JsonField) = apply { this.pan = pan } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -146,6 +166,28 @@ constructor( /** The PAN for the card being retrieved. */ fun pan(pan: String) = apply { body.pan(pan) } + /** The PAN for the card being retrieved. */ + fun pan(pan: JsonField) = apply { body.pan(pan) } + + 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) @@ -244,25 +286,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): CardSearchByPanParams = CardSearchByPanParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardSpendLimits.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardSpendLimits.kt index 8d2b1fae..8f7fd658 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardSpendLimits.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardSpendLimits.kt @@ -40,11 +40,15 @@ private constructor( @JsonProperty("available_spend_limit") @ExcludeMissing - fun _availableSpendLimit() = availableSpendLimit + fun _availableSpendLimit(): JsonField = availableSpendLimit - @JsonProperty("spend_limit") @ExcludeMissing fun _spendLimit() = spendLimit + @JsonProperty("spend_limit") + @ExcludeMissing + fun _spendLimit(): JsonField = spendLimit - @JsonProperty("spend_velocity") @ExcludeMissing fun _spendVelocity() = spendVelocity + @JsonProperty("spend_velocity") + @ExcludeMissing + fun _spendVelocity(): JsonField = spendVelocity @JsonAnyGetter @ExcludeMissing @@ -70,7 +74,7 @@ private constructor( class Builder { - private var availableSpendLimit: JsonField = JsonMissing.of() + private var availableSpendLimit: JsonField? = null private var spendLimit: JsonField = JsonMissing.of() private var spendVelocity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -120,7 +124,9 @@ private constructor( fun build(): CardSpendLimits = CardSpendLimits( - availableSpendLimit, + checkNotNull(availableSpendLimit) { + "`availableSpendLimit` is required but was not set" + }, spendLimit, spendVelocity, additionalProperties.toImmutable(), @@ -164,19 +170,19 @@ private constructor( /** * The available spend limit (in cents) relative to the annual limit configured on the Card. */ - @JsonProperty("annually") @ExcludeMissing fun _annually() = annually + @JsonProperty("annually") @ExcludeMissing fun _annually(): JsonField = annually /** * The available spend limit (in cents) relative to the forever limit configured on the * Card. */ - @JsonProperty("forever") @ExcludeMissing fun _forever() = forever + @JsonProperty("forever") @ExcludeMissing fun _forever(): JsonField = forever /** * The available spend limit (in cents) relative to the monthly limit configured on the * Card. */ - @JsonProperty("monthly") @ExcludeMissing fun _monthly() = monthly + @JsonProperty("monthly") @ExcludeMissing fun _monthly(): JsonField = monthly @JsonAnyGetter @ExcludeMissing @@ -323,13 +329,13 @@ private constructor( fun monthly(): Long? = monthly.getNullable("monthly") /** The configured annual spend limit (in cents) on the Card. */ - @JsonProperty("annually") @ExcludeMissing fun _annually() = annually + @JsonProperty("annually") @ExcludeMissing fun _annually(): JsonField = annually /** The configured forever spend limit (in cents) on the Card. */ - @JsonProperty("forever") @ExcludeMissing fun _forever() = forever + @JsonProperty("forever") @ExcludeMissing fun _forever(): JsonField = forever /** The configured monthly spend limit (in cents) on the Card. */ - @JsonProperty("monthly") @ExcludeMissing fun _monthly() = monthly + @JsonProperty("monthly") @ExcludeMissing fun _monthly(): JsonField = monthly @JsonAnyGetter @ExcludeMissing @@ -470,19 +476,19 @@ private constructor( * Current annual spend velocity (in cents) on the Card. Present if annual spend limit is * set. */ - @JsonProperty("annually") @ExcludeMissing fun _annually() = annually + @JsonProperty("annually") @ExcludeMissing fun _annually(): JsonField = annually /** * Current forever spend velocity (in cents) on the Card. Present if forever spend limit is * set. */ - @JsonProperty("forever") @ExcludeMissing fun _forever() = forever + @JsonProperty("forever") @ExcludeMissing fun _forever(): JsonField = forever /** * Current monthly spend velocity (in cents) on the Card. Present if monthly spend limit is * set. */ - @JsonProperty("monthly") @ExcludeMissing fun _monthly() = monthly + @JsonProperty("monthly") @ExcludeMissing fun _monthly(): JsonField = monthly @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardUpdateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardUpdateParams.kt index 11392c2b..b294430d 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardUpdateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardUpdateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -86,12 +87,65 @@ constructor( */ fun state(): State? = body.state() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * Specifies the digital card art to be displayed in the user’s digital wallet after + * tokenization. This artwork must be approved by Mastercard and configured by Lithic to use. + * See + * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). + */ + fun _digitalCardArtToken(): JsonField = body._digitalCardArtToken() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Friendly name to identify the card. */ + fun _memo(): JsonField = body._memo() + + /** + * Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and `VIRTUAL`. + * Changing PIN also resets PIN status to `OK`. See + * [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block). + */ + fun _pin(): JsonField = body._pin() + + /** + * Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect attempts). + * Can only be set to `OK` to unblock a card. + */ + fun _pinStatus(): JsonField = body._pinStatus() + + /** + * Amount (in cents) to limit approved authorizations. Transaction requests above the spend + * limit will be declined. Note that a spend limit of 0 is effectively no limit, and should only + * be used to reset or remove a prior limit. Only a limit of 1 or above will result in declined + * transactions due to checks against the card limit. + */ + fun _spendLimit(): JsonField = body._spendLimit() + + /** + * Spend limit duration values: + * - `ANNUALLY` - Card will authorize transactions up to spend limit for the trailing year. + * - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime of the card. + * - `MONTHLY` - Card will authorize transactions up to spend limit for the trailing month. To + * support recurring monthly payments, which can occur on different day every month, the time + * window we consider for monthly velocity starts 6 days after the current calendar date one + * month prior. + * - `TRANSACTION` - Card will authorize multiple transactions if each individual transaction is + * under the spend limit. + */ + fun _spendLimitDuration(): JsonField = body._spendLimitDuration() + + /** + * Card state values: + * - `CLOSED` - Card will no longer approve authorizations. Closing a card cannot be undone. + * - `OPEN` - Card will approve authorizations (if they match card and account parameters). + * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. + */ + fun _state(): JsonField = body._state() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): CardUpdateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -109,17 +163,85 @@ constructor( class CardUpdateBody @JsonCreator internal constructor( - @JsonProperty("digital_card_art_token") private val digitalCardArtToken: String?, - @JsonProperty("memo") private val memo: String?, - @JsonProperty("pin") private val pin: String?, - @JsonProperty("pin_status") private val pinStatus: PinStatus?, - @JsonProperty("spend_limit") private val spendLimit: Long?, - @JsonProperty("spend_limit_duration") private val spendLimitDuration: SpendLimitDuration?, - @JsonProperty("state") private val state: State?, + @JsonProperty("digital_card_art_token") + @ExcludeMissing + private val digitalCardArtToken: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), + @JsonProperty("pin") @ExcludeMissing private val pin: JsonField = JsonMissing.of(), + @JsonProperty("pin_status") + @ExcludeMissing + private val pinStatus: JsonField = JsonMissing.of(), + @JsonProperty("spend_limit") + @ExcludeMissing + private val spendLimit: JsonField = JsonMissing.of(), + @JsonProperty("spend_limit_duration") + @ExcludeMissing + private val spendLimitDuration: JsonField = JsonMissing.of(), + @JsonProperty("state") + @ExcludeMissing + private val state: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * Specifies the digital card art to be displayed in the user’s digital wallet after + * tokenization. This artwork must be approved by Mastercard and configured by Lithic to + * use. See + * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). + */ + fun digitalCardArtToken(): String? = + digitalCardArtToken.getNullable("digital_card_art_token") + + /** Friendly name to identify the card. */ + fun memo(): String? = memo.getNullable("memo") + + /** + * Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and `VIRTUAL`. + * Changing PIN also resets PIN status to `OK`. See + * [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block). + */ + fun pin(): String? = pin.getNullable("pin") + + /** + * Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect + * attempts). Can only be set to `OK` to unblock a card. + */ + fun pinStatus(): PinStatus? = pinStatus.getNullable("pin_status") + + /** + * Amount (in cents) to limit approved authorizations. Transaction requests above the spend + * limit will be declined. Note that a spend limit of 0 is effectively no limit, and should + * only be used to reset or remove a prior limit. Only a limit of 1 or above will result in + * declined transactions due to checks against the card limit. + */ + fun spendLimit(): Long? = spendLimit.getNullable("spend_limit") + + /** + * Spend limit duration values: + * - `ANNUALLY` - Card will authorize transactions up to spend limit for the trailing year. + * - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime of the + * card. + * - `MONTHLY` - Card will authorize transactions up to spend limit for the trailing month. + * To support recurring monthly payments, which can occur on different day every month, + * the time window we consider for monthly velocity starts 6 days after the current + * calendar date one month prior. + * - `TRANSACTION` - Card will authorize multiple transactions if each individual + * transaction is under the spend limit. + */ + fun spendLimitDuration(): SpendLimitDuration? = + spendLimitDuration.getNullable("spend_limit_duration") + + /** + * Card state values: + * - `CLOSED` - Card will no longer approve authorizations. Closing a card cannot be undone. + * - `OPEN` - Card will approve authorizations (if they match card and account parameters). + * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. + */ + fun state(): State? = state.getNullable("state") + /** * Specifies the digital card art to be displayed in the user’s digital wallet after * tokenization. This artwork must be approved by Mastercard and configured by Lithic to @@ -127,23 +249,26 @@ constructor( * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). */ @JsonProperty("digital_card_art_token") - fun digitalCardArtToken(): String? = digitalCardArtToken + @ExcludeMissing + fun _digitalCardArtToken(): JsonField = digitalCardArtToken /** Friendly name to identify the card. */ - @JsonProperty("memo") fun memo(): String? = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo /** * Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and `VIRTUAL`. * Changing PIN also resets PIN status to `OK`. See * [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block). */ - @JsonProperty("pin") fun pin(): String? = pin + @JsonProperty("pin") @ExcludeMissing fun _pin(): JsonField = pin /** * Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect * attempts). Can only be set to `OK` to unblock a card. */ - @JsonProperty("pin_status") fun pinStatus(): PinStatus? = pinStatus + @JsonProperty("pin_status") + @ExcludeMissing + fun _pinStatus(): JsonField = pinStatus /** * Amount (in cents) to limit approved authorizations. Transaction requests above the spend @@ -151,7 +276,7 @@ constructor( * only be used to reset or remove a prior limit. Only a limit of 1 or above will result in * declined transactions due to checks against the card limit. */ - @JsonProperty("spend_limit") fun spendLimit(): Long? = spendLimit + @JsonProperty("spend_limit") @ExcludeMissing fun _spendLimit(): JsonField = spendLimit /** * Spend limit duration values: @@ -166,7 +291,8 @@ constructor( * transaction is under the spend limit. */ @JsonProperty("spend_limit_duration") - fun spendLimitDuration(): SpendLimitDuration? = spendLimitDuration + @ExcludeMissing + fun _spendLimitDuration(): JsonField = spendLimitDuration /** * Card state values: @@ -174,12 +300,27 @@ constructor( * - `OPEN` - Card will approve authorizations (if they match card and account parameters). * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. */ - @JsonProperty("state") fun state(): State? = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CardUpdateBody = apply { + if (!validated) { + digitalCardArtToken() + memo() + pin() + pinStatus() + spendLimit() + spendLimitDuration() + state() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -189,13 +330,13 @@ constructor( class Builder { - private var digitalCardArtToken: String? = null - private var memo: String? = null - private var pin: String? = null - private var pinStatus: PinStatus? = null - private var spendLimit: Long? = null - private var spendLimitDuration: SpendLimitDuration? = null - private var state: State? = null + private var digitalCardArtToken: JsonField = JsonMissing.of() + private var memo: JsonField = JsonMissing.of() + private var pin: JsonField = JsonMissing.of() + private var pinStatus: JsonField = JsonMissing.of() + private var spendLimit: JsonField = JsonMissing.of() + private var spendLimitDuration: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cardUpdateBody: CardUpdateBody) = apply { @@ -215,25 +356,50 @@ constructor( * use. See * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). */ - fun digitalCardArtToken(digitalCardArtToken: String?) = apply { + fun digitalCardArtToken(digitalCardArtToken: String) = + digitalCardArtToken(JsonField.of(digitalCardArtToken)) + + /** + * Specifies the digital card art to be displayed in the user’s digital wallet after + * tokenization. This artwork must be approved by Mastercard and configured by Lithic to + * use. See + * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). + */ + fun digitalCardArtToken(digitalCardArtToken: JsonField) = apply { this.digitalCardArtToken = digitalCardArtToken } /** Friendly name to identify the card. */ - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String) = memo(JsonField.of(memo)) + + /** Friendly name to identify the card. */ + fun memo(memo: JsonField) = apply { this.memo = memo } + + /** + * Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and + * `VIRTUAL`. Changing PIN also resets PIN status to `OK`. See + * [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block). + */ + fun pin(pin: String) = pin(JsonField.of(pin)) /** * Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and * `VIRTUAL`. Changing PIN also resets PIN status to `OK`. See * [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block). */ - fun pin(pin: String?) = apply { this.pin = pin } + fun pin(pin: JsonField) = apply { this.pin = pin } /** * Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect * attempts). Can only be set to `OK` to unblock a card. */ - fun pinStatus(pinStatus: PinStatus?) = apply { this.pinStatus = pinStatus } + fun pinStatus(pinStatus: PinStatus) = pinStatus(JsonField.of(pinStatus)) + + /** + * Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect + * attempts). Can only be set to `OK` to unblock a card. + */ + fun pinStatus(pinStatus: JsonField) = apply { this.pinStatus = pinStatus } /** * Amount (in cents) to limit approved authorizations. Transaction requests above the @@ -241,7 +407,7 @@ constructor( * and should only be used to reset or remove a prior limit. Only a limit of 1 or above * will result in declined transactions due to checks against the card limit. */ - fun spendLimit(spendLimit: Long?) = apply { this.spendLimit = spendLimit } + fun spendLimit(spendLimit: Long) = spendLimit(JsonField.of(spendLimit)) /** * Amount (in cents) to limit approved authorizations. Transaction requests above the @@ -249,7 +415,23 @@ constructor( * and should only be used to reset or remove a prior limit. Only a limit of 1 or above * will result in declined transactions due to checks against the card limit. */ - fun spendLimit(spendLimit: Long) = spendLimit(spendLimit as Long?) + fun spendLimit(spendLimit: JsonField) = apply { this.spendLimit = spendLimit } + + /** + * Spend limit duration values: + * - `ANNUALLY` - Card will authorize transactions up to spend limit for the trailing + * year. + * - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime of + * the card. + * - `MONTHLY` - Card will authorize transactions up to spend limit for the trailing + * month. To support recurring monthly payments, which can occur on different day + * every month, the time window we consider for monthly velocity starts 6 days after + * the current calendar date one month prior. + * - `TRANSACTION` - Card will authorize multiple transactions if each individual + * transaction is under the spend limit. + */ + fun spendLimitDuration(spendLimitDuration: SpendLimitDuration) = + spendLimitDuration(JsonField.of(spendLimitDuration)) /** * Spend limit duration values: @@ -264,7 +446,7 @@ constructor( * - `TRANSACTION` - Card will authorize multiple transactions if each individual * transaction is under the spend limit. */ - fun spendLimitDuration(spendLimitDuration: SpendLimitDuration?) = apply { + fun spendLimitDuration(spendLimitDuration: JsonField) = apply { this.spendLimitDuration = spendLimitDuration } @@ -276,7 +458,17 @@ constructor( * parameters). * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. */ - fun state(state: State?) = apply { this.state = state } + fun state(state: State) = state(JsonField.of(state)) + + /** + * Card state values: + * - `CLOSED` - Card will no longer approve authorizations. Closing a card cannot be + * undone. + * - `OPEN` - Card will approve authorizations (if they match card and account + * parameters). + * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. + */ + fun state(state: JsonField) = apply { this.state = state } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -358,25 +550,51 @@ constructor( * use. See * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). */ - fun digitalCardArtToken(digitalCardArtToken: String?) = apply { + fun digitalCardArtToken(digitalCardArtToken: String) = apply { + body.digitalCardArtToken(digitalCardArtToken) + } + + /** + * Specifies the digital card art to be displayed in the user’s digital wallet after + * tokenization. This artwork must be approved by Mastercard and configured by Lithic to + * use. See + * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). + */ + fun digitalCardArtToken(digitalCardArtToken: JsonField) = apply { body.digitalCardArtToken(digitalCardArtToken) } /** Friendly name to identify the card. */ - fun memo(memo: String?) = apply { body.memo(memo) } + fun memo(memo: String) = apply { body.memo(memo) } + + /** Friendly name to identify the card. */ + fun memo(memo: JsonField) = apply { body.memo(memo) } + + /** + * Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and `VIRTUAL`. + * Changing PIN also resets PIN status to `OK`. See + * [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block). + */ + fun pin(pin: String) = apply { body.pin(pin) } /** * Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and `VIRTUAL`. * Changing PIN also resets PIN status to `OK`. See * [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block). */ - fun pin(pin: String?) = apply { body.pin(pin) } + fun pin(pin: JsonField) = apply { body.pin(pin) } /** * Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect * attempts). Can only be set to `OK` to unblock a card. */ - fun pinStatus(pinStatus: PinStatus?) = apply { body.pinStatus(pinStatus) } + fun pinStatus(pinStatus: PinStatus) = apply { body.pinStatus(pinStatus) } + + /** + * Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect + * attempts). Can only be set to `OK` to unblock a card. + */ + fun pinStatus(pinStatus: JsonField) = apply { body.pinStatus(pinStatus) } /** * Amount (in cents) to limit approved authorizations. Transaction requests above the spend @@ -384,7 +602,7 @@ constructor( * only be used to reset or remove a prior limit. Only a limit of 1 or above will result in * declined transactions due to checks against the card limit. */ - fun spendLimit(spendLimit: Long?) = apply { body.spendLimit(spendLimit) } + fun spendLimit(spendLimit: Long) = apply { body.spendLimit(spendLimit) } /** * Amount (in cents) to limit approved authorizations. Transaction requests above the spend @@ -392,7 +610,23 @@ constructor( * only be used to reset or remove a prior limit. Only a limit of 1 or above will result in * declined transactions due to checks against the card limit. */ - fun spendLimit(spendLimit: Long) = spendLimit(spendLimit as Long?) + fun spendLimit(spendLimit: JsonField) = apply { body.spendLimit(spendLimit) } + + /** + * Spend limit duration values: + * - `ANNUALLY` - Card will authorize transactions up to spend limit for the trailing year. + * - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime of the + * card. + * - `MONTHLY` - Card will authorize transactions up to spend limit for the trailing month. + * To support recurring monthly payments, which can occur on different day every month, + * the time window we consider for monthly velocity starts 6 days after the current + * calendar date one month prior. + * - `TRANSACTION` - Card will authorize multiple transactions if each individual + * transaction is under the spend limit. + */ + fun spendLimitDuration(spendLimitDuration: SpendLimitDuration) = apply { + body.spendLimitDuration(spendLimitDuration) + } /** * Spend limit duration values: @@ -406,7 +640,7 @@ constructor( * - `TRANSACTION` - Card will authorize multiple transactions if each individual * transaction is under the spend limit. */ - fun spendLimitDuration(spendLimitDuration: SpendLimitDuration?) = apply { + fun spendLimitDuration(spendLimitDuration: JsonField) = apply { body.spendLimitDuration(spendLimitDuration) } @@ -416,7 +650,34 @@ constructor( * - `OPEN` - Card will approve authorizations (if they match card and account parameters). * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. */ - fun state(state: State?) = apply { body.state(state) } + fun state(state: State) = apply { body.state(state) } + + /** + * Card state values: + * - `CLOSED` - Card will no longer approve authorizations. Closing a card cannot be undone. + * - `OPEN` - Card will approve authorizations (if they match card and account parameters). + * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. + */ + fun state(state: JsonField) = apply { body.state(state) } + + 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() @@ -516,25 +777,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): CardUpdateParams = CardUpdateParams( checkNotNull(cardToken) { "`cardToken` is required but was not set" }, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Carrier.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Carrier.kt index c9fb5fb9..0bf1879f 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Carrier.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Carrier.kt @@ -29,7 +29,7 @@ private constructor( fun qrCodeUrl(): String? = qrCodeUrl.getNullable("qr_code_url") /** QR code url to display on the card carrier */ - @JsonProperty("qr_code_url") @ExcludeMissing fun _qrCodeUrl() = qrCodeUrl + @JsonProperty("qr_code_url") @ExcludeMissing fun _qrCodeUrl(): JsonField = qrCodeUrl @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ChallengeResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ChallengeResponse.kt index f13e8b69..e4bd484c 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ChallengeResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ChallengeResponse.kt @@ -41,10 +41,12 @@ private constructor( * initial 3DS Decisioning Request and as part of the 3DS Challenge Event in the * [ThreeDSAuthentication](#/components/schemas/ThreeDSAuthentication) object */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Whether the Cardholder has Approved or Declined the issued Challenge */ - @JsonProperty("challenge_response") @ExcludeMissing fun _challengeResponse() = challengeResponse + @JsonProperty("challenge_response") + @ExcludeMissing + fun _challengeResponse(): JsonField = challengeResponse @JsonAnyGetter @ExcludeMissing @@ -69,8 +71,8 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var challengeResponse: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var challengeResponse: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(challengeResponse: ChallengeResponse) = apply { @@ -123,8 +125,10 @@ private constructor( fun build(): ChallengeResponse = ChallengeResponse( - token, - challengeResponse, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(challengeResponse) { + "`challengeResponse` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CreditProductPrimeRateCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CreditProductPrimeRateCreateParams.kt index e1ed3c38..5292ff6e 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CreditProductPrimeRateCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CreditProductPrimeRateCreateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -34,12 +36,18 @@ constructor( /** The rate in decimal format */ fun rate(): String = body.rate() - fun _additionalHeaders(): Headers = additionalHeaders + /** Date the rate goes into effect */ + fun _effectiveDate(): JsonField = body._effectiveDate() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The rate in decimal format */ + fun _rate(): JsonField = body._rate() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): CreditProductPrimeRateCreateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -57,22 +65,44 @@ constructor( class CreditProductPrimeRateCreateBody @JsonCreator internal constructor( - @JsonProperty("effective_date") private val effectiveDate: LocalDate, - @JsonProperty("rate") private val rate: String, + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("rate") + @ExcludeMissing + private val rate: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Date the rate goes into effect */ - @JsonProperty("effective_date") fun effectiveDate(): LocalDate = effectiveDate + fun effectiveDate(): LocalDate = effectiveDate.getRequired("effective_date") + + /** The rate in decimal format */ + fun rate(): String = rate.getRequired("rate") + + /** Date the rate goes into effect */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate /** The rate in decimal format */ - @JsonProperty("rate") fun rate(): String = rate + @JsonProperty("rate") @ExcludeMissing fun _rate(): JsonField = rate @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CreditProductPrimeRateCreateBody = apply { + if (!validated) { + effectiveDate() + rate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -82,8 +112,8 @@ constructor( class Builder { - private var effectiveDate: LocalDate? = null - private var rate: String? = null + private var effectiveDate: JsonField? = null + private var rate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(creditProductPrimeRateCreateBody: CreditProductPrimeRateCreateBody) = @@ -95,12 +125,18 @@ constructor( } /** Date the rate goes into effect */ - fun effectiveDate(effectiveDate: LocalDate) = apply { + fun effectiveDate(effectiveDate: LocalDate) = effectiveDate(JsonField.of(effectiveDate)) + + /** Date the rate goes into effect */ + fun effectiveDate(effectiveDate: JsonField) = apply { this.effectiveDate = effectiveDate } /** The rate in decimal format */ - fun rate(rate: String) = apply { this.rate = rate } + fun rate(rate: String) = rate(JsonField.of(rate)) + + /** The rate in decimal format */ + fun rate(rate: JsonField) = apply { this.rate = rate } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -180,9 +216,36 @@ constructor( /** Date the rate goes into effect */ fun effectiveDate(effectiveDate: LocalDate) = apply { body.effectiveDate(effectiveDate) } + /** Date the rate goes into effect */ + fun effectiveDate(effectiveDate: JsonField) = apply { + body.effectiveDate(effectiveDate) + } + /** The rate in decimal format */ fun rate(rate: String) = apply { body.rate(rate) } + /** The rate in decimal format */ + fun rate(rate: JsonField) = apply { body.rate(rate) } + + 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) @@ -281,25 +344,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): CreditProductPrimeRateCreateParams = CreditProductPrimeRateCreateParams( checkNotNull(creditProductToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DecisioningRetrieveSecretResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DecisioningRetrieveSecretResponse.kt index 983c8259..6bc30cf5 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DecisioningRetrieveSecretResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DecisioningRetrieveSecretResponse.kt @@ -29,7 +29,7 @@ private constructor( fun secret(): String? = secret.getNullable("secret") /** The 3DS Decisioning HMAC secret */ - @JsonProperty("secret") @ExcludeMissing fun _secret() = secret + @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DecisioningSimulateChallengeResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DecisioningSimulateChallengeResponse.kt index a109f3df..2725fa83 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DecisioningSimulateChallengeResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DecisioningSimulateChallengeResponse.kt @@ -35,7 +35,7 @@ private constructor( * authorization. This token is used in /v1/three_ds_decisioning/simulate/challenge_response to * Approve or Decline the authentication */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DigitalCardArt.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DigitalCardArt.kt index 57b1a1dc..b8eabef9 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DigitalCardArt.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DigitalCardArt.kt @@ -67,27 +67,29 @@ private constructor( isCardProgramDefault.getNullable("is_card_program_default") /** Globally unique identifier for the card art. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Globally unique identifier for the card program. */ - @JsonProperty("card_program_token") @ExcludeMissing fun _cardProgramToken() = cardProgramToken + @JsonProperty("card_program_token") + @ExcludeMissing + fun _cardProgramToken(): JsonField = cardProgramToken /** Timestamp of when card art was created. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Description of the card art. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** Whether the card art is enabled. */ - @JsonProperty("is_enabled") @ExcludeMissing fun _isEnabled() = isEnabled + @JsonProperty("is_enabled") @ExcludeMissing fun _isEnabled(): JsonField = isEnabled /** Card network. */ - @JsonProperty("network") @ExcludeMissing fun _network() = network + @JsonProperty("network") @ExcludeMissing fun _network(): JsonField = network /** Whether the card art is the default card art to be added upon tokenization. */ @JsonProperty("is_card_program_default") @ExcludeMissing - fun _isCardProgramDefault() = isCardProgramDefault + fun _isCardProgramDefault(): JsonField = isCardProgramDefault @JsonAnyGetter @ExcludeMissing @@ -117,12 +119,12 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var cardProgramToken: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var isEnabled: JsonField = JsonMissing.of() - private var network: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var cardProgramToken: JsonField? = null + private var created: JsonField? = null + private var description: JsonField? = null + private var isEnabled: JsonField? = null + private var network: JsonField? = null private var isCardProgramDefault: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -206,12 +208,12 @@ private constructor( fun build(): DigitalCardArt = DigitalCardArt( - token, - cardProgramToken, - created, - description, - isEnabled, - network, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(cardProgramToken) { "`cardProgramToken` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(isEnabled) { "`isEnabled` is required but was not set" }, + checkNotNull(network) { "`network` is required but was not set" }, isCardProgramDefault, additionalProperties.toImmutable(), ) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Dispute.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Dispute.kt index 4c1e1b17..bfcbe0c6 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Dispute.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Dispute.kt @@ -189,46 +189,56 @@ private constructor( fun transactionToken(): String = transactionToken.getRequired("transaction_token") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Amount under dispute. May be different from the original transaction amount. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** Date dispute entered arbitration. */ - @JsonProperty("arbitration_date") @ExcludeMissing fun _arbitrationDate() = arbitrationDate + @JsonProperty("arbitration_date") + @ExcludeMissing + fun _arbitrationDate(): JsonField = arbitrationDate /** Timestamp of when first Dispute was reported. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Date that the dispute was filed by the customer making the dispute. */ @JsonProperty("customer_filed_date") @ExcludeMissing - fun _customerFiledDate() = customerFiledDate + fun _customerFiledDate(): JsonField = customerFiledDate /** End customer description of the reason for the dispute. */ - @JsonProperty("customer_note") @ExcludeMissing fun _customerNote() = customerNote + @JsonProperty("customer_note") + @ExcludeMissing + fun _customerNote(): JsonField = customerNote /** Unique identifiers for the dispute from the network. */ - @JsonProperty("network_claim_ids") @ExcludeMissing fun _networkClaimIds() = networkClaimIds + @JsonProperty("network_claim_ids") + @ExcludeMissing + fun _networkClaimIds(): JsonField> = networkClaimIds /** Date that the dispute was submitted to the network. */ - @JsonProperty("network_filed_date") @ExcludeMissing fun _networkFiledDate() = networkFiledDate + @JsonProperty("network_filed_date") + @ExcludeMissing + fun _networkFiledDate(): JsonField = networkFiledDate /** Network reason code used to file the dispute. */ @JsonProperty("network_reason_code") @ExcludeMissing - fun _networkReasonCode() = networkReasonCode + fun _networkReasonCode(): JsonField = networkReasonCode /** Date dispute entered pre-arbitration. */ @JsonProperty("prearbitration_date") @ExcludeMissing - fun _prearbitrationDate() = prearbitrationDate + fun _prearbitrationDate(): JsonField = prearbitrationDate /** * Unique identifier for the dispute from the network. If there are multiple, this will be the * first claim id set by the network */ - @JsonProperty("primary_claim_id") @ExcludeMissing fun _primaryClaimId() = primaryClaimId + @JsonProperty("primary_claim_id") + @ExcludeMissing + fun _primaryClaimId(): JsonField = primaryClaimId /** * Dispute reason: @@ -247,19 +257,27 @@ private constructor( * - `REFUND_NOT_PROCESSED`: The refund was not processed. * - `RECURRING_TRANSACTION_NOT_CANCELLED`: The recurring transaction was not cancelled. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** Date the representment was received. */ - @JsonProperty("representment_date") @ExcludeMissing fun _representmentDate() = representmentDate + @JsonProperty("representment_date") + @ExcludeMissing + fun _representmentDate(): JsonField = representmentDate /** Resolution amount net of network fees. */ - @JsonProperty("resolution_amount") @ExcludeMissing fun _resolutionAmount() = resolutionAmount + @JsonProperty("resolution_amount") + @ExcludeMissing + fun _resolutionAmount(): JsonField = resolutionAmount /** Date that the dispute was resolved. */ - @JsonProperty("resolution_date") @ExcludeMissing fun _resolutionDate() = resolutionDate + @JsonProperty("resolution_date") + @ExcludeMissing + fun _resolutionDate(): JsonField = resolutionDate /** Note by Dispute team on the case resolution. */ - @JsonProperty("resolution_note") @ExcludeMissing fun _resolutionNote() = resolutionNote + @JsonProperty("resolution_note") + @ExcludeMissing + fun _resolutionNote(): JsonField = resolutionNote /** * Reason for the dispute resolution: @@ -281,7 +299,9 @@ private constructor( * - `WON_FIRST_CHARGEBACK`: Won first chargeback. * - `WON_PREARBITRATION`: Won prearbitration. */ - @JsonProperty("resolution_reason") @ExcludeMissing fun _resolutionReason() = resolutionReason + @JsonProperty("resolution_reason") + @ExcludeMissing + fun _resolutionReason(): JsonField = resolutionReason /** * Status types: @@ -294,13 +314,15 @@ private constructor( * - `CASE_WON` - Case was won and credit will be issued. * - `CASE_CLOSED` - Case was lost or withdrawn. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** * The transaction that is being disputed. A transaction can only be disputed once but may have * multiple dispute cases. */ - @JsonProperty("transaction_token") @ExcludeMissing fun _transactionToken() = transactionToken + @JsonProperty("transaction_token") + @ExcludeMissing + fun _transactionToken(): JsonField = transactionToken @JsonAnyGetter @ExcludeMissing @@ -342,25 +364,25 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var arbitrationDate: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var customerFiledDate: JsonField = JsonMissing.of() - private var customerNote: JsonField = JsonMissing.of() - private var networkClaimIds: JsonField> = JsonMissing.of() - private var networkFiledDate: JsonField = JsonMissing.of() - private var networkReasonCode: JsonField = JsonMissing.of() - private var prearbitrationDate: JsonField = JsonMissing.of() - private var primaryClaimId: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var representmentDate: JsonField = JsonMissing.of() - private var resolutionAmount: JsonField = JsonMissing.of() - private var resolutionDate: JsonField = JsonMissing.of() - private var resolutionNote: JsonField = JsonMissing.of() - private var resolutionReason: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var transactionToken: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var amount: JsonField? = null + private var arbitrationDate: JsonField? = null + private var created: JsonField? = null + private var customerFiledDate: JsonField? = null + private var customerNote: JsonField? = null + private var networkClaimIds: JsonField>? = null + private var networkFiledDate: JsonField? = null + private var networkReasonCode: JsonField? = null + private var prearbitrationDate: JsonField? = null + private var primaryClaimId: JsonField? = null + private var reason: JsonField? = null + private var representmentDate: JsonField? = null + private var resolutionAmount: JsonField? = null + private var resolutionDate: JsonField? = null + private var resolutionNote: JsonField? = null + private var resolutionReason: JsonField? = null + private var status: JsonField? = null + private var transactionToken: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(dispute: Dispute) = apply { @@ -370,7 +392,7 @@ private constructor( created = dispute.created customerFiledDate = dispute.customerFiledDate customerNote = dispute.customerNote - networkClaimIds = dispute.networkClaimIds + networkClaimIds = dispute.networkClaimIds.map { it.toMutableList() } networkFiledDate = dispute.networkFiledDate networkReasonCode = dispute.networkReasonCode prearbitrationDate = dispute.prearbitrationDate @@ -399,8 +421,8 @@ private constructor( fun amount(amount: JsonField) = apply { this.amount = amount } /** Date dispute entered arbitration. */ - fun arbitrationDate(arbitrationDate: OffsetDateTime) = - arbitrationDate(JsonField.of(arbitrationDate)) + fun arbitrationDate(arbitrationDate: OffsetDateTime?) = + arbitrationDate(JsonField.ofNullable(arbitrationDate)) /** Date dispute entered arbitration. */ fun arbitrationDate(arbitrationDate: JsonField) = apply { @@ -414,8 +436,8 @@ private constructor( fun created(created: JsonField) = apply { this.created = created } /** Date that the dispute was filed by the customer making the dispute. */ - fun customerFiledDate(customerFiledDate: OffsetDateTime) = - customerFiledDate(JsonField.of(customerFiledDate)) + fun customerFiledDate(customerFiledDate: OffsetDateTime?) = + customerFiledDate(JsonField.ofNullable(customerFiledDate)) /** Date that the dispute was filed by the customer making the dispute. */ fun customerFiledDate(customerFiledDate: JsonField) = apply { @@ -423,7 +445,7 @@ private constructor( } /** End customer description of the reason for the dispute. */ - fun customerNote(customerNote: String) = customerNote(JsonField.of(customerNote)) + fun customerNote(customerNote: String?) = customerNote(JsonField.ofNullable(customerNote)) /** End customer description of the reason for the dispute. */ fun customerNote(customerNote: JsonField) = apply { @@ -431,17 +453,29 @@ private constructor( } /** Unique identifiers for the dispute from the network. */ - fun networkClaimIds(networkClaimIds: List) = - networkClaimIds(JsonField.of(networkClaimIds)) + fun networkClaimIds(networkClaimIds: List?) = + networkClaimIds(JsonField.ofNullable(networkClaimIds)) /** Unique identifiers for the dispute from the network. */ fun networkClaimIds(networkClaimIds: JsonField>) = apply { - this.networkClaimIds = networkClaimIds + this.networkClaimIds = networkClaimIds.map { it.toMutableList() } + } + + /** Unique identifiers for the dispute from the network. */ + fun addNetworkClaimId(networkClaimId: String) = apply { + networkClaimIds = + (networkClaimIds ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(networkClaimId) + } } /** Date that the dispute was submitted to the network. */ - fun networkFiledDate(networkFiledDate: OffsetDateTime) = - networkFiledDate(JsonField.of(networkFiledDate)) + fun networkFiledDate(networkFiledDate: OffsetDateTime?) = + networkFiledDate(JsonField.ofNullable(networkFiledDate)) /** Date that the dispute was submitted to the network. */ fun networkFiledDate(networkFiledDate: JsonField) = apply { @@ -449,8 +483,8 @@ private constructor( } /** Network reason code used to file the dispute. */ - fun networkReasonCode(networkReasonCode: String) = - networkReasonCode(JsonField.of(networkReasonCode)) + fun networkReasonCode(networkReasonCode: String?) = + networkReasonCode(JsonField.ofNullable(networkReasonCode)) /** Network reason code used to file the dispute. */ fun networkReasonCode(networkReasonCode: JsonField) = apply { @@ -458,8 +492,8 @@ private constructor( } /** Date dispute entered pre-arbitration. */ - fun prearbitrationDate(prearbitrationDate: OffsetDateTime) = - prearbitrationDate(JsonField.of(prearbitrationDate)) + fun prearbitrationDate(prearbitrationDate: OffsetDateTime?) = + prearbitrationDate(JsonField.ofNullable(prearbitrationDate)) /** Date dispute entered pre-arbitration. */ fun prearbitrationDate(prearbitrationDate: JsonField) = apply { @@ -470,7 +504,8 @@ private constructor( * Unique identifier for the dispute from the network. If there are multiple, this will be * the first claim id set by the network */ - fun primaryClaimId(primaryClaimId: String) = primaryClaimId(JsonField.of(primaryClaimId)) + fun primaryClaimId(primaryClaimId: String?) = + primaryClaimId(JsonField.ofNullable(primaryClaimId)) /** * Unique identifier for the dispute from the network. If there are multiple, this will be @@ -521,8 +556,8 @@ private constructor( fun reason(reason: JsonField) = apply { this.reason = reason } /** Date the representment was received. */ - fun representmentDate(representmentDate: OffsetDateTime) = - representmentDate(JsonField.of(representmentDate)) + fun representmentDate(representmentDate: OffsetDateTime?) = + representmentDate(JsonField.ofNullable(representmentDate)) /** Date the representment was received. */ fun representmentDate(representmentDate: JsonField) = apply { @@ -530,8 +565,11 @@ private constructor( } /** Resolution amount net of network fees. */ - fun resolutionAmount(resolutionAmount: Long) = - resolutionAmount(JsonField.of(resolutionAmount)) + fun resolutionAmount(resolutionAmount: Long?) = + resolutionAmount(JsonField.ofNullable(resolutionAmount)) + + /** Resolution amount net of network fees. */ + fun resolutionAmount(resolutionAmount: Long) = resolutionAmount(resolutionAmount as Long?) /** Resolution amount net of network fees. */ fun resolutionAmount(resolutionAmount: JsonField) = apply { @@ -539,8 +577,8 @@ private constructor( } /** Date that the dispute was resolved. */ - fun resolutionDate(resolutionDate: OffsetDateTime) = - resolutionDate(JsonField.of(resolutionDate)) + fun resolutionDate(resolutionDate: OffsetDateTime?) = + resolutionDate(JsonField.ofNullable(resolutionDate)) /** Date that the dispute was resolved. */ fun resolutionDate(resolutionDate: JsonField) = apply { @@ -548,7 +586,8 @@ private constructor( } /** Note by Dispute team on the case resolution. */ - fun resolutionNote(resolutionNote: String) = resolutionNote(JsonField.of(resolutionNote)) + fun resolutionNote(resolutionNote: String?) = + resolutionNote(JsonField.ofNullable(resolutionNote)) /** Note by Dispute team on the case resolution. */ fun resolutionNote(resolutionNote: JsonField) = apply { @@ -575,8 +614,8 @@ private constructor( * - `WON_FIRST_CHARGEBACK`: Won first chargeback. * - `WON_PREARBITRATION`: Won prearbitration. */ - fun resolutionReason(resolutionReason: ResolutionReason) = - resolutionReason(JsonField.of(resolutionReason)) + fun resolutionReason(resolutionReason: ResolutionReason?) = + resolutionReason(JsonField.ofNullable(resolutionReason)) /** * Reason for the dispute resolution: @@ -664,25 +703,34 @@ private constructor( fun build(): Dispute = Dispute( - token, - amount, - arbitrationDate, - created, - customerFiledDate, - customerNote, - networkClaimIds.map { it.toImmutable() }, - networkFiledDate, - networkReasonCode, - prearbitrationDate, - primaryClaimId, - reason, - representmentDate, - resolutionAmount, - resolutionDate, - resolutionNote, - resolutionReason, - status, - transactionToken, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(arbitrationDate) { "`arbitrationDate` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(customerFiledDate) { + "`customerFiledDate` is required but was not set" + }, + checkNotNull(customerNote) { "`customerNote` is required but was not set" }, + checkNotNull(networkClaimIds) { "`networkClaimIds` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(networkFiledDate) { "`networkFiledDate` is required but was not set" }, + checkNotNull(networkReasonCode) { + "`networkReasonCode` is required but was not set" + }, + checkNotNull(prearbitrationDate) { + "`prearbitrationDate` is required but was not set" + }, + checkNotNull(primaryClaimId) { "`primaryClaimId` is required but was not set" }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(representmentDate) { + "`representmentDate` is required but was not set" + }, + checkNotNull(resolutionAmount) { "`resolutionAmount` is required but was not set" }, + checkNotNull(resolutionDate) { "`resolutionDate` is required but was not set" }, + checkNotNull(resolutionNote) { "`resolutionNote` is required but was not set" }, + checkNotNull(resolutionReason) { "`resolutionReason` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(transactionToken) { "`transactionToken` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeCreateParams.kt index e589306f..6cda6948 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeCreateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -42,12 +43,27 @@ constructor( /** Customer description of dispute */ fun customerNote(): String? = body.customerNote() - fun _additionalHeaders(): Headers = additionalHeaders + /** Amount to dispute */ + fun _amount(): JsonField = body._amount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Reason for dispute */ + fun _reason(): JsonField = body._reason() + + /** Transaction to dispute */ + fun _transactionToken(): JsonField = body._transactionToken() + + /** Date the customer filed the dispute */ + fun _customerFiledDate(): JsonField = body._customerFiledDate() + + /** Customer description of dispute */ + fun _customerNote(): JsonField = body._customerNote() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): DisputeCreateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -58,35 +74,79 @@ constructor( class DisputeCreateBody @JsonCreator internal constructor( - @JsonProperty("amount") private val amount: Long, - @JsonProperty("reason") private val reason: Reason, - @JsonProperty("transaction_token") private val transactionToken: String, - @JsonProperty("customer_filed_date") private val customerFiledDate: OffsetDateTime?, - @JsonProperty("customer_note") private val customerNote: String?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), + @JsonProperty("transaction_token") + @ExcludeMissing + private val transactionToken: JsonField = JsonMissing.of(), + @JsonProperty("customer_filed_date") + @ExcludeMissing + private val customerFiledDate: JsonField = JsonMissing.of(), + @JsonProperty("customer_note") + @ExcludeMissing + private val customerNote: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Amount to dispute */ - @JsonProperty("amount") fun amount(): Long = amount + fun amount(): Long = amount.getRequired("amount") /** Reason for dispute */ - @JsonProperty("reason") fun reason(): Reason = reason + fun reason(): Reason = reason.getRequired("reason") /** Transaction to dispute */ - @JsonProperty("transaction_token") fun transactionToken(): String = transactionToken + fun transactionToken(): String = transactionToken.getRequired("transaction_token") + + /** Date the customer filed the dispute */ + fun customerFiledDate(): OffsetDateTime? = + customerFiledDate.getNullable("customer_filed_date") + + /** Customer description of dispute */ + fun customerNote(): String? = customerNote.getNullable("customer_note") + + /** Amount to dispute */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** Reason for dispute */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** Transaction to dispute */ + @JsonProperty("transaction_token") + @ExcludeMissing + fun _transactionToken(): JsonField = transactionToken /** Date the customer filed the dispute */ @JsonProperty("customer_filed_date") - fun customerFiledDate(): OffsetDateTime? = customerFiledDate + @ExcludeMissing + fun _customerFiledDate(): JsonField = customerFiledDate /** Customer description of dispute */ - @JsonProperty("customer_note") fun customerNote(): String? = customerNote + @JsonProperty("customer_note") + @ExcludeMissing + fun _customerNote(): JsonField = customerNote @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): DisputeCreateBody = apply { + if (!validated) { + amount() + reason() + transactionToken() + customerFiledDate() + customerNote() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -96,11 +156,11 @@ constructor( class Builder { - private var amount: Long? = null - private var reason: Reason? = null - private var transactionToken: String? = null - private var customerFiledDate: OffsetDateTime? = null - private var customerNote: String? = null + private var amount: JsonField? = null + private var reason: JsonField? = null + private var transactionToken: JsonField? = null + private var customerFiledDate: JsonField = JsonMissing.of() + private var customerNote: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(disputeCreateBody: DisputeCreateBody) = apply { @@ -113,23 +173,42 @@ constructor( } /** Amount to dispute */ - fun amount(amount: Long) = apply { this.amount = amount } + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** Amount to dispute */ + fun amount(amount: JsonField) = apply { this.amount = amount } /** Reason for dispute */ - fun reason(reason: Reason) = apply { this.reason = reason } + fun reason(reason: Reason) = reason(JsonField.of(reason)) + + /** Reason for dispute */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** Transaction to dispute */ + fun transactionToken(transactionToken: String) = + transactionToken(JsonField.of(transactionToken)) /** Transaction to dispute */ - fun transactionToken(transactionToken: String) = apply { + fun transactionToken(transactionToken: JsonField) = apply { this.transactionToken = transactionToken } /** Date the customer filed the dispute */ - fun customerFiledDate(customerFiledDate: OffsetDateTime?) = apply { + fun customerFiledDate(customerFiledDate: OffsetDateTime) = + customerFiledDate(JsonField.of(customerFiledDate)) + + /** Date the customer filed the dispute */ + fun customerFiledDate(customerFiledDate: JsonField) = apply { this.customerFiledDate = customerFiledDate } /** Customer description of dispute */ - fun customerNote(customerNote: String?) = apply { this.customerNote = customerNote } + fun customerNote(customerNote: String) = customerNote(JsonField.of(customerNote)) + + /** Customer description of dispute */ + fun customerNote(customerNote: JsonField) = apply { + this.customerNote = customerNote + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -204,21 +283,61 @@ constructor( /** Amount to dispute */ fun amount(amount: Long) = apply { body.amount(amount) } + /** Amount to dispute */ + fun amount(amount: JsonField) = apply { body.amount(amount) } + /** Reason for dispute */ fun reason(reason: Reason) = apply { body.reason(reason) } + /** Reason for dispute */ + fun reason(reason: JsonField) = apply { body.reason(reason) } + /** Transaction to dispute */ fun transactionToken(transactionToken: String) = apply { body.transactionToken(transactionToken) } + /** Transaction to dispute */ + fun transactionToken(transactionToken: JsonField) = apply { + body.transactionToken(transactionToken) + } + /** Date the customer filed the dispute */ - fun customerFiledDate(customerFiledDate: OffsetDateTime?) = apply { + fun customerFiledDate(customerFiledDate: OffsetDateTime) = apply { body.customerFiledDate(customerFiledDate) } + /** Date the customer filed the dispute */ + fun customerFiledDate(customerFiledDate: JsonField) = apply { + body.customerFiledDate(customerFiledDate) + } + + /** Customer description of dispute */ + fun customerNote(customerNote: String) = apply { body.customerNote(customerNote) } + /** Customer description of dispute */ - fun customerNote(customerNote: String?) = apply { body.customerNote(customerNote) } + fun customerNote(customerNote: JsonField) = apply { + body.customerNote(customerNote) + } + + 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() @@ -318,25 +437,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): DisputeCreateParams = DisputeCreateParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeEvidence.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeEvidence.kt index d81b9525..a0814433 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeEvidence.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeEvidence.kt @@ -76,13 +76,15 @@ private constructor( fun uploadUrl(): String? = uploadUrl.getNullable("upload_url") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Timestamp of when dispute evidence was created. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Dispute token evidence is attached to. */ - @JsonProperty("dispute_token") @ExcludeMissing fun _disputeToken() = disputeToken + @JsonProperty("dispute_token") + @ExcludeMissing + fun _disputeToken(): JsonField = disputeToken /** * Upload status types: @@ -92,18 +94,22 @@ private constructor( * - `REJECTED` - Evidence was rejected. * - `UPLOADED` - Evidence was uploaded. */ - @JsonProperty("upload_status") @ExcludeMissing fun _uploadStatus() = uploadStatus + @JsonProperty("upload_status") + @ExcludeMissing + fun _uploadStatus(): JsonField = uploadStatus /** URL to download evidence. Only shown when `upload_status` is `UPLOADED`. */ - @JsonProperty("download_url") @ExcludeMissing fun _downloadUrl() = downloadUrl + @JsonProperty("download_url") + @ExcludeMissing + fun _downloadUrl(): JsonField = downloadUrl /** * File name of evidence. Recommended to give the dispute evidence a human-readable identifier. */ - @JsonProperty("filename") @ExcludeMissing fun _filename() = filename + @JsonProperty("filename") @ExcludeMissing fun _filename(): JsonField = filename /** URL to upload evidence. Only shown when `upload_status` is `PENDING`. */ - @JsonProperty("upload_url") @ExcludeMissing fun _uploadUrl() = uploadUrl + @JsonProperty("upload_url") @ExcludeMissing fun _uploadUrl(): JsonField = uploadUrl @JsonAnyGetter @ExcludeMissing @@ -133,10 +139,10 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var disputeToken: JsonField = JsonMissing.of() - private var uploadStatus: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var created: JsonField? = null + private var disputeToken: JsonField? = null + private var uploadStatus: JsonField? = null private var downloadUrl: JsonField = JsonMissing.of() private var filename: JsonField = JsonMissing.of() private var uploadUrl: JsonField = JsonMissing.of() @@ -240,10 +246,10 @@ private constructor( fun build(): DisputeEvidence = DisputeEvidence( - token, - created, - disputeToken, - uploadStatus, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(disputeToken) { "`disputeToken` is required but was not set" }, + checkNotNull(uploadStatus) { "`uploadStatus` is required but was not set" }, downloadUrl, filename, uploadUrl, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeInitiateEvidenceUploadParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeInitiateEvidenceUploadParams.kt index 4fd1a26e..ae66eb1f 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeInitiateEvidenceUploadParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeInitiateEvidenceUploadParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -34,12 +36,15 @@ constructor( /** Filename of the evidence. */ fun filename(): String? = body.filename() + /** Filename of the evidence. */ + fun _filename(): JsonField = body._filename() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): DisputeInitiateEvidenceUploadBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -57,18 +62,32 @@ constructor( class DisputeInitiateEvidenceUploadBody @JsonCreator internal constructor( - @JsonProperty("filename") private val filename: String?, + @JsonProperty("filename") + @ExcludeMissing + private val filename: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Filename of the evidence. */ - @JsonProperty("filename") fun filename(): String? = filename + fun filename(): String? = filename.getNullable("filename") + + /** Filename of the evidence. */ + @JsonProperty("filename") @ExcludeMissing fun _filename(): JsonField = filename @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): DisputeInitiateEvidenceUploadBody = apply { + if (!validated) { + filename() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -78,7 +97,7 @@ constructor( class Builder { - private var filename: String? = null + private var filename: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -90,7 +109,10 @@ constructor( } /** Filename of the evidence. */ - fun filename(filename: String?) = apply { this.filename = filename } + fun filename(filename: String) = filename(JsonField.of(filename)) + + /** Filename of the evidence. */ + fun filename(filename: JsonField) = apply { this.filename = filename } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -162,7 +184,29 @@ constructor( fun disputeToken(disputeToken: String) = apply { this.disputeToken = disputeToken } /** Filename of the evidence. */ - fun filename(filename: String?) = apply { body.filename(filename) } + fun filename(filename: String) = apply { body.filename(filename) } + + /** Filename of the evidence. */ + fun filename(filename: JsonField) = apply { body.filename(filename) } + + 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() @@ -262,25 +306,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): DisputeInitiateEvidenceUploadParams = DisputeInitiateEvidenceUploadParams( checkNotNull(disputeToken) { "`disputeToken` is required but was not set" }, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeUpdateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeUpdateParams.kt index ac3a0534..f35d7d9c 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeUpdateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeUpdateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -42,12 +43,24 @@ constructor( /** Reason for dispute */ fun reason(): Reason? = body.reason() - fun _additionalHeaders(): Headers = additionalHeaders + /** Amount to dispute */ + fun _amount(): JsonField = body._amount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Date the customer filed the dispute */ + fun _customerFiledDate(): JsonField = body._customerFiledDate() + + /** Customer description of dispute */ + fun _customerNote(): JsonField = body._customerNote() + + /** Reason for dispute */ + fun _reason(): JsonField = body._reason() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): DisputeUpdateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -65,31 +78,67 @@ constructor( class DisputeUpdateBody @JsonCreator internal constructor( - @JsonProperty("amount") private val amount: Long?, - @JsonProperty("customer_filed_date") private val customerFiledDate: OffsetDateTime?, - @JsonProperty("customer_note") private val customerNote: String?, - @JsonProperty("reason") private val reason: Reason?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("customer_filed_date") + @ExcludeMissing + private val customerFiledDate: JsonField = JsonMissing.of(), + @JsonProperty("customer_note") + @ExcludeMissing + private val customerNote: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Amount to dispute */ - @JsonProperty("amount") fun amount(): Long? = amount + fun amount(): Long? = amount.getNullable("amount") + + /** Date the customer filed the dispute */ + fun customerFiledDate(): OffsetDateTime? = + customerFiledDate.getNullable("customer_filed_date") + + /** Customer description of dispute */ + fun customerNote(): String? = customerNote.getNullable("customer_note") + + /** Reason for dispute */ + fun reason(): Reason? = reason.getNullable("reason") + + /** Amount to dispute */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** Date the customer filed the dispute */ @JsonProperty("customer_filed_date") - fun customerFiledDate(): OffsetDateTime? = customerFiledDate + @ExcludeMissing + fun _customerFiledDate(): JsonField = customerFiledDate /** Customer description of dispute */ - @JsonProperty("customer_note") fun customerNote(): String? = customerNote + @JsonProperty("customer_note") + @ExcludeMissing + fun _customerNote(): JsonField = customerNote /** Reason for dispute */ - @JsonProperty("reason") fun reason(): Reason? = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): DisputeUpdateBody = apply { + if (!validated) { + amount() + customerFiledDate() + customerNote() + reason() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -99,10 +148,10 @@ constructor( class Builder { - private var amount: Long? = null - private var customerFiledDate: OffsetDateTime? = null - private var customerNote: String? = null - private var reason: Reason? = null + private var amount: JsonField = JsonMissing.of() + private var customerFiledDate: JsonField = JsonMissing.of() + private var customerNote: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(disputeUpdateBody: DisputeUpdateBody) = apply { @@ -114,21 +163,33 @@ constructor( } /** Amount to dispute */ - fun amount(amount: Long?) = apply { this.amount = amount } + fun amount(amount: Long) = amount(JsonField.of(amount)) /** Amount to dispute */ - fun amount(amount: Long) = amount(amount as Long?) + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Date the customer filed the dispute */ + fun customerFiledDate(customerFiledDate: OffsetDateTime) = + customerFiledDate(JsonField.of(customerFiledDate)) /** Date the customer filed the dispute */ - fun customerFiledDate(customerFiledDate: OffsetDateTime?) = apply { + fun customerFiledDate(customerFiledDate: JsonField) = apply { this.customerFiledDate = customerFiledDate } /** Customer description of dispute */ - fun customerNote(customerNote: String?) = apply { this.customerNote = customerNote } + fun customerNote(customerNote: String) = customerNote(JsonField.of(customerNote)) + + /** Customer description of dispute */ + fun customerNote(customerNote: JsonField) = apply { + this.customerNote = customerNote + } + + /** Reason for dispute */ + fun reason(reason: Reason) = reason(JsonField.of(reason)) /** Reason for dispute */ - fun reason(reason: Reason?) = apply { this.reason = reason } + fun reason(reason: JsonField) = apply { this.reason = reason } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -202,21 +263,53 @@ constructor( fun disputeToken(disputeToken: String) = apply { this.disputeToken = disputeToken } /** Amount to dispute */ - fun amount(amount: Long?) = apply { body.amount(amount) } + fun amount(amount: Long) = apply { body.amount(amount) } /** Amount to dispute */ - fun amount(amount: Long) = amount(amount as Long?) + fun amount(amount: JsonField) = apply { body.amount(amount) } /** Date the customer filed the dispute */ - fun customerFiledDate(customerFiledDate: OffsetDateTime?) = apply { + fun customerFiledDate(customerFiledDate: OffsetDateTime) = apply { + body.customerFiledDate(customerFiledDate) + } + + /** Date the customer filed the dispute */ + fun customerFiledDate(customerFiledDate: JsonField) = apply { body.customerFiledDate(customerFiledDate) } /** Customer description of dispute */ - fun customerNote(customerNote: String?) = apply { body.customerNote(customerNote) } + fun customerNote(customerNote: String) = apply { body.customerNote(customerNote) } + + /** Customer description of dispute */ + fun customerNote(customerNote: JsonField) = apply { + body.customerNote(customerNote) + } + + /** Reason for dispute */ + fun reason(reason: Reason) = apply { body.reason(reason) } /** Reason for dispute */ - fun reason(reason: Reason?) = apply { body.reason(reason) } + fun reason(reason: JsonField) = apply { body.reason(reason) } + + 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() @@ -316,25 +409,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): DisputeUpdateParams = DisputeUpdateParams( checkNotNull(disputeToken) { "`disputeToken` is required but was not set" }, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Document.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Document.kt index 6e514ec3..1d2897ad 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Document.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Document.kt @@ -56,23 +56,28 @@ private constructor( requiredDocumentUploads.getRequired("required_document_uploads") /** Globally unique identifier for the document. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Globally unique identifier for the account holder. */ @JsonProperty("account_holder_token") @ExcludeMissing - fun _accountHolderToken() = accountHolderToken + fun _accountHolderToken(): JsonField = accountHolderToken /** Type of documentation to be submitted for verification of an account holder */ - @JsonProperty("document_type") @ExcludeMissing fun _documentType() = documentType + @JsonProperty("document_type") + @ExcludeMissing + fun _documentType(): JsonField = documentType /** Globally unique identifier for an entity. */ - @JsonProperty("entity_token") @ExcludeMissing fun _entityToken() = entityToken + @JsonProperty("entity_token") + @ExcludeMissing + fun _entityToken(): JsonField = entityToken /** Represents a single image of the document to upload. */ @JsonProperty("required_document_uploads") @ExcludeMissing - fun _requiredDocumentUploads() = requiredDocumentUploads + fun _requiredDocumentUploads(): JsonField> = + requiredDocumentUploads @JsonAnyGetter @ExcludeMissing @@ -100,12 +105,11 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountHolderToken: JsonField = JsonMissing.of() - private var documentType: JsonField = JsonMissing.of() - private var entityToken: JsonField = JsonMissing.of() - private var requiredDocumentUploads: JsonField> = - JsonMissing.of() + private var token: JsonField? = null + private var accountHolderToken: JsonField? = null + private var documentType: JsonField? = null + private var entityToken: JsonField? = null + private var requiredDocumentUploads: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(document: Document) = apply { @@ -113,7 +117,7 @@ private constructor( accountHolderToken = document.accountHolderToken documentType = document.documentType entityToken = document.entityToken - requiredDocumentUploads = document.requiredDocumentUploads + requiredDocumentUploads = document.requiredDocumentUploads.map { it.toMutableList() } additionalProperties = document.additionalProperties.toMutableMap() } @@ -153,7 +157,21 @@ private constructor( /** Represents a single image of the document to upload. */ fun requiredDocumentUploads( requiredDocumentUploads: JsonField> - ) = apply { this.requiredDocumentUploads = requiredDocumentUploads } + ) = apply { + this.requiredDocumentUploads = requiredDocumentUploads.map { it.toMutableList() } + } + + /** Represents a single image of the document to upload. */ + fun addRequiredDocumentUpload(requiredDocumentUpload: RequiredDocumentUpload) = apply { + requiredDocumentUploads = + (requiredDocumentUploads ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(requiredDocumentUpload) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -176,11 +194,16 @@ private constructor( fun build(): Document = Document( - token, - accountHolderToken, - documentType, - entityToken, - requiredDocumentUploads.map { it.toImmutable() }, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountHolderToken) { + "`accountHolderToken` is required but was not set" + }, + checkNotNull(documentType) { "`documentType` is required but was not set" }, + checkNotNull(entityToken) { "`entityToken` is required but was not set" }, + checkNotNull(requiredDocumentUploads) { + "`requiredDocumentUploads` is required but was not set" + } + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -417,7 +440,7 @@ private constructor( fun uploadUrl(): String = uploadUrl.getRequired("upload_url") /** Globally unique identifier for the document upload. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * A list of status reasons associated with a KYB account holder that have been satisfied by @@ -425,13 +448,15 @@ private constructor( */ @JsonProperty("accepted_entity_status_reasons") @ExcludeMissing - fun _acceptedEntityStatusReasons() = acceptedEntityStatusReasons + fun _acceptedEntityStatusReasons(): JsonField> = acceptedEntityStatusReasons /** When the document upload was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Type of image to upload. */ - @JsonProperty("image_type") @ExcludeMissing fun _imageType() = imageType + @JsonProperty("image_type") + @ExcludeMissing + fun _imageType(): JsonField = imageType /** * A list of status reasons associated with a KYB account holder that have not been @@ -439,16 +464,20 @@ private constructor( */ @JsonProperty("rejected_entity_status_reasons") @ExcludeMissing - fun _rejectedEntityStatusReasons() = rejectedEntityStatusReasons + fun _rejectedEntityStatusReasons(): JsonField> = rejectedEntityStatusReasons /** Status of an account holder's document upload. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status /** Reasons for document image upload status. */ - @JsonProperty("status_reasons") @ExcludeMissing fun _statusReasons() = statusReasons + @JsonProperty("status_reasons") + @ExcludeMissing + fun _statusReasons(): JsonField> = statusReasons /** When the document upload was last updated */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated /** * URL to upload document image to. @@ -457,7 +486,7 @@ private constructor( * the URLs by retrieving the document upload from `GET * /account_holders/{account_holder_token}/documents`. */ - @JsonProperty("upload_url") @ExcludeMissing fun _uploadUrl() = uploadUrl + @JsonProperty("upload_url") @ExcludeMissing fun _uploadUrl(): JsonField = uploadUrl @JsonAnyGetter @ExcludeMissing @@ -489,26 +518,27 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var acceptedEntityStatusReasons: JsonField> = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var imageType: JsonField = JsonMissing.of() - private var rejectedEntityStatusReasons: JsonField> = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var statusReasons: JsonField> = - JsonMissing.of() - private var updated: JsonField = JsonMissing.of() - private var uploadUrl: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var acceptedEntityStatusReasons: JsonField>? = null + private var created: JsonField? = null + private var imageType: JsonField? = null + private var rejectedEntityStatusReasons: JsonField>? = null + private var status: JsonField? = null + private var statusReasons: JsonField>? = null + private var updated: JsonField? = null + private var uploadUrl: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(requiredDocumentUpload: RequiredDocumentUpload) = apply { token = requiredDocumentUpload.token - acceptedEntityStatusReasons = requiredDocumentUpload.acceptedEntityStatusReasons + acceptedEntityStatusReasons = + requiredDocumentUpload.acceptedEntityStatusReasons.map { it.toMutableList() } created = requiredDocumentUpload.created imageType = requiredDocumentUpload.imageType - rejectedEntityStatusReasons = requiredDocumentUpload.rejectedEntityStatusReasons + rejectedEntityStatusReasons = + requiredDocumentUpload.rejectedEntityStatusReasons.map { it.toMutableList() } status = requiredDocumentUpload.status - statusReasons = requiredDocumentUpload.statusReasons + statusReasons = requiredDocumentUpload.statusReasons.map { it.toMutableList() } updated = requiredDocumentUpload.updated uploadUrl = requiredDocumentUpload.uploadUrl additionalProperties = requiredDocumentUpload.additionalProperties.toMutableMap() @@ -533,9 +563,25 @@ private constructor( */ fun acceptedEntityStatusReasons(acceptedEntityStatusReasons: JsonField>) = apply { - this.acceptedEntityStatusReasons = acceptedEntityStatusReasons + this.acceptedEntityStatusReasons = + acceptedEntityStatusReasons.map { it.toMutableList() } } + /** + * A list of status reasons associated with a KYB account holder that have been + * satisfied by the document upload + */ + fun addAcceptedEntityStatusReason(acceptedEntityStatusReason: String) = apply { + acceptedEntityStatusReasons = + (acceptedEntityStatusReasons ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(acceptedEntityStatusReason) + } + } + /** When the document upload was created */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -561,9 +607,25 @@ private constructor( */ fun rejectedEntityStatusReasons(rejectedEntityStatusReasons: JsonField>) = apply { - this.rejectedEntityStatusReasons = rejectedEntityStatusReasons + this.rejectedEntityStatusReasons = + rejectedEntityStatusReasons.map { it.toMutableList() } } + /** + * A list of status reasons associated with a KYB account holder that have not been + * satisfied by the document upload + */ + fun addRejectedEntityStatusReason(rejectedEntityStatusReason: String) = apply { + rejectedEntityStatusReasons = + (rejectedEntityStatusReasons ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(rejectedEntityStatusReason) + } + } + /** Status of an account holder's document upload. */ fun status(status: DocumentUploadStatus) = status(JsonField.of(status)) @@ -576,7 +638,19 @@ private constructor( /** Reasons for document image upload status. */ fun statusReasons(statusReasons: JsonField>) = apply { - this.statusReasons = statusReasons + this.statusReasons = statusReasons.map { it.toMutableList() } + } + + /** Reasons for document image upload status. */ + fun addStatusReason(statusReason: DocumentUploadStatusReasons) = apply { + statusReasons = + (statusReasons ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(statusReason) + } } /** When the document upload was last updated */ @@ -624,15 +698,22 @@ private constructor( fun build(): RequiredDocumentUpload = RequiredDocumentUpload( - token, - acceptedEntityStatusReasons.map { it.toImmutable() }, - created, - imageType, - rejectedEntityStatusReasons.map { it.toImmutable() }, - status, - statusReasons.map { it.toImmutable() }, - updated, - uploadUrl, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(acceptedEntityStatusReasons) { + "`acceptedEntityStatusReasons` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(imageType) { "`imageType` is required but was not set" }, + checkNotNull(rejectedEntityStatusReasons) { + "`rejectedEntityStatusReasons` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(statusReasons) { "`statusReasons` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(updated) { "`updated` is required but was not set" }, + checkNotNull(uploadUrl) { "`uploadUrl` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EnhancedCommercialDataRetrieveResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EnhancedCommercialDataRetrieveResponse.kt index d491f690..a359a4d2 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EnhancedCommercialDataRetrieveResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EnhancedCommercialDataRetrieveResponse.kt @@ -27,7 +27,7 @@ private constructor( fun data(): List = data.getRequired("data") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonAnyGetter @ExcludeMissing @@ -51,20 +51,33 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( enhancedCommercialDataRetrieveResponse: EnhancedCommercialDataRetrieveResponse ) = apply { - data = enhancedCommercialDataRetrieveResponse.data + data = enhancedCommercialDataRetrieveResponse.data.map { it.toMutableList() } additionalProperties = enhancedCommercialDataRetrieveResponse.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: EnhancedData) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(data) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -87,7 +100,8 @@ private constructor( fun build(): EnhancedCommercialDataRetrieveResponse = EnhancedCommercialDataRetrieveResponse( - data.map { it.toImmutable() }, + checkNotNull(data) { "`data` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EnhancedData.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EnhancedData.kt index 76d505f6..22ea10f8 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EnhancedData.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EnhancedData.kt @@ -52,17 +52,19 @@ private constructor( fun transactionToken(): String = transactionToken.getRequired("transaction_token") /** A unique identifier for the enhanced commercial data. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - @JsonProperty("common") @ExcludeMissing fun _common() = common + @JsonProperty("common") @ExcludeMissing fun _common(): JsonField = common /** The token of the event that the enhanced data is associated with. */ - @JsonProperty("event_token") @ExcludeMissing fun _eventToken() = eventToken + @JsonProperty("event_token") @ExcludeMissing fun _eventToken(): JsonField = eventToken - @JsonProperty("fleet") @ExcludeMissing fun _fleet() = fleet + @JsonProperty("fleet") @ExcludeMissing fun _fleet(): JsonField> = fleet /** The token of the transaction that the enhanced data is associated with. */ - @JsonProperty("transaction_token") @ExcludeMissing fun _transactionToken() = transactionToken + @JsonProperty("transaction_token") + @ExcludeMissing + fun _transactionToken(): JsonField = transactionToken @JsonAnyGetter @ExcludeMissing @@ -90,18 +92,18 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var common: JsonField = JsonMissing.of() - private var eventToken: JsonField = JsonMissing.of() - private var fleet: JsonField> = JsonMissing.of() - private var transactionToken: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var common: JsonField? = null + private var eventToken: JsonField? = null + private var fleet: JsonField>? = null + private var transactionToken: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(enhancedData: EnhancedData) = apply { token = enhancedData.token common = enhancedData.common eventToken = enhancedData.eventToken - fleet = enhancedData.fleet + fleet = enhancedData.fleet.map { it.toMutableList() } transactionToken = enhancedData.transactionToken additionalProperties = enhancedData.additionalProperties.toMutableMap() } @@ -124,7 +126,20 @@ private constructor( fun fleet(fleet: List) = fleet(JsonField.of(fleet)) - fun fleet(fleet: JsonField>) = apply { this.fleet = fleet } + fun fleet(fleet: JsonField>) = apply { + this.fleet = fleet.map { it.toMutableList() } + } + + fun addFleet(fleet: Fleet) = apply { + this.fleet = + (this.fleet ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(fleet) + } + } /** The token of the transaction that the enhanced data is associated with. */ fun transactionToken(transactionToken: String) = @@ -156,11 +171,12 @@ private constructor( fun build(): EnhancedData = EnhancedData( - token, - common, - eventToken, - fleet.map { it.toImmutable() }, - transactionToken, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(common) { "`common` is required but was not set" }, + checkNotNull(eventToken) { "`eventToken` is required but was not set" }, + checkNotNull(fleet) { "`fleet` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(transactionToken) { "`transactionToken` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -201,22 +217,26 @@ private constructor( /** The date of the order. */ fun orderDate(): LocalDate? = orderDate.getNullable("order_date") - @JsonProperty("line_items") @ExcludeMissing fun _lineItems() = lineItems + @JsonProperty("line_items") + @ExcludeMissing + fun _lineItems(): JsonField> = lineItems - @JsonProperty("tax") @ExcludeMissing fun _tax() = tax + @JsonProperty("tax") @ExcludeMissing fun _tax(): JsonField = tax /** A customer identifier. */ @JsonProperty("customer_reference_number") @ExcludeMissing - fun _customerReferenceNumber() = customerReferenceNumber + fun _customerReferenceNumber(): JsonField = customerReferenceNumber /** A merchant identifier. */ @JsonProperty("merchant_reference_number") @ExcludeMissing - fun _merchantReferenceNumber() = merchantReferenceNumber + fun _merchantReferenceNumber(): JsonField = merchantReferenceNumber /** The date of the order. */ - @JsonProperty("order_date") @ExcludeMissing fun _orderDate() = orderDate + @JsonProperty("order_date") + @ExcludeMissing + fun _orderDate(): JsonField = orderDate @JsonAnyGetter @ExcludeMissing @@ -244,15 +264,15 @@ private constructor( class Builder { - private var lineItems: JsonField> = JsonMissing.of() - private var tax: JsonField = JsonMissing.of() + private var lineItems: JsonField>? = null + private var tax: JsonField? = null private var customerReferenceNumber: JsonField = JsonMissing.of() private var merchantReferenceNumber: JsonField = JsonMissing.of() private var orderDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(commonData: CommonData) = apply { - lineItems = commonData.lineItems + lineItems = commonData.lineItems.map { it.toMutableList() } tax = commonData.tax customerReferenceNumber = commonData.customerReferenceNumber merchantReferenceNumber = commonData.merchantReferenceNumber @@ -263,7 +283,18 @@ private constructor( fun lineItems(lineItems: List) = lineItems(JsonField.of(lineItems)) fun lineItems(lineItems: JsonField>) = apply { - this.lineItems = lineItems + this.lineItems = lineItems.map { it.toMutableList() } + } + + fun addLineItem(lineItem: LineItem) = apply { + lineItems = + (lineItems ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(lineItem) + } } fun tax(tax: TaxData) = tax(JsonField.of(tax)) @@ -315,8 +346,9 @@ private constructor( fun build(): CommonData = CommonData( - lineItems.map { it.toImmutable() }, - tax, + checkNotNull(lineItems) { "`lineItems` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(tax) { "`tax` is required but was not set" }, customerReferenceNumber, merchantReferenceNumber, orderDate, @@ -358,16 +390,20 @@ private constructor( fun quantity(): Double? = quantity.getNullable("quantity") /** The price of the item purchased in merchant currency. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** A human-readable description of the item. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** An identifier for the item purchased. */ - @JsonProperty("product_code") @ExcludeMissing fun _productCode() = productCode + @JsonProperty("product_code") + @ExcludeMissing + fun _productCode(): JsonField = productCode /** The quantity of the item purchased. */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -513,13 +549,17 @@ private constructor( fun merchantTaxId(): String? = merchantTaxId.getNullable("merchant_tax_id") /** The amount of tax collected. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** A flag indicating whether the transaction is tax exempt or not. */ - @JsonProperty("exempt") @ExcludeMissing fun _exempt() = exempt + @JsonProperty("exempt") + @ExcludeMissing + fun _exempt(): JsonField = exempt /** The tax ID of the merchant. */ - @JsonProperty("merchant_tax_id") @ExcludeMissing fun _merchantTaxId() = merchantTaxId + @JsonProperty("merchant_tax_id") + @ExcludeMissing + fun _merchantTaxId(): JsonField = merchantTaxId @JsonAnyGetter @ExcludeMissing @@ -757,27 +797,35 @@ private constructor( */ fun vehicleNumber(): String? = vehicleNumber.getNullable("vehicle_number") - @JsonProperty("amount_totals") @ExcludeMissing fun _amountTotals() = amountTotals + @JsonProperty("amount_totals") + @ExcludeMissing + fun _amountTotals(): JsonField = amountTotals - @JsonProperty("fuel") @ExcludeMissing fun _fuel() = fuel + @JsonProperty("fuel") @ExcludeMissing fun _fuel(): JsonField = fuel /** * The driver number entered into the terminal at the time of sale, with leading zeros * stripped. */ - @JsonProperty("driver_number") @ExcludeMissing fun _driverNumber() = driverNumber + @JsonProperty("driver_number") + @ExcludeMissing + fun _driverNumber(): JsonField = driverNumber /** The odometer reading entered into the terminal at the time of sale. */ - @JsonProperty("odometer") @ExcludeMissing fun _odometer() = odometer + @JsonProperty("odometer") @ExcludeMissing fun _odometer(): JsonField = odometer /** The type of fuel service. */ - @JsonProperty("service_type") @ExcludeMissing fun _serviceType() = serviceType + @JsonProperty("service_type") + @ExcludeMissing + fun _serviceType(): JsonField = serviceType /** * The vehicle number entered into the terminal at the time of sale, with leading zeros * stripped. */ - @JsonProperty("vehicle_number") @ExcludeMissing fun _vehicleNumber() = vehicleNumber + @JsonProperty("vehicle_number") + @ExcludeMissing + fun _vehicleNumber(): JsonField = vehicleNumber @JsonAnyGetter @ExcludeMissing @@ -806,8 +854,8 @@ private constructor( class Builder { - private var amountTotals: JsonField = JsonMissing.of() - private var fuel: JsonField = JsonMissing.of() + private var amountTotals: JsonField? = null + private var fuel: JsonField? = null private var driverNumber: JsonField = JsonMissing.of() private var odometer: JsonField = JsonMissing.of() private var serviceType: JsonField = JsonMissing.of() @@ -897,8 +945,8 @@ private constructor( fun build(): Fleet = Fleet( - amountTotals, - fuel, + checkNotNull(amountTotals) { "`amountTotals` is required but was not set" }, + checkNotNull(fuel) { "`fuel` is required but was not set" }, driverNumber, odometer, serviceType, @@ -934,13 +982,15 @@ private constructor( fun netSale(): Long? = netSale.getNullable("net_sale") /** The discount applied to the gross sale amount. */ - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount /** The gross sale amount. */ - @JsonProperty("gross_sale") @ExcludeMissing fun _grossSale() = grossSale + @JsonProperty("gross_sale") + @ExcludeMissing + fun _grossSale(): JsonField = grossSale /** The amount after discount. */ - @JsonProperty("net_sale") @ExcludeMissing fun _netSale() = netSale + @JsonProperty("net_sale") @ExcludeMissing fun _netSale(): JsonField = netSale @JsonAnyGetter @ExcludeMissing @@ -1078,16 +1128,20 @@ private constructor( fun unitPrice(): Long? = unitPrice.getNullable("unit_price") /** The quantity of fuel purchased. */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity /** The type of fuel purchased. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** Unit of measure for fuel disbursement. */ - @JsonProperty("unit_of_measure") @ExcludeMissing fun _unitOfMeasure() = unitOfMeasure + @JsonProperty("unit_of_measure") + @ExcludeMissing + fun _unitOfMeasure(): JsonField = unitOfMeasure /** The price per unit of fuel. */ - @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice() = unitPrice + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Event.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Event.kt index 53ade7c7..65a44067 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Event.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Event.kt @@ -79,14 +79,14 @@ private constructor( fun payload(): Payload = payload.getRequired("payload") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * An RFC 3339 timestamp for when the event was created. UTC time zone. * * If no timezone is specified, UTC will be used. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** * Event types: @@ -116,9 +116,9 @@ private constructor( * - `digital_wallet.tokenization_updated` - Notification that a digital wallet tokenization's * status has changed. */ - @JsonProperty("event_type") @ExcludeMissing fun _eventType() = eventType + @JsonProperty("event_type") @ExcludeMissing fun _eventType(): JsonField = eventType - @JsonProperty("payload") @ExcludeMissing fun _payload() = payload + @JsonProperty("payload") @ExcludeMissing fun _payload(): JsonField = payload @JsonAnyGetter @ExcludeMissing @@ -145,10 +145,10 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var eventType: JsonField = JsonMissing.of() - private var payload: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var created: JsonField? = null + private var eventType: JsonField? = null + private var payload: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(event: Event) = apply { @@ -268,10 +268,10 @@ private constructor( fun build(): Event = Event( - token, - created, - eventType, - payload, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(eventType) { "`eventType` is required but was not set" }, + checkNotNull(payload) { "`payload` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscription.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscription.kt index 4cc266d4..4ee3dc8a 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscription.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscription.kt @@ -50,17 +50,19 @@ private constructor( fun eventTypes(): List? = eventTypes.getNullable("event_types") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** A description of the subscription. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** Whether the subscription is disabled. */ - @JsonProperty("disabled") @ExcludeMissing fun _disabled() = disabled + @JsonProperty("disabled") @ExcludeMissing fun _disabled(): JsonField = disabled - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - @JsonProperty("event_types") @ExcludeMissing fun _eventTypes() = eventTypes + @JsonProperty("event_types") + @ExcludeMissing + fun _eventTypes(): JsonField> = eventTypes @JsonAnyGetter @ExcludeMissing @@ -88,11 +90,11 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var disabled: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var eventTypes: JsonField> = JsonMissing.of() + private var token: JsonField? = null + private var description: JsonField? = null + private var disabled: JsonField? = null + private var url: JsonField? = null + private var eventTypes: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventSubscription: EventSubscription) = apply { @@ -100,7 +102,7 @@ private constructor( description = eventSubscription.description disabled = eventSubscription.disabled url = eventSubscription.url - eventTypes = eventSubscription.eventTypes + eventTypes = eventSubscription.eventTypes.map { it.toMutableList() } additionalProperties = eventSubscription.additionalProperties.toMutableMap() } @@ -126,10 +128,21 @@ private constructor( fun url(url: JsonField) = apply { this.url = url } - fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) + fun eventTypes(eventTypes: List?) = eventTypes(JsonField.ofNullable(eventTypes)) fun eventTypes(eventTypes: JsonField>) = apply { - this.eventTypes = eventTypes + this.eventTypes = eventTypes.map { it.toMutableList() } + } + + fun addEventType(eventType: EventType) = apply { + eventTypes = + (eventTypes ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(eventType) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -153,11 +166,11 @@ private constructor( fun build(): EventSubscription = EventSubscription( - token, - description, - disabled, - url, - eventTypes.map { it.toImmutable() }, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(disabled) { "`disabled` is required but was not set" }, + checkNotNull(url) { "`url` is required but was not set" }, + (eventTypes ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionCreateParams.kt index 73bf1556..abdf8fb0 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionCreateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -41,12 +42,27 @@ constructor( */ fun eventTypes(): List? = body.eventTypes() - fun _additionalHeaders(): Headers = additionalHeaders + /** URL to which event webhooks will be sent. URL must be a valid HTTPS address. */ + fun _url(): JsonField = body._url() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Event subscription description. */ + fun _description(): JsonField = body._description() + + /** Whether the event subscription is active (false) or inactive (true). */ + fun _disabled(): JsonField = body._disabled() + + /** + * Indicates types of events that will be sent to this subscription. If left blank, all types + * will be sent. + */ + fun _eventTypes(): JsonField> = body._eventTypes() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): EventSubscriptionCreateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -57,33 +73,70 @@ constructor( class EventSubscriptionCreateBody @JsonCreator internal constructor( - @JsonProperty("url") private val url: String, - @JsonProperty("description") private val description: String?, - @JsonProperty("disabled") private val disabled: Boolean?, - @JsonProperty("event_types") private val eventTypes: List?, + @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("disabled") + @ExcludeMissing + private val disabled: JsonField = JsonMissing.of(), + @JsonProperty("event_types") + @ExcludeMissing + private val eventTypes: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** URL to which event webhooks will be sent. URL must be a valid HTTPS address. */ - @JsonProperty("url") fun url(): String = url + fun url(): String = url.getRequired("url") /** Event subscription description. */ - @JsonProperty("description") fun description(): String? = description + fun description(): String? = description.getNullable("description") /** Whether the event subscription is active (false) or inactive (true). */ - @JsonProperty("disabled") fun disabled(): Boolean? = disabled + fun disabled(): Boolean? = disabled.getNullable("disabled") /** * Indicates types of events that will be sent to this subscription. If left blank, all * types will be sent. */ - @JsonProperty("event_types") fun eventTypes(): List? = eventTypes + fun eventTypes(): List? = eventTypes.getNullable("event_types") + + /** URL to which event webhooks will be sent. URL must be a valid HTTPS address. */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** Event subscription description. */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** Whether the event subscription is active (false) or inactive (true). */ + @JsonProperty("disabled") @ExcludeMissing fun _disabled(): JsonField = disabled + + /** + * Indicates types of events that will be sent to this subscription. If left blank, all + * types will be sent. + */ + @JsonProperty("event_types") + @ExcludeMissing + fun _eventTypes(): JsonField> = eventTypes @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): EventSubscriptionCreateBody = apply { + if (!validated) { + url() + description() + disabled() + eventTypes() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -93,39 +146,53 @@ constructor( class Builder { - private var url: String? = null - private var description: String? = null - private var disabled: Boolean? = null - private var eventTypes: MutableList? = null + private var url: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var disabled: JsonField = JsonMissing.of() + private var eventTypes: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventSubscriptionCreateBody: EventSubscriptionCreateBody) = apply { url = eventSubscriptionCreateBody.url description = eventSubscriptionCreateBody.description disabled = eventSubscriptionCreateBody.disabled - eventTypes = eventSubscriptionCreateBody.eventTypes?.toMutableList() + eventTypes = eventSubscriptionCreateBody.eventTypes.map { it.toMutableList() } additionalProperties = eventSubscriptionCreateBody.additionalProperties.toMutableMap() } /** URL to which event webhooks will be sent. URL must be a valid HTTPS address. */ - fun url(url: String) = apply { this.url = url } + fun url(url: String) = url(JsonField.of(url)) + + /** URL to which event webhooks will be sent. URL must be a valid HTTPS address. */ + fun url(url: JsonField) = apply { this.url = url } + + /** Event subscription description. */ + fun description(description: String) = description(JsonField.of(description)) /** Event subscription description. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } /** Whether the event subscription is active (false) or inactive (true). */ - fun disabled(disabled: Boolean?) = apply { this.disabled = disabled } + fun disabled(disabled: Boolean) = disabled(JsonField.of(disabled)) /** Whether the event subscription is active (false) or inactive (true). */ - fun disabled(disabled: Boolean) = disabled(disabled as Boolean?) + fun disabled(disabled: JsonField) = apply { this.disabled = disabled } /** * Indicates types of events that will be sent to this subscription. If left blank, all * types will be sent. */ - fun eventTypes(eventTypes: List?) = apply { - this.eventTypes = eventTypes?.toMutableList() + fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) + + /** + * Indicates types of events that will be sent to this subscription. If left blank, all + * types will be sent. + */ + fun eventTypes(eventTypes: JsonField>) = apply { + this.eventTypes = eventTypes.map { it.toMutableList() } } /** @@ -133,7 +200,14 @@ constructor( * types will be sent. */ fun addEventType(eventType: EventType) = apply { - eventTypes = (eventTypes ?: mutableListOf()).apply { add(eventType) } + eventTypes = + (eventTypes ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(eventType) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -160,7 +234,7 @@ constructor( checkNotNull(url) { "`url` is required but was not set" }, description, disabled, - eventTypes?.toImmutable(), + (eventTypes ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -207,20 +281,34 @@ constructor( /** URL to which event webhooks will be sent. URL must be a valid HTTPS address. */ fun url(url: String) = apply { body.url(url) } + /** URL to which event webhooks will be sent. URL must be a valid HTTPS address. */ + fun url(url: JsonField) = apply { body.url(url) } + /** Event subscription description. */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String) = apply { body.description(description) } + + /** Event subscription description. */ + fun description(description: JsonField) = apply { body.description(description) } /** Whether the event subscription is active (false) or inactive (true). */ - fun disabled(disabled: Boolean?) = apply { body.disabled(disabled) } + fun disabled(disabled: Boolean) = apply { body.disabled(disabled) } /** Whether the event subscription is active (false) or inactive (true). */ - fun disabled(disabled: Boolean) = disabled(disabled as Boolean?) + fun disabled(disabled: JsonField) = apply { body.disabled(disabled) } + + /** + * Indicates types of events that will be sent to this subscription. If left blank, all + * types will be sent. + */ + fun eventTypes(eventTypes: List) = apply { body.eventTypes(eventTypes) } /** * Indicates types of events that will be sent to this subscription. If left blank, all * types will be sent. */ - fun eventTypes(eventTypes: List?) = apply { body.eventTypes(eventTypes) } + fun eventTypes(eventTypes: JsonField>) = apply { + body.eventTypes(eventTypes) + } /** * Indicates types of events that will be sent to this subscription. If left blank, all @@ -228,6 +316,25 @@ constructor( */ fun addEventType(eventType: EventType) = apply { body.addEventType(eventType) } + 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) @@ -326,25 +433,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): EventSubscriptionCreateParams = EventSubscriptionCreateParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionSendSimulatedExampleParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionSendSimulatedExampleParams.kt index 593a8a3c..2ae9e113 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionSendSimulatedExampleParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionSendSimulatedExampleParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -32,12 +33,15 @@ constructor( /** Event type to send example message for. */ fun eventType(): EventType? = body.eventType() + /** Event type to send example message for. */ + fun _eventType(): JsonField = body._eventType() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): EventSubscriptionSendSimulatedExampleBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -55,18 +59,34 @@ constructor( class EventSubscriptionSendSimulatedExampleBody @JsonCreator internal constructor( - @JsonProperty("event_type") private val eventType: EventType?, + @JsonProperty("event_type") + @ExcludeMissing + private val eventType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Event type to send example message for. */ - @JsonProperty("event_type") fun eventType(): EventType? = eventType + fun eventType(): EventType? = eventType.getNullable("event_type") + + /** Event type to send example message for. */ + @JsonProperty("event_type") + @ExcludeMissing + fun _eventType(): JsonField = eventType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): EventSubscriptionSendSimulatedExampleBody = apply { + if (!validated) { + eventType() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -76,7 +96,7 @@ constructor( class Builder { - private var eventType: EventType? = null + private var eventType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -88,7 +108,10 @@ constructor( } /** Event type to send example message for. */ - fun eventType(eventType: EventType?) = apply { this.eventType = eventType } + fun eventType(eventType: EventType) = eventType(JsonField.of(eventType)) + + /** Event type to send example message for. */ + fun eventType(eventType: JsonField) = apply { this.eventType = eventType } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -167,7 +190,29 @@ constructor( } /** Event type to send example message for. */ - fun eventType(eventType: EventType?) = apply { body.eventType(eventType) } + fun eventType(eventType: EventType) = apply { body.eventType(eventType) } + + /** Event type to send example message for. */ + fun eventType(eventType: JsonField) = apply { body.eventType(eventType) } + + 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() @@ -267,25 +312,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): EventSubscriptionSendSimulatedExampleParams = EventSubscriptionSendSimulatedExampleParams( checkNotNull(eventSubscriptionToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionUpdateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionUpdateParams.kt index c158ea02..e5ba5ec2 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionUpdateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionUpdateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -44,12 +45,27 @@ constructor( */ fun eventTypes(): List? = body.eventTypes() - fun _additionalHeaders(): Headers = additionalHeaders + /** URL to which event webhooks will be sent. URL must be a valid HTTPS address. */ + fun _url(): JsonField = body._url() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Event subscription description. */ + fun _description(): JsonField = body._description() + + /** Whether the event subscription is active (false) or inactive (true). */ + fun _disabled(): JsonField = body._disabled() + + /** + * Indicates types of events that will be sent to this subscription. If left blank, all types + * will be sent. + */ + fun _eventTypes(): JsonField> = body._eventTypes() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): EventSubscriptionUpdateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -67,33 +83,70 @@ constructor( class EventSubscriptionUpdateBody @JsonCreator internal constructor( - @JsonProperty("url") private val url: String, - @JsonProperty("description") private val description: String?, - @JsonProperty("disabled") private val disabled: Boolean?, - @JsonProperty("event_types") private val eventTypes: List?, + @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("disabled") + @ExcludeMissing + private val disabled: JsonField = JsonMissing.of(), + @JsonProperty("event_types") + @ExcludeMissing + private val eventTypes: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** URL to which event webhooks will be sent. URL must be a valid HTTPS address. */ - @JsonProperty("url") fun url(): String = url + fun url(): String = url.getRequired("url") /** Event subscription description. */ - @JsonProperty("description") fun description(): String? = description + fun description(): String? = description.getNullable("description") /** Whether the event subscription is active (false) or inactive (true). */ - @JsonProperty("disabled") fun disabled(): Boolean? = disabled + fun disabled(): Boolean? = disabled.getNullable("disabled") /** * Indicates types of events that will be sent to this subscription. If left blank, all * types will be sent. */ - @JsonProperty("event_types") fun eventTypes(): List? = eventTypes + fun eventTypes(): List? = eventTypes.getNullable("event_types") + + /** URL to which event webhooks will be sent. URL must be a valid HTTPS address. */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** Event subscription description. */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** Whether the event subscription is active (false) or inactive (true). */ + @JsonProperty("disabled") @ExcludeMissing fun _disabled(): JsonField = disabled + + /** + * Indicates types of events that will be sent to this subscription. If left blank, all + * types will be sent. + */ + @JsonProperty("event_types") + @ExcludeMissing + fun _eventTypes(): JsonField> = eventTypes @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): EventSubscriptionUpdateBody = apply { + if (!validated) { + url() + description() + disabled() + eventTypes() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -103,39 +156,53 @@ constructor( class Builder { - private var url: String? = null - private var description: String? = null - private var disabled: Boolean? = null - private var eventTypes: MutableList? = null + private var url: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var disabled: JsonField = JsonMissing.of() + private var eventTypes: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(eventSubscriptionUpdateBody: EventSubscriptionUpdateBody) = apply { url = eventSubscriptionUpdateBody.url description = eventSubscriptionUpdateBody.description disabled = eventSubscriptionUpdateBody.disabled - eventTypes = eventSubscriptionUpdateBody.eventTypes?.toMutableList() + eventTypes = eventSubscriptionUpdateBody.eventTypes.map { it.toMutableList() } additionalProperties = eventSubscriptionUpdateBody.additionalProperties.toMutableMap() } /** URL to which event webhooks will be sent. URL must be a valid HTTPS address. */ - fun url(url: String) = apply { this.url = url } + fun url(url: String) = url(JsonField.of(url)) + + /** URL to which event webhooks will be sent. URL must be a valid HTTPS address. */ + fun url(url: JsonField) = apply { this.url = url } + + /** Event subscription description. */ + fun description(description: String) = description(JsonField.of(description)) /** Event subscription description. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: JsonField) = apply { + this.description = description + } /** Whether the event subscription is active (false) or inactive (true). */ - fun disabled(disabled: Boolean?) = apply { this.disabled = disabled } + fun disabled(disabled: Boolean) = disabled(JsonField.of(disabled)) /** Whether the event subscription is active (false) or inactive (true). */ - fun disabled(disabled: Boolean) = disabled(disabled as Boolean?) + fun disabled(disabled: JsonField) = apply { this.disabled = disabled } /** * Indicates types of events that will be sent to this subscription. If left blank, all * types will be sent. */ - fun eventTypes(eventTypes: List?) = apply { - this.eventTypes = eventTypes?.toMutableList() + fun eventTypes(eventTypes: List) = eventTypes(JsonField.of(eventTypes)) + + /** + * Indicates types of events that will be sent to this subscription. If left blank, all + * types will be sent. + */ + fun eventTypes(eventTypes: JsonField>) = apply { + this.eventTypes = eventTypes.map { it.toMutableList() } } /** @@ -143,7 +210,14 @@ constructor( * types will be sent. */ fun addEventType(eventType: EventType) = apply { - eventTypes = (eventTypes ?: mutableListOf()).apply { add(eventType) } + eventTypes = + (eventTypes ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(eventType) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -170,7 +244,7 @@ constructor( checkNotNull(url) { "`url` is required but was not set" }, description, disabled, - eventTypes?.toImmutable(), + (eventTypes ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -223,20 +297,34 @@ constructor( /** URL to which event webhooks will be sent. URL must be a valid HTTPS address. */ fun url(url: String) = apply { body.url(url) } + /** URL to which event webhooks will be sent. URL must be a valid HTTPS address. */ + fun url(url: JsonField) = apply { body.url(url) } + /** Event subscription description. */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String) = apply { body.description(description) } + + /** Event subscription description. */ + fun description(description: JsonField) = apply { body.description(description) } /** Whether the event subscription is active (false) or inactive (true). */ - fun disabled(disabled: Boolean?) = apply { body.disabled(disabled) } + fun disabled(disabled: Boolean) = apply { body.disabled(disabled) } /** Whether the event subscription is active (false) or inactive (true). */ - fun disabled(disabled: Boolean) = disabled(disabled as Boolean?) + fun disabled(disabled: JsonField) = apply { body.disabled(disabled) } + + /** + * Indicates types of events that will be sent to this subscription. If left blank, all + * types will be sent. + */ + fun eventTypes(eventTypes: List) = apply { body.eventTypes(eventTypes) } /** * Indicates types of events that will be sent to this subscription. If left blank, all * types will be sent. */ - fun eventTypes(eventTypes: List?) = apply { body.eventTypes(eventTypes) } + fun eventTypes(eventTypes: JsonField>) = apply { + body.eventTypes(eventTypes) + } /** * Indicates types of events that will be sent to this subscription. If left blank, all @@ -244,6 +332,25 @@ constructor( */ fun addEventType(eventType: EventType) = apply { body.addEventType(eventType) } + 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) @@ -342,25 +449,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): EventSubscriptionUpdateParams = EventSubscriptionUpdateParams( checkNotNull(eventSubscriptionToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExtendedCredit.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExtendedCredit.kt index 6171ae8c..846c67ef 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExtendedCredit.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExtendedCredit.kt @@ -27,7 +27,9 @@ private constructor( fun creditExtended(): Long = creditExtended.getRequired("credit_extended") - @JsonProperty("credit_extended") @ExcludeMissing fun _creditExtended() = creditExtended + @JsonProperty("credit_extended") + @ExcludeMissing + fun _creditExtended(): JsonField = creditExtended @JsonAnyGetter @ExcludeMissing @@ -51,7 +53,7 @@ private constructor( class Builder { - private var creditExtended: JsonField = JsonMissing.of() + private var creditExtended: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(extendedCredit: ExtendedCredit) = apply { @@ -85,7 +87,10 @@ private constructor( } fun build(): ExtendedCredit = - ExtendedCredit(creditExtended, additionalProperties.toImmutable()) + ExtendedCredit( + checkNotNull(creditExtended) { "`creditExtended` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountAddress.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountAddress.kt index 7827d666..b702d1a1 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountAddress.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountAddress.kt @@ -48,17 +48,17 @@ private constructor( fun address2(): String? = address2.getNullable("address2") - @JsonProperty("address1") @ExcludeMissing fun _address1() = address1 + @JsonProperty("address1") @ExcludeMissing fun _address1(): JsonField = address1 - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") @ExcludeMissing fun _postalCode(): JsonField = postalCode - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - @JsonProperty("address2") @ExcludeMissing fun _address2() = address2 + @JsonProperty("address2") @ExcludeMissing fun _address2(): JsonField = address2 @JsonAnyGetter @ExcludeMissing @@ -87,11 +87,11 @@ private constructor( class Builder { - private var address1: JsonField = JsonMissing.of() - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() + private var address1: JsonField? = null + private var city: JsonField? = null + private var country: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null private var address2: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -150,11 +150,11 @@ private constructor( fun build(): ExternalBankAccountAddress = ExternalBankAccountAddress( - address1, - city, - country, - postalCode, - state, + checkNotNull(address1) { "`address1` is required but was not set" }, + checkNotNull(city) { "`city` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(postalCode) { "`postalCode` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, address2, additionalProperties.toImmutable(), ) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountCreateParams.kt index 644ddc73..3cc3e0b1 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountCreateParams.kt @@ -18,6 +18,7 @@ import com.lithic.api.core.BaseSerializer import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.getOrThrow @@ -410,93 +411,231 @@ constructor( class BankVerifiedCreateBankAccountApiRequest @JsonCreator private constructor( - @JsonProperty("account_number") private val accountNumber: String, - @JsonProperty("country") private val country: String, - @JsonProperty("currency") private val currency: String, - @JsonProperty("financial_account_token") private val financialAccountToken: String, - @JsonProperty("owner") private val owner: String, - @JsonProperty("owner_type") private val ownerType: OwnerType, - @JsonProperty("routing_number") private val routingNumber: String, - @JsonProperty("type") private val type: AccountType, - @JsonProperty("verification_method") private val verificationMethod: VerificationMethod, - @JsonProperty("account_token") private val accountToken: String?, - @JsonProperty("address") private val address: ExternalBankAccountAddress?, - @JsonProperty("company_id") private val companyId: String?, - @JsonProperty("dob") private val dob: LocalDate?, - @JsonProperty("doing_business_as") private val doingBusinessAs: String?, - @JsonProperty("name") private val name: String?, - @JsonProperty("user_defined_id") private val userDefinedId: String?, - @JsonProperty("verification_enforcement") private val verificationEnforcement: Boolean?, + @JsonProperty("account_number") + @ExcludeMissing + private val accountNumber: JsonField = JsonMissing.of(), + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + private val financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("owner") + @ExcludeMissing + private val owner: JsonField = JsonMissing.of(), + @JsonProperty("owner_type") + @ExcludeMissing + private val ownerType: JsonField = JsonMissing.of(), + @JsonProperty("routing_number") + @ExcludeMissing + private val routingNumber: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), + @JsonProperty("verification_method") + @ExcludeMissing + private val verificationMethod: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + private val accountToken: JsonField = JsonMissing.of(), + @JsonProperty("address") + @ExcludeMissing + private val address: JsonField = JsonMissing.of(), + @JsonProperty("company_id") + @ExcludeMissing + private val companyId: JsonField = JsonMissing.of(), + @JsonProperty("dob") + @ExcludeMissing + private val dob: JsonField = JsonMissing.of(), + @JsonProperty("doing_business_as") + @ExcludeMissing + private val doingBusinessAs: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + private val userDefinedId: JsonField = JsonMissing.of(), + @JsonProperty("verification_enforcement") + @ExcludeMissing + private val verificationEnforcement: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Account Number */ - @JsonProperty("account_number") fun accountNumber(): String = accountNumber + fun accountNumber(): String = accountNumber.getRequired("account_number") + + /** + * The country that the bank account is located in using ISO 3166-1. We will only accept USA + * bank accounts e.g., USA + */ + fun country(): String = country.getRequired("country") + + /** currency of the external account 3-digit alphabetic ISO 4217 code */ + fun currency(): String = currency.getRequired("currency") + + /** The financial account token of the operating account to fund the micro deposits */ + fun financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + /** + * Legal Name of the business or individual who owns the external account. This will appear + * in statements + */ + fun owner(): String = owner.getRequired("owner") + + /** Owner Type */ + fun ownerType(): OwnerType = ownerType.getRequired("owner_type") + + /** Routing Number */ + fun routingNumber(): String = routingNumber.getRequired("routing_number") + + /** Account Type */ + fun type(): AccountType = type.getRequired("type") + + /** Verification Method */ + fun verificationMethod(): VerificationMethod = + verificationMethod.getRequired("verification_method") + + /** + * Indicates which Lithic account the external account is associated with. For external + * accounts that are associated with the program, account_token field returned will be null + */ + fun accountToken(): String? = accountToken.getNullable("account_token") + + /** Address */ + fun address(): ExternalBankAccountAddress? = address.getNullable("address") + + /** Optional field that helps identify bank accounts in receipts */ + fun companyId(): String? = companyId.getNullable("company_id") + + /** Date of Birth of the Individual that owns the external bank account */ + fun dob(): LocalDate? = dob.getNullable("dob") + + /** Doing Business As */ + fun doingBusinessAs(): String? = doingBusinessAs.getNullable("doing_business_as") + + /** The nickname for this External Bank Account */ + fun name(): String? = name.getNullable("name") + + /** User Defined ID */ + fun userDefinedId(): String? = userDefinedId.getNullable("user_defined_id") + + fun verificationEnforcement(): Boolean? = + verificationEnforcement.getNullable("verification_enforcement") + + /** Account Number */ + @JsonProperty("account_number") + @ExcludeMissing + fun _accountNumber(): JsonField = accountNumber /** * The country that the bank account is located in using ISO 3166-1. We will only accept USA * bank accounts e.g., USA */ - @JsonProperty("country") fun country(): String = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** currency of the external account 3-digit alphabetic ISO 4217 code */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The financial account token of the operating account to fund the micro deposits */ @JsonProperty("financial_account_token") - fun financialAccountToken(): String = financialAccountToken + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken /** * Legal Name of the business or individual who owns the external account. This will appear * in statements */ - @JsonProperty("owner") fun owner(): String = owner + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner /** Owner Type */ - @JsonProperty("owner_type") fun ownerType(): OwnerType = ownerType + @JsonProperty("owner_type") + @ExcludeMissing + fun _ownerType(): JsonField = ownerType /** Routing Number */ - @JsonProperty("routing_number") fun routingNumber(): String = routingNumber + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber /** Account Type */ - @JsonProperty("type") fun type(): AccountType = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** Verification Method */ @JsonProperty("verification_method") - fun verificationMethod(): VerificationMethod = verificationMethod + @ExcludeMissing + fun _verificationMethod(): JsonField = verificationMethod /** * Indicates which Lithic account the external account is associated with. For external * accounts that are associated with the program, account_token field returned will be null */ - @JsonProperty("account_token") fun accountToken(): String? = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** Address */ - @JsonProperty("address") fun address(): ExternalBankAccountAddress? = address + @JsonProperty("address") + @ExcludeMissing + fun _address(): JsonField = address /** Optional field that helps identify bank accounts in receipts */ - @JsonProperty("company_id") fun companyId(): String? = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Date of Birth of the Individual that owns the external bank account */ - @JsonProperty("dob") fun dob(): LocalDate? = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** Doing Business As */ - @JsonProperty("doing_business_as") fun doingBusinessAs(): String? = doingBusinessAs + @JsonProperty("doing_business_as") + @ExcludeMissing + fun _doingBusinessAs(): JsonField = doingBusinessAs /** The nickname for this External Bank Account */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** User Defined ID */ - @JsonProperty("user_defined_id") fun userDefinedId(): String? = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId @JsonProperty("verification_enforcement") - fun verificationEnforcement(): Boolean? = verificationEnforcement + @ExcludeMissing + fun _verificationEnforcement(): JsonField = verificationEnforcement @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BankVerifiedCreateBankAccountApiRequest = apply { + if (!validated) { + accountNumber() + country() + currency() + financialAccountToken() + owner() + ownerType() + routingNumber() + type() + verificationMethod() + accountToken() + address()?.validate() + companyId() + dob() + doingBusinessAs() + name() + userDefinedId() + verificationEnforcement() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -506,23 +645,23 @@ constructor( class Builder { - private var accountNumber: String? = null - private var country: String? = null - private var currency: String? = null - private var financialAccountToken: String? = null - private var owner: String? = null - private var ownerType: OwnerType? = null - private var routingNumber: String? = null - private var type: AccountType? = null - private var verificationMethod: VerificationMethod? = null - private var accountToken: String? = null - private var address: ExternalBankAccountAddress? = null - private var companyId: String? = null - private var dob: LocalDate? = null - private var doingBusinessAs: String? = null - private var name: String? = null - private var userDefinedId: String? = null - private var verificationEnforcement: Boolean? = null + private var accountNumber: JsonField? = null + private var country: JsonField? = null + private var currency: JsonField? = null + private var financialAccountToken: JsonField? = null + private var owner: JsonField? = null + private var ownerType: JsonField? = null + private var routingNumber: JsonField? = null + private var type: JsonField? = null + private var verificationMethod: JsonField? = null + private var accountToken: JsonField = JsonMissing.of() + private var address: JsonField = JsonMissing.of() + private var companyId: JsonField = JsonMissing.of() + private var dob: JsonField = JsonMissing.of() + private var doingBusinessAs: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() + private var verificationEnforcement: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -552,19 +691,37 @@ constructor( } /** Account Number */ - fun accountNumber(accountNumber: String) = apply { this.accountNumber = accountNumber } + fun accountNumber(accountNumber: String) = accountNumber(JsonField.of(accountNumber)) + + /** Account Number */ + fun accountNumber(accountNumber: JsonField) = apply { + this.accountNumber = accountNumber + } + + /** + * The country that the bank account is located in using ISO 3166-1. We will only accept + * USA bank accounts e.g., USA + */ + fun country(country: String) = country(JsonField.of(country)) /** * The country that the bank account is located in using ISO 3166-1. We will only accept * USA bank accounts e.g., USA */ - fun country(country: String) = apply { this.country = country } + fun country(country: JsonField) = apply { this.country = country } /** currency of the external account 3-digit alphabetic ISO 4217 code */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** currency of the external account 3-digit alphabetic ISO 4217 code */ + fun currency(currency: JsonField) = apply { this.currency = currency } /** The financial account token of the operating account to fund the micro deposits */ - fun financialAccountToken(financialAccountToken: String) = apply { + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** The financial account token of the operating account to fund the micro deposits */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { this.financialAccountToken = financialAccountToken } @@ -572,19 +729,40 @@ constructor( * Legal Name of the business or individual who owns the external account. This will * appear in statements */ - fun owner(owner: String) = apply { this.owner = owner } + fun owner(owner: String) = owner(JsonField.of(owner)) + + /** + * Legal Name of the business or individual who owns the external account. This will + * appear in statements + */ + fun owner(owner: JsonField) = apply { this.owner = owner } + + /** Owner Type */ + fun ownerType(ownerType: OwnerType) = ownerType(JsonField.of(ownerType)) /** Owner Type */ - fun ownerType(ownerType: OwnerType) = apply { this.ownerType = ownerType } + fun ownerType(ownerType: JsonField) = apply { this.ownerType = ownerType } + + /** Routing Number */ + fun routingNumber(routingNumber: String) = routingNumber(JsonField.of(routingNumber)) /** Routing Number */ - fun routingNumber(routingNumber: String) = apply { this.routingNumber = routingNumber } + fun routingNumber(routingNumber: JsonField) = apply { + this.routingNumber = routingNumber + } /** Account Type */ - fun type(type: AccountType) = apply { this.type = type } + fun type(type: AccountType) = type(JsonField.of(type)) + + /** Account Type */ + fun type(type: JsonField) = apply { this.type = type } + + /** Verification Method */ + fun verificationMethod(verificationMethod: VerificationMethod) = + verificationMethod(JsonField.of(verificationMethod)) /** Verification Method */ - fun verificationMethod(verificationMethod: VerificationMethod) = apply { + fun verificationMethod(verificationMethod: JsonField) = apply { this.verificationMethod = verificationMethod } @@ -593,34 +771,66 @@ constructor( * accounts that are associated with the program, account_token field returned will be * null */ - fun accountToken(accountToken: String?) = apply { this.accountToken = accountToken } + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Indicates which Lithic account the external account is associated with. For external + * accounts that are associated with the program, account_token field returned will be + * null + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } /** Address */ - fun address(address: ExternalBankAccountAddress?) = apply { this.address = address } + fun address(address: ExternalBankAccountAddress) = address(JsonField.of(address)) + + /** Address */ + fun address(address: JsonField) = apply { + this.address = address + } + + /** Optional field that helps identify bank accounts in receipts */ + fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** Optional field that helps identify bank accounts in receipts */ - fun companyId(companyId: String?) = apply { this.companyId = companyId } + fun companyId(companyId: JsonField) = apply { this.companyId = companyId } + + /** Date of Birth of the Individual that owns the external bank account */ + fun dob(dob: LocalDate) = dob(JsonField.of(dob)) /** Date of Birth of the Individual that owns the external bank account */ - fun dob(dob: LocalDate?) = apply { this.dob = dob } + fun dob(dob: JsonField) = apply { this.dob = dob } + + /** Doing Business As */ + fun doingBusinessAs(doingBusinessAs: String) = + doingBusinessAs(JsonField.of(doingBusinessAs)) /** Doing Business As */ - fun doingBusinessAs(doingBusinessAs: String?) = apply { + fun doingBusinessAs(doingBusinessAs: JsonField) = apply { this.doingBusinessAs = doingBusinessAs } /** The nickname for this External Bank Account */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The nickname for this External Bank Account */ + fun name(name: JsonField) = apply { this.name = name } /** User Defined ID */ - fun userDefinedId(userDefinedId: String?) = apply { this.userDefinedId = userDefinedId } + fun userDefinedId(userDefinedId: String) = userDefinedId(JsonField.of(userDefinedId)) - fun verificationEnforcement(verificationEnforcement: Boolean?) = apply { - this.verificationEnforcement = verificationEnforcement + /** User Defined ID */ + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId } fun verificationEnforcement(verificationEnforcement: Boolean) = - verificationEnforcement(verificationEnforcement as Boolean?) + verificationEnforcement(JsonField.of(verificationEnforcement)) + + fun verificationEnforcement(verificationEnforcement: JsonField) = apply { + this.verificationEnforcement = verificationEnforcement + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -747,15 +957,33 @@ constructor( class PlaidCreateBankAccountApiRequest @JsonCreator private constructor( - @JsonProperty("owner") private val owner: String, - @JsonProperty("owner_type") private val ownerType: OwnerType, - @JsonProperty("processor_token") private val processorToken: String, - @JsonProperty("verification_method") private val verificationMethod: VerificationMethod, - @JsonProperty("account_token") private val accountToken: String?, - @JsonProperty("company_id") private val companyId: String?, - @JsonProperty("dob") private val dob: LocalDate?, - @JsonProperty("doing_business_as") private val doingBusinessAs: String?, - @JsonProperty("user_defined_id") private val userDefinedId: String?, + @JsonProperty("owner") + @ExcludeMissing + private val owner: JsonField = JsonMissing.of(), + @JsonProperty("owner_type") + @ExcludeMissing + private val ownerType: JsonField = JsonMissing.of(), + @JsonProperty("processor_token") + @ExcludeMissing + private val processorToken: JsonField = JsonMissing.of(), + @JsonProperty("verification_method") + @ExcludeMissing + private val verificationMethod: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + private val accountToken: JsonField = JsonMissing.of(), + @JsonProperty("company_id") + @ExcludeMissing + private val companyId: JsonField = JsonMissing.of(), + @JsonProperty("dob") + @ExcludeMissing + private val dob: JsonField = JsonMissing.of(), + @JsonProperty("doing_business_as") + @ExcludeMissing + private val doingBusinessAs: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + private val userDefinedId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -764,39 +992,100 @@ constructor( * Legal Name of the business or individual who owns the external account. This will appear * in statements */ - @JsonProperty("owner") fun owner(): String = owner + fun owner(): String = owner.getRequired("owner") /** Owner Type */ - @JsonProperty("owner_type") fun ownerType(): OwnerType = ownerType + fun ownerType(): OwnerType = ownerType.getRequired("owner_type") - @JsonProperty("processor_token") fun processorToken(): String = processorToken + fun processorToken(): String = processorToken.getRequired("processor_token") + + /** Verification Method */ + fun verificationMethod(): VerificationMethod = + verificationMethod.getRequired("verification_method") + + /** + * Indicates which Lithic account the external account is associated with. For external + * accounts that are associated with the program, account_token field returned will be null + */ + fun accountToken(): String? = accountToken.getNullable("account_token") + + /** Optional field that helps identify bank accounts in receipts */ + fun companyId(): String? = companyId.getNullable("company_id") + + /** Date of Birth of the Individual that owns the external bank account */ + fun dob(): LocalDate? = dob.getNullable("dob") + + /** Doing Business As */ + fun doingBusinessAs(): String? = doingBusinessAs.getNullable("doing_business_as") + + /** User Defined ID */ + fun userDefinedId(): String? = userDefinedId.getNullable("user_defined_id") + + /** + * Legal Name of the business or individual who owns the external account. This will appear + * in statements + */ + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner + + /** Owner Type */ + @JsonProperty("owner_type") + @ExcludeMissing + fun _ownerType(): JsonField = ownerType + + @JsonProperty("processor_token") + @ExcludeMissing + fun _processorToken(): JsonField = processorToken /** Verification Method */ @JsonProperty("verification_method") - fun verificationMethod(): VerificationMethod = verificationMethod + @ExcludeMissing + fun _verificationMethod(): JsonField = verificationMethod /** * Indicates which Lithic account the external account is associated with. For external * accounts that are associated with the program, account_token field returned will be null */ - @JsonProperty("account_token") fun accountToken(): String? = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** Optional field that helps identify bank accounts in receipts */ - @JsonProperty("company_id") fun companyId(): String? = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Date of Birth of the Individual that owns the external bank account */ - @JsonProperty("dob") fun dob(): LocalDate? = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** Doing Business As */ - @JsonProperty("doing_business_as") fun doingBusinessAs(): String? = doingBusinessAs + @JsonProperty("doing_business_as") + @ExcludeMissing + fun _doingBusinessAs(): JsonField = doingBusinessAs /** User Defined ID */ - @JsonProperty("user_defined_id") fun userDefinedId(): String? = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PlaidCreateBankAccountApiRequest = apply { + if (!validated) { + owner() + ownerType() + processorToken() + verificationMethod() + accountToken() + companyId() + dob() + doingBusinessAs() + userDefinedId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -806,15 +1095,15 @@ constructor( class Builder { - private var owner: String? = null - private var ownerType: OwnerType? = null - private var processorToken: String? = null - private var verificationMethod: VerificationMethod? = null - private var accountToken: String? = null - private var companyId: String? = null - private var dob: LocalDate? = null - private var doingBusinessAs: String? = null - private var userDefinedId: String? = null + private var owner: JsonField? = null + private var ownerType: JsonField? = null + private var processorToken: JsonField? = null + private var verificationMethod: JsonField? = null + private var accountToken: JsonField = JsonMissing.of() + private var companyId: JsonField = JsonMissing.of() + private var dob: JsonField = JsonMissing.of() + private var doingBusinessAs: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(plaidCreateBankAccountApiRequest: PlaidCreateBankAccountApiRequest) = @@ -836,17 +1125,33 @@ constructor( * Legal Name of the business or individual who owns the external account. This will * appear in statements */ - fun owner(owner: String) = apply { this.owner = owner } + fun owner(owner: String) = owner(JsonField.of(owner)) + + /** + * Legal Name of the business or individual who owns the external account. This will + * appear in statements + */ + fun owner(owner: JsonField) = apply { this.owner = owner } /** Owner Type */ - fun ownerType(ownerType: OwnerType) = apply { this.ownerType = ownerType } + fun ownerType(ownerType: OwnerType) = ownerType(JsonField.of(ownerType)) - fun processorToken(processorToken: String) = apply { + /** Owner Type */ + fun ownerType(ownerType: JsonField) = apply { this.ownerType = ownerType } + + fun processorToken(processorToken: String) = + processorToken(JsonField.of(processorToken)) + + fun processorToken(processorToken: JsonField) = apply { this.processorToken = processorToken } /** Verification Method */ - fun verificationMethod(verificationMethod: VerificationMethod) = apply { + fun verificationMethod(verificationMethod: VerificationMethod) = + verificationMethod(JsonField.of(verificationMethod)) + + /** Verification Method */ + fun verificationMethod(verificationMethod: JsonField) = apply { this.verificationMethod = verificationMethod } @@ -855,21 +1160,45 @@ constructor( * accounts that are associated with the program, account_token field returned will be * null */ - fun accountToken(accountToken: String?) = apply { this.accountToken = accountToken } + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Indicates which Lithic account the external account is associated with. For external + * accounts that are associated with the program, account_token field returned will be + * null + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } /** Optional field that helps identify bank accounts in receipts */ - fun companyId(companyId: String?) = apply { this.companyId = companyId } + fun companyId(companyId: String) = companyId(JsonField.of(companyId)) + + /** Optional field that helps identify bank accounts in receipts */ + fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** Date of Birth of the Individual that owns the external bank account */ - fun dob(dob: LocalDate?) = apply { this.dob = dob } + fun dob(dob: LocalDate) = dob(JsonField.of(dob)) + + /** Date of Birth of the Individual that owns the external bank account */ + fun dob(dob: JsonField) = apply { this.dob = dob } + + /** Doing Business As */ + fun doingBusinessAs(doingBusinessAs: String) = + doingBusinessAs(JsonField.of(doingBusinessAs)) /** Doing Business As */ - fun doingBusinessAs(doingBusinessAs: String?) = apply { + fun doingBusinessAs(doingBusinessAs: JsonField) = apply { this.doingBusinessAs = doingBusinessAs } /** User Defined ID */ - fun userDefinedId(userDefinedId: String?) = apply { this.userDefinedId = userDefinedId } + fun userDefinedId(userDefinedId: String) = userDefinedId(JsonField.of(userDefinedId)) + + /** User Defined ID */ + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -929,85 +1258,207 @@ constructor( class ExternallyVerifiedCreateBankAccountApiRequest @JsonCreator private constructor( - @JsonProperty("account_number") private val accountNumber: String, - @JsonProperty("country") private val country: String, - @JsonProperty("currency") private val currency: String, - @JsonProperty("owner") private val owner: String, - @JsonProperty("owner_type") private val ownerType: OwnerType, - @JsonProperty("routing_number") private val routingNumber: String, - @JsonProperty("type") private val type: Type, + @JsonProperty("account_number") + @ExcludeMissing + private val accountNumber: JsonField = JsonMissing.of(), + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("owner") + @ExcludeMissing + private val owner: JsonField = JsonMissing.of(), + @JsonProperty("owner_type") + @ExcludeMissing + private val ownerType: JsonField = JsonMissing.of(), + @JsonProperty("routing_number") + @ExcludeMissing + private val routingNumber: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonProperty("verification_method") - private val verificationMethod: ExternallyVerifiedVerificationMethod, - @JsonProperty("account_token") private val accountToken: String?, - @JsonProperty("address") private val address: ExternalBankAccountAddress?, - @JsonProperty("company_id") private val companyId: String?, - @JsonProperty("dob") private val dob: LocalDate?, - @JsonProperty("doing_business_as") private val doingBusinessAs: String?, - @JsonProperty("name") private val name: String?, - @JsonProperty("user_defined_id") private val userDefinedId: String?, + @ExcludeMissing + private val verificationMethod: JsonField = + JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + private val accountToken: JsonField = JsonMissing.of(), + @JsonProperty("address") + @ExcludeMissing + private val address: JsonField = JsonMissing.of(), + @JsonProperty("company_id") + @ExcludeMissing + private val companyId: JsonField = JsonMissing.of(), + @JsonProperty("dob") + @ExcludeMissing + private val dob: JsonField = JsonMissing.of(), + @JsonProperty("doing_business_as") + @ExcludeMissing + private val doingBusinessAs: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + private val userDefinedId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Account Number */ - @JsonProperty("account_number") fun accountNumber(): String = accountNumber + fun accountNumber(): String = accountNumber.getRequired("account_number") /** * The country that the bank account is located in using ISO 3166-1. We will only accept USA * bank accounts e.g., USA */ - @JsonProperty("country") fun country(): String = country + fun country(): String = country.getRequired("country") /** currency of the external account 3-digit alphabetic ISO 4217 code */ - @JsonProperty("currency") fun currency(): String = currency + fun currency(): String = currency.getRequired("currency") /** * Legal Name of the business or individual who owns the external account. This will appear * in statements */ - @JsonProperty("owner") fun owner(): String = owner + fun owner(): String = owner.getRequired("owner") /** Owner Type */ - @JsonProperty("owner_type") fun ownerType(): OwnerType = ownerType + fun ownerType(): OwnerType = ownerType.getRequired("owner_type") /** Routing Number */ - @JsonProperty("routing_number") fun routingNumber(): String = routingNumber + fun routingNumber(): String = routingNumber.getRequired("routing_number") /** Account Type */ - @JsonProperty("type") fun type(): Type = type + fun type(): Type = type.getRequired("type") + + /** Verification Method */ + fun verificationMethod(): ExternallyVerifiedVerificationMethod = + verificationMethod.getRequired("verification_method") + + /** + * Indicates which Lithic account the external account is associated with. For external + * accounts that are associated with the program, account_token field returned will be null + */ + fun accountToken(): String? = accountToken.getNullable("account_token") + + /** Address */ + fun address(): ExternalBankAccountAddress? = address.getNullable("address") + + /** Optional field that helps identify bank accounts in receipts */ + fun companyId(): String? = companyId.getNullable("company_id") + + /** Date of Birth of the Individual that owns the external bank account */ + fun dob(): LocalDate? = dob.getNullable("dob") + + /** Doing Business As */ + fun doingBusinessAs(): String? = doingBusinessAs.getNullable("doing_business_as") + + /** The nickname for this External Bank Account */ + fun name(): String? = name.getNullable("name") + + /** User Defined ID */ + fun userDefinedId(): String? = userDefinedId.getNullable("user_defined_id") + + /** Account Number */ + @JsonProperty("account_number") + @ExcludeMissing + fun _accountNumber(): JsonField = accountNumber + + /** + * The country that the bank account is located in using ISO 3166-1. We will only accept USA + * bank accounts e.g., USA + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + /** currency of the external account 3-digit alphabetic ISO 4217 code */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Legal Name of the business or individual who owns the external account. This will appear + * in statements + */ + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner + + /** Owner Type */ + @JsonProperty("owner_type") + @ExcludeMissing + fun _ownerType(): JsonField = ownerType + + /** Routing Number */ + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber + + /** Account Type */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** Verification Method */ @JsonProperty("verification_method") - fun verificationMethod(): ExternallyVerifiedVerificationMethod = verificationMethod + @ExcludeMissing + fun _verificationMethod(): JsonField = + verificationMethod /** * Indicates which Lithic account the external account is associated with. For external * accounts that are associated with the program, account_token field returned will be null */ - @JsonProperty("account_token") fun accountToken(): String? = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** Address */ - @JsonProperty("address") fun address(): ExternalBankAccountAddress? = address + @JsonProperty("address") + @ExcludeMissing + fun _address(): JsonField = address /** Optional field that helps identify bank accounts in receipts */ - @JsonProperty("company_id") fun companyId(): String? = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Date of Birth of the Individual that owns the external bank account */ - @JsonProperty("dob") fun dob(): LocalDate? = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** Doing Business As */ - @JsonProperty("doing_business_as") fun doingBusinessAs(): String? = doingBusinessAs + @JsonProperty("doing_business_as") + @ExcludeMissing + fun _doingBusinessAs(): JsonField = doingBusinessAs /** The nickname for this External Bank Account */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** User Defined ID */ - @JsonProperty("user_defined_id") fun userDefinedId(): String? = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExternallyVerifiedCreateBankAccountApiRequest = apply { + if (!validated) { + accountNumber() + country() + currency() + owner() + ownerType() + routingNumber() + type() + verificationMethod() + accountToken() + address()?.validate() + companyId() + dob() + doingBusinessAs() + name() + userDefinedId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1017,21 +1468,21 @@ constructor( class Builder { - private var accountNumber: String? = null - private var country: String? = null - private var currency: String? = null - private var owner: String? = null - private var ownerType: OwnerType? = null - private var routingNumber: String? = null - private var type: Type? = null - private var verificationMethod: ExternallyVerifiedVerificationMethod? = null - private var accountToken: String? = null - private var address: ExternalBankAccountAddress? = null - private var companyId: String? = null - private var dob: LocalDate? = null - private var doingBusinessAs: String? = null - private var name: String? = null - private var userDefinedId: String? = null + private var accountNumber: JsonField? = null + private var country: JsonField? = null + private var currency: JsonField? = null + private var owner: JsonField? = null + private var ownerType: JsonField? = null + private var routingNumber: JsonField? = null + private var type: JsonField? = null + private var verificationMethod: JsonField? = null + private var accountToken: JsonField = JsonMissing.of() + private var address: JsonField = JsonMissing.of() + private var companyId: JsonField = JsonMissing.of() + private var dob: JsonField = JsonMissing.of() + private var doingBusinessAs: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -1060,64 +1511,130 @@ constructor( } /** Account Number */ - fun accountNumber(accountNumber: String) = apply { this.accountNumber = accountNumber } + fun accountNumber(accountNumber: String) = accountNumber(JsonField.of(accountNumber)) + + /** Account Number */ + fun accountNumber(accountNumber: JsonField) = apply { + this.accountNumber = accountNumber + } /** * The country that the bank account is located in using ISO 3166-1. We will only accept * USA bank accounts e.g., USA */ - fun country(country: String) = apply { this.country = country } + fun country(country: String) = country(JsonField.of(country)) + + /** + * The country that the bank account is located in using ISO 3166-1. We will only accept + * USA bank accounts e.g., USA + */ + fun country(country: JsonField) = apply { this.country = country } + + /** currency of the external account 3-digit alphabetic ISO 4217 code */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** currency of the external account 3-digit alphabetic ISO 4217 code */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } /** * Legal Name of the business or individual who owns the external account. This will * appear in statements */ - fun owner(owner: String) = apply { this.owner = owner } + fun owner(owner: String) = owner(JsonField.of(owner)) + + /** + * Legal Name of the business or individual who owns the external account. This will + * appear in statements + */ + fun owner(owner: JsonField) = apply { this.owner = owner } /** Owner Type */ - fun ownerType(ownerType: OwnerType) = apply { this.ownerType = ownerType } + fun ownerType(ownerType: OwnerType) = ownerType(JsonField.of(ownerType)) + + /** Owner Type */ + fun ownerType(ownerType: JsonField) = apply { this.ownerType = ownerType } /** Routing Number */ - fun routingNumber(routingNumber: String) = apply { this.routingNumber = routingNumber } + fun routingNumber(routingNumber: String) = routingNumber(JsonField.of(routingNumber)) + + /** Routing Number */ + fun routingNumber(routingNumber: JsonField) = apply { + this.routingNumber = routingNumber + } /** Account Type */ - fun type(type: Type) = apply { this.type = type } + fun type(type: Type) = type(JsonField.of(type)) + + /** Account Type */ + fun type(type: JsonField) = apply { this.type = type } /** Verification Method */ fun verificationMethod(verificationMethod: ExternallyVerifiedVerificationMethod) = - apply { - this.verificationMethod = verificationMethod - } + verificationMethod(JsonField.of(verificationMethod)) + + /** Verification Method */ + fun verificationMethod( + verificationMethod: JsonField + ) = apply { this.verificationMethod = verificationMethod } /** * Indicates which Lithic account the external account is associated with. For external * accounts that are associated with the program, account_token field returned will be * null */ - fun accountToken(accountToken: String?) = apply { this.accountToken = accountToken } + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Indicates which Lithic account the external account is associated with. For external + * accounts that are associated with the program, account_token field returned will be + * null + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } /** Address */ - fun address(address: ExternalBankAccountAddress?) = apply { this.address = address } + fun address(address: ExternalBankAccountAddress) = address(JsonField.of(address)) + + /** Address */ + fun address(address: JsonField) = apply { + this.address = address + } + + /** Optional field that helps identify bank accounts in receipts */ + fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** Optional field that helps identify bank accounts in receipts */ - fun companyId(companyId: String?) = apply { this.companyId = companyId } + fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** Date of Birth of the Individual that owns the external bank account */ - fun dob(dob: LocalDate?) = apply { this.dob = dob } + fun dob(dob: LocalDate) = dob(JsonField.of(dob)) + + /** Date of Birth of the Individual that owns the external bank account */ + fun dob(dob: JsonField) = apply { this.dob = dob } /** Doing Business As */ - fun doingBusinessAs(doingBusinessAs: String?) = apply { + fun doingBusinessAs(doingBusinessAs: String) = + doingBusinessAs(JsonField.of(doingBusinessAs)) + + /** Doing Business As */ + fun doingBusinessAs(doingBusinessAs: JsonField) = apply { this.doingBusinessAs = doingBusinessAs } /** The nickname for this External Bank Account */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The nickname for this External Bank Account */ + fun name(name: JsonField) = apply { this.name = name } + + /** User Defined ID */ + fun userDefinedId(userDefinedId: String) = userDefinedId(JsonField.of(userDefinedId)) /** User Defined ID */ - fun userDefinedId(userDefinedId: String?) = apply { this.userDefinedId = userDefinedId } + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountCreateResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountCreateResponse.kt index 90fe3f11..9b0f4166 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountCreateResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountCreateResponse.kt @@ -171,82 +171,94 @@ private constructor( * program links an external bank account to more than one end-user or to both the program and * the end-user, then Lithic will return each record of the association */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * The country that the bank account is located in using ISO 3166-1. We will only accept USA * bank accounts e.g., USA */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** An ISO 8601 string representing when this funding source was added to the Lithic account. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** currency of the external account 3-digit alphabetic ISO 4217 code */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The last 4 digits of the bank account. Derived by Lithic from the account number passed */ - @JsonProperty("last_four") @ExcludeMissing fun _lastFour() = lastFour + @JsonProperty("last_four") @ExcludeMissing fun _lastFour(): JsonField = lastFour /** * Legal Name of the business or individual who owns the external account. This will appear in * statements */ - @JsonProperty("owner") @ExcludeMissing fun _owner() = owner + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner /** Owner Type */ - @JsonProperty("owner_type") @ExcludeMissing fun _ownerType() = ownerType + @JsonProperty("owner_type") @ExcludeMissing fun _ownerType(): JsonField = ownerType /** Routing Number */ - @JsonProperty("routing_number") @ExcludeMissing fun _routingNumber() = routingNumber + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber /** Account State */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** Account Type */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** The number of attempts at verification */ @JsonProperty("verification_attempts") @ExcludeMissing - fun _verificationAttempts() = verificationAttempts + fun _verificationAttempts(): JsonField = verificationAttempts /** Verification Method */ @JsonProperty("verification_method") @ExcludeMissing - fun _verificationMethod() = verificationMethod + fun _verificationMethod(): JsonField = verificationMethod /** Verification State */ - @JsonProperty("verification_state") @ExcludeMissing fun _verificationState() = verificationState + @JsonProperty("verification_state") + @ExcludeMissing + fun _verificationState(): JsonField = verificationState /** * Indicates which Lithic account the external account is associated with. For external accounts * that are associated with the program, account_token field returned will be null */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** Address */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") + @ExcludeMissing + fun _address(): JsonField = address /** Optional field that helps identify bank accounts in receipts */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Date of Birth of the Individual that owns the external bank account */ - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** Doing Business As */ - @JsonProperty("doing_business_as") @ExcludeMissing fun _doingBusinessAs() = doingBusinessAs + @JsonProperty("doing_business_as") + @ExcludeMissing + fun _doingBusinessAs(): JsonField = doingBusinessAs /** The financial account token of the operating account to fund the micro deposits */ @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken /** The nickname for this External Bank Account */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** User Defined ID */ - @JsonProperty("user_defined_id") @ExcludeMissing fun _userDefinedId() = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId /** * Optional free text description of the reason for the failed verification. For ACH @@ -255,7 +267,7 @@ private constructor( */ @JsonProperty("verification_failed_reason") @ExcludeMissing - fun _verificationFailedReason() = verificationFailedReason + fun _verificationFailedReason(): JsonField = verificationFailedReason @JsonAnyGetter @ExcludeMissing @@ -300,19 +312,19 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var lastFour: JsonField = JsonMissing.of() - private var owner: JsonField = JsonMissing.of() - private var ownerType: JsonField = JsonMissing.of() - private var routingNumber: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var verificationAttempts: JsonField = JsonMissing.of() - private var verificationMethod: JsonField = JsonMissing.of() - private var verificationState: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var country: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var lastFour: JsonField? = null + private var owner: JsonField? = null + private var ownerType: JsonField? = null + private var routingNumber: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var verificationAttempts: JsonField? = null + private var verificationMethod: JsonField? = null + private var verificationState: JsonField? = null private var accountToken: JsonField = JsonMissing.of() private var address: JsonField = JsonMissing.of() private var companyId: JsonField = JsonMissing.of() @@ -574,19 +586,25 @@ private constructor( fun build(): ExternalBankAccountCreateResponse = ExternalBankAccountCreateResponse( - token, - country, - created, - currency, - lastFour, - owner, - ownerType, - routingNumber, - state, - type, - verificationAttempts, - verificationMethod, - verificationState, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(lastFour) { "`lastFour` is required but was not set" }, + checkNotNull(owner) { "`owner` is required but was not set" }, + checkNotNull(ownerType) { "`ownerType` is required but was not set" }, + checkNotNull(routingNumber) { "`routingNumber` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(verificationAttempts) { + "`verificationAttempts` is required but was not set" + }, + checkNotNull(verificationMethod) { + "`verificationMethod` is required but was not set" + }, + checkNotNull(verificationState) { + "`verificationState` is required but was not set" + }, accountToken, address, companyId, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountListResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountListResponse.kt index 9b292c0b..6ba54fd5 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountListResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountListResponse.kt @@ -171,82 +171,94 @@ private constructor( * program links an external bank account to more than one end-user or to both the program and * the end-user, then Lithic will return each record of the association */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * The country that the bank account is located in using ISO 3166-1. We will only accept USA * bank accounts e.g., USA */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** An ISO 8601 string representing when this funding source was added to the Lithic account. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** currency of the external account 3-digit alphabetic ISO 4217 code */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The last 4 digits of the bank account. Derived by Lithic from the account number passed */ - @JsonProperty("last_four") @ExcludeMissing fun _lastFour() = lastFour + @JsonProperty("last_four") @ExcludeMissing fun _lastFour(): JsonField = lastFour /** * Legal Name of the business or individual who owns the external account. This will appear in * statements */ - @JsonProperty("owner") @ExcludeMissing fun _owner() = owner + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner /** Owner Type */ - @JsonProperty("owner_type") @ExcludeMissing fun _ownerType() = ownerType + @JsonProperty("owner_type") @ExcludeMissing fun _ownerType(): JsonField = ownerType /** Routing Number */ - @JsonProperty("routing_number") @ExcludeMissing fun _routingNumber() = routingNumber + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber /** Account State */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** Account Type */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** The number of attempts at verification */ @JsonProperty("verification_attempts") @ExcludeMissing - fun _verificationAttempts() = verificationAttempts + fun _verificationAttempts(): JsonField = verificationAttempts /** Verification Method */ @JsonProperty("verification_method") @ExcludeMissing - fun _verificationMethod() = verificationMethod + fun _verificationMethod(): JsonField = verificationMethod /** Verification State */ - @JsonProperty("verification_state") @ExcludeMissing fun _verificationState() = verificationState + @JsonProperty("verification_state") + @ExcludeMissing + fun _verificationState(): JsonField = verificationState /** * Indicates which Lithic account the external account is associated with. For external accounts * that are associated with the program, account_token field returned will be null */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** Address */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") + @ExcludeMissing + fun _address(): JsonField = address /** Optional field that helps identify bank accounts in receipts */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Date of Birth of the Individual that owns the external bank account */ - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** Doing Business As */ - @JsonProperty("doing_business_as") @ExcludeMissing fun _doingBusinessAs() = doingBusinessAs + @JsonProperty("doing_business_as") + @ExcludeMissing + fun _doingBusinessAs(): JsonField = doingBusinessAs /** The financial account token of the operating account to fund the micro deposits */ @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken /** The nickname for this External Bank Account */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** User Defined ID */ - @JsonProperty("user_defined_id") @ExcludeMissing fun _userDefinedId() = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId /** * Optional free text description of the reason for the failed verification. For ACH @@ -255,7 +267,7 @@ private constructor( */ @JsonProperty("verification_failed_reason") @ExcludeMissing - fun _verificationFailedReason() = verificationFailedReason + fun _verificationFailedReason(): JsonField = verificationFailedReason @JsonAnyGetter @ExcludeMissing @@ -300,19 +312,19 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var lastFour: JsonField = JsonMissing.of() - private var owner: JsonField = JsonMissing.of() - private var ownerType: JsonField = JsonMissing.of() - private var routingNumber: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var verificationAttempts: JsonField = JsonMissing.of() - private var verificationMethod: JsonField = JsonMissing.of() - private var verificationState: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var country: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var lastFour: JsonField? = null + private var owner: JsonField? = null + private var ownerType: JsonField? = null + private var routingNumber: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var verificationAttempts: JsonField? = null + private var verificationMethod: JsonField? = null + private var verificationState: JsonField? = null private var accountToken: JsonField = JsonMissing.of() private var address: JsonField = JsonMissing.of() private var companyId: JsonField = JsonMissing.of() @@ -573,19 +585,25 @@ private constructor( fun build(): ExternalBankAccountListResponse = ExternalBankAccountListResponse( - token, - country, - created, - currency, - lastFour, - owner, - ownerType, - routingNumber, - state, - type, - verificationAttempts, - verificationMethod, - verificationState, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(lastFour) { "`lastFour` is required but was not set" }, + checkNotNull(owner) { "`owner` is required but was not set" }, + checkNotNull(ownerType) { "`ownerType` is required but was not set" }, + checkNotNull(routingNumber) { "`routingNumber` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(verificationAttempts) { + "`verificationAttempts` is required but was not set" + }, + checkNotNull(verificationMethod) { + "`verificationMethod` is required but was not set" + }, + checkNotNull(verificationState) { + "`verificationState` is required but was not set" + }, accountToken, address, companyId, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountMicroDepositCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountMicroDepositCreateParams.kt index e533db48..f135afd7 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountMicroDepositCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountMicroDepositCreateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -28,12 +30,14 @@ constructor( fun microDeposits(): List = body.microDeposits() + fun _microDeposits(): JsonField> = body._microDeposits() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): ExternalBankAccountMicroDepositCreateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -51,17 +55,32 @@ constructor( class ExternalBankAccountMicroDepositCreateBody @JsonCreator internal constructor( - @JsonProperty("micro_deposits") private val microDeposits: List, + @JsonProperty("micro_deposits") + @ExcludeMissing + private val microDeposits: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("micro_deposits") fun microDeposits(): List = microDeposits + fun microDeposits(): List = microDeposits.getRequired("micro_deposits") + + @JsonProperty("micro_deposits") + @ExcludeMissing + fun _microDeposits(): JsonField> = microDeposits @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExternalBankAccountMicroDepositCreateBody = apply { + if (!validated) { + microDeposits() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -71,24 +90,36 @@ constructor( class Builder { - private var microDeposits: MutableList? = null + private var microDeposits: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( externalBankAccountMicroDepositCreateBody: ExternalBankAccountMicroDepositCreateBody ) = apply { microDeposits = - externalBankAccountMicroDepositCreateBody.microDeposits.toMutableList() + externalBankAccountMicroDepositCreateBody.microDeposits.map { + it.toMutableList() + } additionalProperties = externalBankAccountMicroDepositCreateBody.additionalProperties.toMutableMap() } - fun microDeposits(microDeposits: List) = apply { - this.microDeposits = microDeposits.toMutableList() + fun microDeposits(microDeposits: List) = + microDeposits(JsonField.of(microDeposits)) + + fun microDeposits(microDeposits: JsonField>) = apply { + this.microDeposits = microDeposits.map { it.toMutableList() } } fun addMicroDeposit(microDeposit: Long) = apply { - microDeposits = (microDeposits ?: mutableListOf()).apply { add(microDeposit) } + microDeposits = + (microDeposits ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(microDeposit) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -113,7 +144,7 @@ constructor( fun build(): ExternalBankAccountMicroDepositCreateBody = ExternalBankAccountMicroDepositCreateBody( checkNotNull(microDeposits) { "`microDeposits` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -170,8 +201,31 @@ constructor( fun microDeposits(microDeposits: List) = apply { body.microDeposits(microDeposits) } + fun microDeposits(microDeposits: JsonField>) = apply { + body.microDeposits(microDeposits) + } + fun addMicroDeposit(microDeposit: Long) = apply { body.addMicroDeposit(microDeposit) } + 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) @@ -270,25 +324,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ExternalBankAccountMicroDepositCreateParams = ExternalBankAccountMicroDepositCreateParams( checkNotNull(externalBankAccountToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetrieveResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetrieveResponse.kt index 1397d471..0e28ae1f 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetrieveResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetrieveResponse.kt @@ -171,82 +171,94 @@ private constructor( * program links an external bank account to more than one end-user or to both the program and * the end-user, then Lithic will return each record of the association */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * The country that the bank account is located in using ISO 3166-1. We will only accept USA * bank accounts e.g., USA */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** An ISO 8601 string representing when this funding source was added to the Lithic account. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** currency of the external account 3-digit alphabetic ISO 4217 code */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The last 4 digits of the bank account. Derived by Lithic from the account number passed */ - @JsonProperty("last_four") @ExcludeMissing fun _lastFour() = lastFour + @JsonProperty("last_four") @ExcludeMissing fun _lastFour(): JsonField = lastFour /** * Legal Name of the business or individual who owns the external account. This will appear in * statements */ - @JsonProperty("owner") @ExcludeMissing fun _owner() = owner + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner /** Owner Type */ - @JsonProperty("owner_type") @ExcludeMissing fun _ownerType() = ownerType + @JsonProperty("owner_type") @ExcludeMissing fun _ownerType(): JsonField = ownerType /** Routing Number */ - @JsonProperty("routing_number") @ExcludeMissing fun _routingNumber() = routingNumber + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber /** Account State */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** Account Type */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** The number of attempts at verification */ @JsonProperty("verification_attempts") @ExcludeMissing - fun _verificationAttempts() = verificationAttempts + fun _verificationAttempts(): JsonField = verificationAttempts /** Verification Method */ @JsonProperty("verification_method") @ExcludeMissing - fun _verificationMethod() = verificationMethod + fun _verificationMethod(): JsonField = verificationMethod /** Verification State */ - @JsonProperty("verification_state") @ExcludeMissing fun _verificationState() = verificationState + @JsonProperty("verification_state") + @ExcludeMissing + fun _verificationState(): JsonField = verificationState /** * Indicates which Lithic account the external account is associated with. For external accounts * that are associated with the program, account_token field returned will be null */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** Address */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") + @ExcludeMissing + fun _address(): JsonField = address /** Optional field that helps identify bank accounts in receipts */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Date of Birth of the Individual that owns the external bank account */ - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** Doing Business As */ - @JsonProperty("doing_business_as") @ExcludeMissing fun _doingBusinessAs() = doingBusinessAs + @JsonProperty("doing_business_as") + @ExcludeMissing + fun _doingBusinessAs(): JsonField = doingBusinessAs /** The financial account token of the operating account to fund the micro deposits */ @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken /** The nickname for this External Bank Account */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** User Defined ID */ - @JsonProperty("user_defined_id") @ExcludeMissing fun _userDefinedId() = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId /** * Optional free text description of the reason for the failed verification. For ACH @@ -255,7 +267,7 @@ private constructor( */ @JsonProperty("verification_failed_reason") @ExcludeMissing - fun _verificationFailedReason() = verificationFailedReason + fun _verificationFailedReason(): JsonField = verificationFailedReason @JsonAnyGetter @ExcludeMissing @@ -300,19 +312,19 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var lastFour: JsonField = JsonMissing.of() - private var owner: JsonField = JsonMissing.of() - private var ownerType: JsonField = JsonMissing.of() - private var routingNumber: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var verificationAttempts: JsonField = JsonMissing.of() - private var verificationMethod: JsonField = JsonMissing.of() - private var verificationState: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var country: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var lastFour: JsonField? = null + private var owner: JsonField? = null + private var ownerType: JsonField? = null + private var routingNumber: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var verificationAttempts: JsonField? = null + private var verificationMethod: JsonField? = null + private var verificationState: JsonField? = null private var accountToken: JsonField = JsonMissing.of() private var address: JsonField = JsonMissing.of() private var companyId: JsonField = JsonMissing.of() @@ -574,19 +586,25 @@ private constructor( fun build(): ExternalBankAccountRetrieveResponse = ExternalBankAccountRetrieveResponse( - token, - country, - created, - currency, - lastFour, - owner, - ownerType, - routingNumber, - state, - type, - verificationAttempts, - verificationMethod, - verificationState, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(lastFour) { "`lastFour` is required but was not set" }, + checkNotNull(owner) { "`owner` is required but was not set" }, + checkNotNull(ownerType) { "`ownerType` is required but was not set" }, + checkNotNull(routingNumber) { "`routingNumber` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(verificationAttempts) { + "`verificationAttempts` is required but was not set" + }, + checkNotNull(verificationMethod) { + "`verificationMethod` is required but was not set" + }, + checkNotNull(verificationState) { + "`verificationState` is required but was not set" + }, accountToken, address, companyId, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryMicroDepositsParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryMicroDepositsParams.kt index 15cea9eb..262c5411 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryMicroDepositsParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryMicroDepositsParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -28,12 +30,14 @@ constructor( fun financialAccountToken(): String? = body.financialAccountToken() + fun _financialAccountToken(): JsonField = body._financialAccountToken() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): ExternalBankAccountRetryMicroDepositsBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -51,18 +55,33 @@ constructor( class ExternalBankAccountRetryMicroDepositsBody @JsonCreator internal constructor( - @JsonProperty("financial_account_token") private val financialAccountToken: String?, + @JsonProperty("financial_account_token") + @ExcludeMissing + private val financialAccountToken: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun financialAccountToken(): String? = + financialAccountToken.getNullable("financial_account_token") + @JsonProperty("financial_account_token") - fun financialAccountToken(): String? = financialAccountToken + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExternalBankAccountRetryMicroDepositsBody = apply { + if (!validated) { + financialAccountToken() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -72,7 +91,7 @@ constructor( class Builder { - private var financialAccountToken: String? = null + private var financialAccountToken: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -84,7 +103,10 @@ constructor( externalBankAccountRetryMicroDepositsBody.additionalProperties.toMutableMap() } - fun financialAccountToken(financialAccountToken: String?) = apply { + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + fun financialAccountToken(financialAccountToken: JsonField) = apply { this.financialAccountToken = financialAccountToken } @@ -164,10 +186,33 @@ constructor( this.externalBankAccountToken = externalBankAccountToken } - fun financialAccountToken(financialAccountToken: String?) = apply { + fun financialAccountToken(financialAccountToken: String) = apply { body.financialAccountToken(financialAccountToken) } + fun financialAccountToken(financialAccountToken: JsonField) = apply { + body.financialAccountToken(financialAccountToken) + } + + 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) @@ -266,25 +311,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ExternalBankAccountRetryMicroDepositsParams = ExternalBankAccountRetryMicroDepositsParams( checkNotNull(externalBankAccountToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryMicroDepositsResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryMicroDepositsResponse.kt index d943bb23..76959955 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryMicroDepositsResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryMicroDepositsResponse.kt @@ -171,82 +171,94 @@ private constructor( * program links an external bank account to more than one end-user or to both the program and * the end-user, then Lithic will return each record of the association */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * The country that the bank account is located in using ISO 3166-1. We will only accept USA * bank accounts e.g., USA */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** An ISO 8601 string representing when this funding source was added to the Lithic account. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** currency of the external account 3-digit alphabetic ISO 4217 code */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The last 4 digits of the bank account. Derived by Lithic from the account number passed */ - @JsonProperty("last_four") @ExcludeMissing fun _lastFour() = lastFour + @JsonProperty("last_four") @ExcludeMissing fun _lastFour(): JsonField = lastFour /** * Legal Name of the business or individual who owns the external account. This will appear in * statements */ - @JsonProperty("owner") @ExcludeMissing fun _owner() = owner + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner /** Owner Type */ - @JsonProperty("owner_type") @ExcludeMissing fun _ownerType() = ownerType + @JsonProperty("owner_type") @ExcludeMissing fun _ownerType(): JsonField = ownerType /** Routing Number */ - @JsonProperty("routing_number") @ExcludeMissing fun _routingNumber() = routingNumber + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber /** Account State */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** Account Type */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** The number of attempts at verification */ @JsonProperty("verification_attempts") @ExcludeMissing - fun _verificationAttempts() = verificationAttempts + fun _verificationAttempts(): JsonField = verificationAttempts /** Verification Method */ @JsonProperty("verification_method") @ExcludeMissing - fun _verificationMethod() = verificationMethod + fun _verificationMethod(): JsonField = verificationMethod /** Verification State */ - @JsonProperty("verification_state") @ExcludeMissing fun _verificationState() = verificationState + @JsonProperty("verification_state") + @ExcludeMissing + fun _verificationState(): JsonField = verificationState /** * Indicates which Lithic account the external account is associated with. For external accounts * that are associated with the program, account_token field returned will be null */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** Address */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") + @ExcludeMissing + fun _address(): JsonField = address /** Optional field that helps identify bank accounts in receipts */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Date of Birth of the Individual that owns the external bank account */ - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** Doing Business As */ - @JsonProperty("doing_business_as") @ExcludeMissing fun _doingBusinessAs() = doingBusinessAs + @JsonProperty("doing_business_as") + @ExcludeMissing + fun _doingBusinessAs(): JsonField = doingBusinessAs /** The financial account token of the operating account to fund the micro deposits */ @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken /** The nickname for this External Bank Account */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** User Defined ID */ - @JsonProperty("user_defined_id") @ExcludeMissing fun _userDefinedId() = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId /** * Optional free text description of the reason for the failed verification. For ACH @@ -255,7 +267,7 @@ private constructor( */ @JsonProperty("verification_failed_reason") @ExcludeMissing - fun _verificationFailedReason() = verificationFailedReason + fun _verificationFailedReason(): JsonField = verificationFailedReason @JsonAnyGetter @ExcludeMissing @@ -300,19 +312,19 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var lastFour: JsonField = JsonMissing.of() - private var owner: JsonField = JsonMissing.of() - private var ownerType: JsonField = JsonMissing.of() - private var routingNumber: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var verificationAttempts: JsonField = JsonMissing.of() - private var verificationMethod: JsonField = JsonMissing.of() - private var verificationState: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var country: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var lastFour: JsonField? = null + private var owner: JsonField? = null + private var ownerType: JsonField? = null + private var routingNumber: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var verificationAttempts: JsonField? = null + private var verificationMethod: JsonField? = null + private var verificationState: JsonField? = null private var accountToken: JsonField = JsonMissing.of() private var address: JsonField = JsonMissing.of() private var companyId: JsonField = JsonMissing.of() @@ -578,19 +590,25 @@ private constructor( fun build(): ExternalBankAccountRetryMicroDepositsResponse = ExternalBankAccountRetryMicroDepositsResponse( - token, - country, - created, - currency, - lastFour, - owner, - ownerType, - routingNumber, - state, - type, - verificationAttempts, - verificationMethod, - verificationState, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(lastFour) { "`lastFour` is required but was not set" }, + checkNotNull(owner) { "`owner` is required but was not set" }, + checkNotNull(ownerType) { "`ownerType` is required but was not set" }, + checkNotNull(routingNumber) { "`routingNumber` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(verificationAttempts) { + "`verificationAttempts` is required but was not set" + }, + checkNotNull(verificationMethod) { + "`verificationMethod` is required but was not set" + }, + checkNotNull(verificationState) { + "`verificationState` is required but was not set" + }, accountToken, address, companyId, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteParams.kt index 4157cd61..25d45a95 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -28,12 +30,14 @@ constructor( fun financialAccountToken(): String? = body.financialAccountToken() + fun _financialAccountToken(): JsonField = body._financialAccountToken() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): ExternalBankAccountRetryPrenoteBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -51,18 +55,33 @@ constructor( class ExternalBankAccountRetryPrenoteBody @JsonCreator internal constructor( - @JsonProperty("financial_account_token") private val financialAccountToken: String?, + @JsonProperty("financial_account_token") + @ExcludeMissing + private val financialAccountToken: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun financialAccountToken(): String? = + financialAccountToken.getNullable("financial_account_token") + @JsonProperty("financial_account_token") - fun financialAccountToken(): String? = financialAccountToken + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExternalBankAccountRetryPrenoteBody = apply { + if (!validated) { + financialAccountToken() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -72,7 +91,7 @@ constructor( class Builder { - private var financialAccountToken: String? = null + private var financialAccountToken: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -83,7 +102,10 @@ constructor( externalBankAccountRetryPrenoteBody.additionalProperties.toMutableMap() } - fun financialAccountToken(financialAccountToken: String?) = apply { + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + fun financialAccountToken(financialAccountToken: JsonField) = apply { this.financialAccountToken = financialAccountToken } @@ -162,10 +184,33 @@ constructor( this.externalBankAccountToken = externalBankAccountToken } - fun financialAccountToken(financialAccountToken: String?) = apply { + fun financialAccountToken(financialAccountToken: String) = apply { body.financialAccountToken(financialAccountToken) } + fun financialAccountToken(financialAccountToken: JsonField) = apply { + body.financialAccountToken(financialAccountToken) + } + + 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) @@ -264,25 +309,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ExternalBankAccountRetryPrenoteParams = ExternalBankAccountRetryPrenoteParams( checkNotNull(externalBankAccountToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteResponse.kt index d566aeb8..dbffaf20 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteResponse.kt @@ -171,82 +171,94 @@ private constructor( * program links an external bank account to more than one end-user or to both the program and * the end-user, then Lithic will return each record of the association */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * The country that the bank account is located in using ISO 3166-1. We will only accept USA * bank accounts e.g., USA */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** An ISO 8601 string representing when this funding source was added to the Lithic account. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** currency of the external account 3-digit alphabetic ISO 4217 code */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The last 4 digits of the bank account. Derived by Lithic from the account number passed */ - @JsonProperty("last_four") @ExcludeMissing fun _lastFour() = lastFour + @JsonProperty("last_four") @ExcludeMissing fun _lastFour(): JsonField = lastFour /** * Legal Name of the business or individual who owns the external account. This will appear in * statements */ - @JsonProperty("owner") @ExcludeMissing fun _owner() = owner + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner /** Owner Type */ - @JsonProperty("owner_type") @ExcludeMissing fun _ownerType() = ownerType + @JsonProperty("owner_type") @ExcludeMissing fun _ownerType(): JsonField = ownerType /** Routing Number */ - @JsonProperty("routing_number") @ExcludeMissing fun _routingNumber() = routingNumber + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber /** Account State */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** Account Type */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** The number of attempts at verification */ @JsonProperty("verification_attempts") @ExcludeMissing - fun _verificationAttempts() = verificationAttempts + fun _verificationAttempts(): JsonField = verificationAttempts /** Verification Method */ @JsonProperty("verification_method") @ExcludeMissing - fun _verificationMethod() = verificationMethod + fun _verificationMethod(): JsonField = verificationMethod /** Verification State */ - @JsonProperty("verification_state") @ExcludeMissing fun _verificationState() = verificationState + @JsonProperty("verification_state") + @ExcludeMissing + fun _verificationState(): JsonField = verificationState /** * Indicates which Lithic account the external account is associated with. For external accounts * that are associated with the program, account_token field returned will be null */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** Address */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") + @ExcludeMissing + fun _address(): JsonField = address /** Optional field that helps identify bank accounts in receipts */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Date of Birth of the Individual that owns the external bank account */ - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** Doing Business As */ - @JsonProperty("doing_business_as") @ExcludeMissing fun _doingBusinessAs() = doingBusinessAs + @JsonProperty("doing_business_as") + @ExcludeMissing + fun _doingBusinessAs(): JsonField = doingBusinessAs /** The financial account token of the operating account to fund the micro deposits */ @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken /** The nickname for this External Bank Account */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** User Defined ID */ - @JsonProperty("user_defined_id") @ExcludeMissing fun _userDefinedId() = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId /** * Optional free text description of the reason for the failed verification. For ACH @@ -255,7 +267,7 @@ private constructor( */ @JsonProperty("verification_failed_reason") @ExcludeMissing - fun _verificationFailedReason() = verificationFailedReason + fun _verificationFailedReason(): JsonField = verificationFailedReason @JsonAnyGetter @ExcludeMissing @@ -300,19 +312,19 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var lastFour: JsonField = JsonMissing.of() - private var owner: JsonField = JsonMissing.of() - private var ownerType: JsonField = JsonMissing.of() - private var routingNumber: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var verificationAttempts: JsonField = JsonMissing.of() - private var verificationMethod: JsonField = JsonMissing.of() - private var verificationState: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var country: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var lastFour: JsonField? = null + private var owner: JsonField? = null + private var ownerType: JsonField? = null + private var routingNumber: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var verificationAttempts: JsonField? = null + private var verificationMethod: JsonField? = null + private var verificationState: JsonField? = null private var accountToken: JsonField = JsonMissing.of() private var address: JsonField = JsonMissing.of() private var companyId: JsonField = JsonMissing.of() @@ -575,19 +587,25 @@ private constructor( fun build(): ExternalBankAccountRetryPrenoteResponse = ExternalBankAccountRetryPrenoteResponse( - token, - country, - created, - currency, - lastFour, - owner, - ownerType, - routingNumber, - state, - type, - verificationAttempts, - verificationMethod, - verificationState, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(lastFour) { "`lastFour` is required but was not set" }, + checkNotNull(owner) { "`owner` is required but was not set" }, + checkNotNull(ownerType) { "`ownerType` is required but was not set" }, + checkNotNull(routingNumber) { "`routingNumber` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(verificationAttempts) { + "`verificationAttempts` is required but was not set" + }, + checkNotNull(verificationMethod) { + "`verificationMethod` is required but was not set" + }, + checkNotNull(verificationState) { + "`verificationState` is required but was not set" + }, accountToken, address, companyId, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUpdateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUpdateParams.kt index 79d07ba9..789b032b 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUpdateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -54,12 +56,39 @@ constructor( /** User Defined ID */ fun userDefinedId(): String? = body.userDefinedId() - fun _additionalHeaders(): Headers = additionalHeaders + /** Address */ + fun _address(): JsonField = body._address() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Optional field that helps identify bank accounts in receipts */ + fun _companyId(): JsonField = body._companyId() + + /** Date of Birth of the Individual that owns the external bank account */ + fun _dob(): JsonField = body._dob() + + /** Doing Business As */ + fun _doingBusinessAs(): JsonField = body._doingBusinessAs() + + /** The nickname for this External Bank Account */ + fun _name(): JsonField = body._name() + + /** + * Legal Name of the business or individual who owns the external account. This will appear in + * statements + */ + fun _owner(): JsonField = body._owner() + + /** Owner Type */ + fun _ownerType(): JsonField = body._ownerType() + + /** User Defined ID */ + fun _userDefinedId(): JsonField = body._userDefinedId() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): ExternalBankAccountUpdateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -77,49 +106,116 @@ constructor( class ExternalBankAccountUpdateBody @JsonCreator internal constructor( - @JsonProperty("address") private val address: ExternalBankAccountAddress?, - @JsonProperty("company_id") private val companyId: String?, - @JsonProperty("dob") private val dob: LocalDate?, - @JsonProperty("doing_business_as") private val doingBusinessAs: String?, - @JsonProperty("name") private val name: String?, - @JsonProperty("owner") private val owner: String?, - @JsonProperty("owner_type") private val ownerType: OwnerType?, - @JsonProperty("user_defined_id") private val userDefinedId: String?, + @JsonProperty("address") + @ExcludeMissing + private val address: JsonField = JsonMissing.of(), + @JsonProperty("company_id") + @ExcludeMissing + private val companyId: JsonField = JsonMissing.of(), + @JsonProperty("dob") + @ExcludeMissing + private val dob: JsonField = JsonMissing.of(), + @JsonProperty("doing_business_as") + @ExcludeMissing + private val doingBusinessAs: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("owner") + @ExcludeMissing + private val owner: JsonField = JsonMissing.of(), + @JsonProperty("owner_type") + @ExcludeMissing + private val ownerType: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + private val userDefinedId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Address */ - @JsonProperty("address") fun address(): ExternalBankAccountAddress? = address + fun address(): ExternalBankAccountAddress? = address.getNullable("address") + + /** Optional field that helps identify bank accounts in receipts */ + fun companyId(): String? = companyId.getNullable("company_id") + + /** Date of Birth of the Individual that owns the external bank account */ + fun dob(): LocalDate? = dob.getNullable("dob") + + /** Doing Business As */ + fun doingBusinessAs(): String? = doingBusinessAs.getNullable("doing_business_as") + + /** The nickname for this External Bank Account */ + fun name(): String? = name.getNullable("name") + + /** + * Legal Name of the business or individual who owns the external account. This will appear + * in statements + */ + fun owner(): String? = owner.getNullable("owner") + + /** Owner Type */ + fun ownerType(): OwnerType? = ownerType.getNullable("owner_type") + + /** User Defined ID */ + fun userDefinedId(): String? = userDefinedId.getNullable("user_defined_id") + + /** Address */ + @JsonProperty("address") + @ExcludeMissing + fun _address(): JsonField = address /** Optional field that helps identify bank accounts in receipts */ - @JsonProperty("company_id") fun companyId(): String? = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Date of Birth of the Individual that owns the external bank account */ - @JsonProperty("dob") fun dob(): LocalDate? = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** Doing Business As */ - @JsonProperty("doing_business_as") fun doingBusinessAs(): String? = doingBusinessAs + @JsonProperty("doing_business_as") + @ExcludeMissing + fun _doingBusinessAs(): JsonField = doingBusinessAs /** The nickname for this External Bank Account */ - @JsonProperty("name") fun name(): String? = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Legal Name of the business or individual who owns the external account. This will appear * in statements */ - @JsonProperty("owner") fun owner(): String? = owner + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner /** Owner Type */ - @JsonProperty("owner_type") fun ownerType(): OwnerType? = ownerType + @JsonProperty("owner_type") + @ExcludeMissing + fun _ownerType(): JsonField = ownerType /** User Defined ID */ - @JsonProperty("user_defined_id") fun userDefinedId(): String? = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExternalBankAccountUpdateBody = apply { + if (!validated) { + address()?.validate() + companyId() + dob() + doingBusinessAs() + name() + owner() + ownerType() + userDefinedId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -129,14 +225,14 @@ constructor( class Builder { - private var address: ExternalBankAccountAddress? = null - private var companyId: String? = null - private var dob: LocalDate? = null - private var doingBusinessAs: String? = null - private var name: String? = null - private var owner: String? = null - private var ownerType: OwnerType? = null - private var userDefinedId: String? = null + private var address: JsonField = JsonMissing.of() + private var companyId: JsonField = JsonMissing.of() + private var dob: JsonField = JsonMissing.of() + private var doingBusinessAs: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var owner: JsonField = JsonMissing.of() + private var ownerType: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(externalBankAccountUpdateBody: ExternalBankAccountUpdateBody) = @@ -154,33 +250,65 @@ constructor( } /** Address */ - fun address(address: ExternalBankAccountAddress?) = apply { this.address = address } + fun address(address: ExternalBankAccountAddress) = address(JsonField.of(address)) + + /** Address */ + fun address(address: JsonField) = apply { + this.address = address + } + + /** Optional field that helps identify bank accounts in receipts */ + fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** Optional field that helps identify bank accounts in receipts */ - fun companyId(companyId: String?) = apply { this.companyId = companyId } + fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** Date of Birth of the Individual that owns the external bank account */ - fun dob(dob: LocalDate?) = apply { this.dob = dob } + fun dob(dob: LocalDate) = dob(JsonField.of(dob)) + + /** Date of Birth of the Individual that owns the external bank account */ + fun dob(dob: JsonField) = apply { this.dob = dob } + + /** Doing Business As */ + fun doingBusinessAs(doingBusinessAs: String) = + doingBusinessAs(JsonField.of(doingBusinessAs)) /** Doing Business As */ - fun doingBusinessAs(doingBusinessAs: String?) = apply { + fun doingBusinessAs(doingBusinessAs: JsonField) = apply { this.doingBusinessAs = doingBusinessAs } /** The nickname for this External Bank Account */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The nickname for this External Bank Account */ + fun name(name: JsonField) = apply { this.name = name } /** * Legal Name of the business or individual who owns the external account. This will * appear in statements */ - fun owner(owner: String?) = apply { this.owner = owner } + fun owner(owner: String) = owner(JsonField.of(owner)) + + /** + * Legal Name of the business or individual who owns the external account. This will + * appear in statements + */ + fun owner(owner: JsonField) = apply { this.owner = owner } + + /** Owner Type */ + fun ownerType(ownerType: OwnerType) = ownerType(JsonField.of(ownerType)) /** Owner Type */ - fun ownerType(ownerType: OwnerType?) = apply { this.ownerType = ownerType } + fun ownerType(ownerType: JsonField) = apply { this.ownerType = ownerType } /** User Defined ID */ - fun userDefinedId(userDefinedId: String?) = apply { this.userDefinedId = userDefinedId } + fun userDefinedId(userDefinedId: String) = userDefinedId(JsonField.of(userDefinedId)) + + /** User Defined ID */ + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -263,33 +391,85 @@ constructor( } /** Address */ - fun address(address: ExternalBankAccountAddress?) = apply { body.address(address) } + fun address(address: ExternalBankAccountAddress) = apply { body.address(address) } + + /** Address */ + fun address(address: JsonField) = apply { + body.address(address) + } /** Optional field that helps identify bank accounts in receipts */ - fun companyId(companyId: String?) = apply { body.companyId(companyId) } + fun companyId(companyId: String) = apply { body.companyId(companyId) } + + /** Optional field that helps identify bank accounts in receipts */ + fun companyId(companyId: JsonField) = apply { body.companyId(companyId) } /** Date of Birth of the Individual that owns the external bank account */ - fun dob(dob: LocalDate?) = apply { body.dob(dob) } + fun dob(dob: LocalDate) = apply { body.dob(dob) } + + /** Date of Birth of the Individual that owns the external bank account */ + fun dob(dob: JsonField) = apply { body.dob(dob) } /** Doing Business As */ - fun doingBusinessAs(doingBusinessAs: String?) = apply { + fun doingBusinessAs(doingBusinessAs: String) = apply { body.doingBusinessAs(doingBusinessAs) } + /** Doing Business As */ + fun doingBusinessAs(doingBusinessAs: JsonField) = apply { + body.doingBusinessAs(doingBusinessAs) + } + + /** The nickname for this External Bank Account */ + fun name(name: String) = apply { body.name(name) } + /** The nickname for this External Bank Account */ - fun name(name: String?) = apply { body.name(name) } + fun name(name: JsonField) = apply { body.name(name) } /** * Legal Name of the business or individual who owns the external account. This will appear * in statements */ - fun owner(owner: String?) = apply { body.owner(owner) } + fun owner(owner: String) = apply { body.owner(owner) } + + /** + * Legal Name of the business or individual who owns the external account. This will appear + * in statements + */ + fun owner(owner: JsonField) = apply { body.owner(owner) } /** Owner Type */ - fun ownerType(ownerType: OwnerType?) = apply { body.ownerType(ownerType) } + fun ownerType(ownerType: OwnerType) = apply { body.ownerType(ownerType) } + + /** Owner Type */ + fun ownerType(ownerType: JsonField) = apply { body.ownerType(ownerType) } + + /** User Defined ID */ + fun userDefinedId(userDefinedId: String) = apply { body.userDefinedId(userDefinedId) } /** User Defined ID */ - fun userDefinedId(userDefinedId: String?) = apply { body.userDefinedId(userDefinedId) } + fun userDefinedId(userDefinedId: JsonField) = apply { + body.userDefinedId(userDefinedId) + } + + 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() @@ -389,25 +569,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ExternalBankAccountUpdateParams = ExternalBankAccountUpdateParams( checkNotNull(externalBankAccountToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUpdateResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUpdateResponse.kt index c4c292d4..4a2e0146 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUpdateResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUpdateResponse.kt @@ -171,82 +171,94 @@ private constructor( * program links an external bank account to more than one end-user or to both the program and * the end-user, then Lithic will return each record of the association */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * The country that the bank account is located in using ISO 3166-1. We will only accept USA * bank accounts e.g., USA */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** An ISO 8601 string representing when this funding source was added to the Lithic account. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** currency of the external account 3-digit alphabetic ISO 4217 code */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The last 4 digits of the bank account. Derived by Lithic from the account number passed */ - @JsonProperty("last_four") @ExcludeMissing fun _lastFour() = lastFour + @JsonProperty("last_four") @ExcludeMissing fun _lastFour(): JsonField = lastFour /** * Legal Name of the business or individual who owns the external account. This will appear in * statements */ - @JsonProperty("owner") @ExcludeMissing fun _owner() = owner + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner /** Owner Type */ - @JsonProperty("owner_type") @ExcludeMissing fun _ownerType() = ownerType + @JsonProperty("owner_type") @ExcludeMissing fun _ownerType(): JsonField = ownerType /** Routing Number */ - @JsonProperty("routing_number") @ExcludeMissing fun _routingNumber() = routingNumber + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber /** Account State */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** Account Type */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** The number of attempts at verification */ @JsonProperty("verification_attempts") @ExcludeMissing - fun _verificationAttempts() = verificationAttempts + fun _verificationAttempts(): JsonField = verificationAttempts /** Verification Method */ @JsonProperty("verification_method") @ExcludeMissing - fun _verificationMethod() = verificationMethod + fun _verificationMethod(): JsonField = verificationMethod /** Verification State */ - @JsonProperty("verification_state") @ExcludeMissing fun _verificationState() = verificationState + @JsonProperty("verification_state") + @ExcludeMissing + fun _verificationState(): JsonField = verificationState /** * Indicates which Lithic account the external account is associated with. For external accounts * that are associated with the program, account_token field returned will be null */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** Address */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") + @ExcludeMissing + fun _address(): JsonField = address /** Optional field that helps identify bank accounts in receipts */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Date of Birth of the Individual that owns the external bank account */ - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** Doing Business As */ - @JsonProperty("doing_business_as") @ExcludeMissing fun _doingBusinessAs() = doingBusinessAs + @JsonProperty("doing_business_as") + @ExcludeMissing + fun _doingBusinessAs(): JsonField = doingBusinessAs /** The financial account token of the operating account to fund the micro deposits */ @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken /** The nickname for this External Bank Account */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** User Defined ID */ - @JsonProperty("user_defined_id") @ExcludeMissing fun _userDefinedId() = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId /** * Optional free text description of the reason for the failed verification. For ACH @@ -255,7 +267,7 @@ private constructor( */ @JsonProperty("verification_failed_reason") @ExcludeMissing - fun _verificationFailedReason() = verificationFailedReason + fun _verificationFailedReason(): JsonField = verificationFailedReason @JsonAnyGetter @ExcludeMissing @@ -300,19 +312,19 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var lastFour: JsonField = JsonMissing.of() - private var owner: JsonField = JsonMissing.of() - private var ownerType: JsonField = JsonMissing.of() - private var routingNumber: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var verificationAttempts: JsonField = JsonMissing.of() - private var verificationMethod: JsonField = JsonMissing.of() - private var verificationState: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var country: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var lastFour: JsonField? = null + private var owner: JsonField? = null + private var ownerType: JsonField? = null + private var routingNumber: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var verificationAttempts: JsonField? = null + private var verificationMethod: JsonField? = null + private var verificationState: JsonField? = null private var accountToken: JsonField = JsonMissing.of() private var address: JsonField = JsonMissing.of() private var companyId: JsonField = JsonMissing.of() @@ -574,19 +586,25 @@ private constructor( fun build(): ExternalBankAccountUpdateResponse = ExternalBankAccountUpdateResponse( - token, - country, - created, - currency, - lastFour, - owner, - ownerType, - routingNumber, - state, - type, - verificationAttempts, - verificationMethod, - verificationState, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(lastFour) { "`lastFour` is required but was not set" }, + checkNotNull(owner) { "`owner` is required but was not set" }, + checkNotNull(ownerType) { "`ownerType` is required but was not set" }, + checkNotNull(routingNumber) { "`routingNumber` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(verificationAttempts) { + "`verificationAttempts` is required but was not set" + }, + checkNotNull(verificationMethod) { + "`verificationMethod` is required but was not set" + }, + checkNotNull(verificationState) { + "`verificationState` is required but was not set" + }, accountToken, address, companyId, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt index 9603d92f..ee542dad 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt @@ -90,33 +90,45 @@ private constructor( fun userDefinedId(): String? = userDefinedId.getNullable("user_defined_id") - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - @JsonProperty("category") @ExcludeMissing fun _category() = category + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken - @JsonProperty("payment_type") @ExcludeMissing fun _paymentType() = paymentType + @JsonProperty("payment_type") + @ExcludeMissing + fun _paymentType(): JsonField = paymentType - @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result - @JsonProperty("settled_amount") @ExcludeMissing fun _settledAmount() = settledAmount + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated - @JsonProperty("user_defined_id") @ExcludeMissing fun _userDefinedId() = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId @JsonAnyGetter @ExcludeMissing @@ -152,18 +164,18 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var category: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var events: JsonField> = JsonMissing.of() - private var financialAccountToken: JsonField = JsonMissing.of() - private var paymentType: JsonField = JsonMissing.of() - private var pendingAmount: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var settledAmount: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var events: JsonField>? = null + private var financialAccountToken: JsonField? = null + private var paymentType: JsonField? = null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null private var userDefinedId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -172,7 +184,7 @@ private constructor( category = externalPayment.category created = externalPayment.created currency = externalPayment.currency - events = externalPayment.events + events = externalPayment.events.map { it.toMutableList() } financialAccountToken = externalPayment.financialAccountToken paymentType = externalPayment.paymentType pendingAmount = externalPayment.pendingAmount @@ -204,7 +216,20 @@ private constructor( fun events(events: List) = events(JsonField.of(events)) - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + fun addEvent(event: ExternalPaymentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(event) + } + } fun financialAccountToken(financialAccountToken: String) = financialAccountToken(JsonField.of(financialAccountToken)) @@ -271,18 +296,21 @@ private constructor( fun build(): ExternalPayment = ExternalPayment( - token, - category, - created, - currency, - events.map { it.toImmutable() }, - financialAccountToken, - paymentType, - pendingAmount, - result, - settledAmount, - status, - updated, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(category) { "`category` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(events) { "`events` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + checkNotNull(paymentType) { "`paymentType` is required but was not set" }, + checkNotNull(pendingAmount) { "`pendingAmount` is required but was not set" }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(settledAmount) { "`settledAmount` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, userDefinedId, additionalProperties.toImmutable(), ) @@ -406,21 +434,27 @@ private constructor( fun type(): ExternalPaymentEventType = type.getRequired("type") - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - @JsonProperty("detailed_results") @ExcludeMissing fun _detailedResults() = detailedResults + @JsonProperty("detailed_results") + @ExcludeMissing + fun _detailedResults(): JsonField> = detailedResults - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("memo") @ExcludeMissing fun _memo() = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -451,21 +485,21 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var detailedResults: JsonField> = JsonMissing.of() - private var effectiveDate: JsonField = JsonMissing.of() - private var memo: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var amount: JsonField? = null + private var created: JsonField? = null + private var detailedResults: JsonField>? = null + private var effectiveDate: JsonField? = null + private var memo: JsonField? = null + private var result: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(externalPaymentEvent: ExternalPaymentEvent) = apply { token = externalPaymentEvent.token amount = externalPaymentEvent.amount created = externalPaymentEvent.created - detailedResults = externalPaymentEvent.detailedResults + detailedResults = externalPaymentEvent.detailedResults.map { it.toMutableList() } effectiveDate = externalPaymentEvent.effectiveDate memo = externalPaymentEvent.memo result = externalPaymentEvent.result @@ -489,7 +523,18 @@ private constructor( detailedResults(JsonField.of(detailedResults)) fun detailedResults(detailedResults: JsonField>) = apply { - this.detailedResults = detailedResults + this.detailedResults = detailedResults.map { it.toMutableList() } + } + + fun addDetailedResult(detailedResult: DetailedResults) = apply { + detailedResults = + (detailedResults ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(detailedResult) + } } fun effectiveDate(effectiveDate: LocalDate) = effectiveDate(JsonField.of(effectiveDate)) @@ -531,14 +576,17 @@ private constructor( fun build(): ExternalPaymentEvent = ExternalPaymentEvent( - token, - amount, - created, - detailedResults.map { it.toImmutable() }, - effectiveDate, - memo, - result, - type, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(detailedResults) { + "`detailedResults` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + checkNotNull(memo) { "`memo` is required but was not set" }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCancelParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCancelParams.kt index 6392fe73..d26ea1c8 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCancelParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCancelParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -31,12 +33,16 @@ constructor( fun memo(): String? = body.memo() - fun _additionalHeaders(): Headers = additionalHeaders + fun _effectiveDate(): JsonField = body._effectiveDate() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _memo(): JsonField = body._memo() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): ExternalPaymentCancelBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -54,20 +60,40 @@ constructor( class ExternalPaymentCancelBody @JsonCreator internal constructor( - @JsonProperty("effective_date") private val effectiveDate: LocalDate, - @JsonProperty("memo") private val memo: String?, + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("effective_date") fun effectiveDate(): LocalDate = effectiveDate + fun effectiveDate(): LocalDate = effectiveDate.getRequired("effective_date") - @JsonProperty("memo") fun memo(): String? = memo + fun memo(): String? = memo.getNullable("memo") + + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExternalPaymentCancelBody = apply { + if (!validated) { + effectiveDate() + memo() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -77,8 +103,8 @@ constructor( class Builder { - private var effectiveDate: LocalDate? = null - private var memo: String? = null + private var effectiveDate: JsonField? = null + private var memo: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(externalPaymentCancelBody: ExternalPaymentCancelBody) = apply { @@ -87,11 +113,15 @@ constructor( additionalProperties = externalPaymentCancelBody.additionalProperties.toMutableMap() } - fun effectiveDate(effectiveDate: LocalDate) = apply { + fun effectiveDate(effectiveDate: LocalDate) = effectiveDate(JsonField.of(effectiveDate)) + + fun effectiveDate(effectiveDate: JsonField) = apply { this.effectiveDate = effectiveDate } - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String) = memo(JsonField.of(memo)) + + fun memo(memo: JsonField) = apply { this.memo = memo } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -166,7 +196,32 @@ constructor( fun effectiveDate(effectiveDate: LocalDate) = apply { body.effectiveDate(effectiveDate) } - fun memo(memo: String?) = apply { body.memo(memo) } + fun effectiveDate(effectiveDate: JsonField) = apply { + body.effectiveDate(effectiveDate) + } + + fun memo(memo: String) = apply { body.memo(memo) } + + fun memo(memo: JsonField) = apply { body.memo(memo) } + + 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() @@ -266,25 +321,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ExternalPaymentCancelParams = ExternalPaymentCancelParams( checkNotNull(externalPaymentToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreateParams.kt index 5b14fba1..63c4b2a2 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -45,12 +46,30 @@ constructor( fun userDefinedId(): String? = body.userDefinedId() - fun _additionalHeaders(): Headers = additionalHeaders + fun _amount(): JsonField = body._amount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _category(): JsonField = body._category() + + fun _effectiveDate(): JsonField = body._effectiveDate() + + fun _financialAccountToken(): JsonField = body._financialAccountToken() + + fun _paymentType(): JsonField = body._paymentType() + + fun _token(): JsonField = body._token() + + fun _memo(): JsonField = body._memo() + + fun _progressTo(): JsonField = body._progressTo() + + fun _userDefinedId(): JsonField = body._userDefinedId() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): ExternalPaymentCreateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -61,42 +80,107 @@ constructor( class ExternalPaymentCreateBody @JsonCreator internal constructor( - @JsonProperty("amount") private val amount: Long, - @JsonProperty("category") private val category: ExternalPaymentCategory, - @JsonProperty("effective_date") private val effectiveDate: LocalDate, - @JsonProperty("financial_account_token") private val financialAccountToken: String, - @JsonProperty("payment_type") private val paymentType: ExternalPaymentDirection, - @JsonProperty("token") private val token: String?, - @JsonProperty("memo") private val memo: String?, - @JsonProperty("progress_to") private val progressTo: ExternalPaymentProgressTo?, - @JsonProperty("user_defined_id") private val userDefinedId: String?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + private val category: JsonField = JsonMissing.of(), + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + private val financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("payment_type") + @ExcludeMissing + private val paymentType: JsonField = JsonMissing.of(), + @JsonProperty("token") + @ExcludeMissing + private val token: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), + @JsonProperty("progress_to") + @ExcludeMissing + private val progressTo: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + private val userDefinedId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("amount") fun amount(): Long = amount + fun amount(): Long = amount.getRequired("amount") + + fun category(): ExternalPaymentCategory = category.getRequired("category") + + fun effectiveDate(): LocalDate = effectiveDate.getRequired("effective_date") + + fun financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + fun paymentType(): ExternalPaymentDirection = paymentType.getRequired("payment_type") - @JsonProperty("category") fun category(): ExternalPaymentCategory = category + fun token(): String? = token.getNullable("token") - @JsonProperty("effective_date") fun effectiveDate(): LocalDate = effectiveDate + fun memo(): String? = memo.getNullable("memo") + + fun progressTo(): ExternalPaymentProgressTo? = progressTo.getNullable("progress_to") + + fun userDefinedId(): String? = userDefinedId.getNullable("user_defined_id") + + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category + + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate @JsonProperty("financial_account_token") - fun financialAccountToken(): String = financialAccountToken + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken - @JsonProperty("payment_type") fun paymentType(): ExternalPaymentDirection = paymentType + @JsonProperty("payment_type") + @ExcludeMissing + fun _paymentType(): JsonField = paymentType - @JsonProperty("token") fun token(): String? = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - @JsonProperty("memo") fun memo(): String? = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - @JsonProperty("progress_to") fun progressTo(): ExternalPaymentProgressTo? = progressTo + @JsonProperty("progress_to") + @ExcludeMissing + fun _progressTo(): JsonField = progressTo - @JsonProperty("user_defined_id") fun userDefinedId(): String? = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExternalPaymentCreateBody = apply { + if (!validated) { + amount() + category() + effectiveDate() + financialAccountToken() + paymentType() + token() + memo() + progressTo() + userDefinedId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -106,15 +190,15 @@ constructor( class Builder { - private var amount: Long? = null - private var category: ExternalPaymentCategory? = null - private var effectiveDate: LocalDate? = null - private var financialAccountToken: String? = null - private var paymentType: ExternalPaymentDirection? = null - private var token: String? = null - private var memo: String? = null - private var progressTo: ExternalPaymentProgressTo? = null - private var userDefinedId: String? = null + private var amount: JsonField? = null + private var category: JsonField? = null + private var effectiveDate: JsonField? = null + private var financialAccountToken: JsonField? = null + private var paymentType: JsonField? = null + private var token: JsonField = JsonMissing.of() + private var memo: JsonField = JsonMissing.of() + private var progressTo: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(externalPaymentCreateBody: ExternalPaymentCreateBody) = apply { @@ -130,31 +214,56 @@ constructor( additionalProperties = externalPaymentCreateBody.additionalProperties.toMutableMap() } - fun amount(amount: Long) = apply { this.amount = amount } + fun amount(amount: Long) = amount(JsonField.of(amount)) - fun category(category: ExternalPaymentCategory) = apply { this.category = category } + fun amount(amount: JsonField) = apply { this.amount = amount } - fun effectiveDate(effectiveDate: LocalDate) = apply { + fun category(category: ExternalPaymentCategory) = category(JsonField.of(category)) + + fun category(category: JsonField) = apply { + this.category = category + } + + fun effectiveDate(effectiveDate: LocalDate) = effectiveDate(JsonField.of(effectiveDate)) + + fun effectiveDate(effectiveDate: JsonField) = apply { this.effectiveDate = effectiveDate } - fun financialAccountToken(financialAccountToken: String) = apply { + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + fun financialAccountToken(financialAccountToken: JsonField) = apply { this.financialAccountToken = financialAccountToken } - fun paymentType(paymentType: ExternalPaymentDirection) = apply { + fun paymentType(paymentType: ExternalPaymentDirection) = + paymentType(JsonField.of(paymentType)) + + fun paymentType(paymentType: JsonField) = apply { this.paymentType = paymentType } - fun token(token: String?) = apply { this.token = token } + fun token(token: String) = token(JsonField.of(token)) + + fun token(token: JsonField) = apply { this.token = token } - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String) = memo(JsonField.of(memo)) - fun progressTo(progressTo: ExternalPaymentProgressTo?) = apply { + fun memo(memo: JsonField) = apply { this.memo = memo } + + fun progressTo(progressTo: ExternalPaymentProgressTo) = + progressTo(JsonField.of(progressTo)) + + fun progressTo(progressTo: JsonField) = apply { this.progressTo = progressTo } - fun userDefinedId(userDefinedId: String?) = apply { this.userDefinedId = userDefinedId } + fun userDefinedId(userDefinedId: String) = userDefinedId(JsonField.of(userDefinedId)) + + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -232,27 +341,76 @@ constructor( fun amount(amount: Long) = apply { body.amount(amount) } + fun amount(amount: JsonField) = apply { body.amount(amount) } + fun category(category: ExternalPaymentCategory) = apply { body.category(category) } + fun category(category: JsonField) = apply { + body.category(category) + } + fun effectiveDate(effectiveDate: LocalDate) = apply { body.effectiveDate(effectiveDate) } + fun effectiveDate(effectiveDate: JsonField) = apply { + body.effectiveDate(effectiveDate) + } + fun financialAccountToken(financialAccountToken: String) = apply { body.financialAccountToken(financialAccountToken) } + fun financialAccountToken(financialAccountToken: JsonField) = apply { + body.financialAccountToken(financialAccountToken) + } + fun paymentType(paymentType: ExternalPaymentDirection) = apply { body.paymentType(paymentType) } - fun token(token: String?) = apply { body.token(token) } + fun paymentType(paymentType: JsonField) = apply { + body.paymentType(paymentType) + } + + fun token(token: String) = apply { body.token(token) } + + fun token(token: JsonField) = apply { body.token(token) } + + fun memo(memo: String) = apply { body.memo(memo) } - fun memo(memo: String?) = apply { body.memo(memo) } + fun memo(memo: JsonField) = apply { body.memo(memo) } + + fun progressTo(progressTo: ExternalPaymentProgressTo) = apply { + body.progressTo(progressTo) + } - fun progressTo(progressTo: ExternalPaymentProgressTo?) = apply { + fun progressTo(progressTo: JsonField) = apply { body.progressTo(progressTo) } - fun userDefinedId(userDefinedId: String?) = apply { body.userDefinedId(userDefinedId) } + fun userDefinedId(userDefinedId: String) = apply { body.userDefinedId(userDefinedId) } + + fun userDefinedId(userDefinedId: JsonField) = apply { + body.userDefinedId(userDefinedId) + } + + 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() @@ -352,25 +510,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ExternalPaymentCreateParams = ExternalPaymentCreateParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentReleaseParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentReleaseParams.kt index 353600ca..2ba9b09e 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentReleaseParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentReleaseParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -31,12 +33,16 @@ constructor( fun memo(): String? = body.memo() - fun _additionalHeaders(): Headers = additionalHeaders + fun _effectiveDate(): JsonField = body._effectiveDate() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _memo(): JsonField = body._memo() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): ExternalPaymentReleaseBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -54,20 +60,40 @@ constructor( class ExternalPaymentReleaseBody @JsonCreator internal constructor( - @JsonProperty("effective_date") private val effectiveDate: LocalDate, - @JsonProperty("memo") private val memo: String?, + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("effective_date") fun effectiveDate(): LocalDate = effectiveDate + fun effectiveDate(): LocalDate = effectiveDate.getRequired("effective_date") - @JsonProperty("memo") fun memo(): String? = memo + fun memo(): String? = memo.getNullable("memo") + + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExternalPaymentReleaseBody = apply { + if (!validated) { + effectiveDate() + memo() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -77,8 +103,8 @@ constructor( class Builder { - private var effectiveDate: LocalDate? = null - private var memo: String? = null + private var effectiveDate: JsonField? = null + private var memo: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(externalPaymentReleaseBody: ExternalPaymentReleaseBody) = apply { @@ -88,11 +114,15 @@ constructor( externalPaymentReleaseBody.additionalProperties.toMutableMap() } - fun effectiveDate(effectiveDate: LocalDate) = apply { + fun effectiveDate(effectiveDate: LocalDate) = effectiveDate(JsonField.of(effectiveDate)) + + fun effectiveDate(effectiveDate: JsonField) = apply { this.effectiveDate = effectiveDate } - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String) = memo(JsonField.of(memo)) + + fun memo(memo: JsonField) = apply { this.memo = memo } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -167,7 +197,32 @@ constructor( fun effectiveDate(effectiveDate: LocalDate) = apply { body.effectiveDate(effectiveDate) } - fun memo(memo: String?) = apply { body.memo(memo) } + fun effectiveDate(effectiveDate: JsonField) = apply { + body.effectiveDate(effectiveDate) + } + + fun memo(memo: String) = apply { body.memo(memo) } + + fun memo(memo: JsonField) = apply { body.memo(memo) } + + 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() @@ -267,25 +322,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ExternalPaymentReleaseParams = ExternalPaymentReleaseParams( checkNotNull(externalPaymentToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentReverseParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentReverseParams.kt index 67068758..de92eb1f 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentReverseParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentReverseParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -31,12 +33,16 @@ constructor( fun memo(): String? = body.memo() - fun _additionalHeaders(): Headers = additionalHeaders + fun _effectiveDate(): JsonField = body._effectiveDate() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _memo(): JsonField = body._memo() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): ExternalPaymentReverseBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -54,20 +60,40 @@ constructor( class ExternalPaymentReverseBody @JsonCreator internal constructor( - @JsonProperty("effective_date") private val effectiveDate: LocalDate, - @JsonProperty("memo") private val memo: String?, + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("effective_date") fun effectiveDate(): LocalDate = effectiveDate + fun effectiveDate(): LocalDate = effectiveDate.getRequired("effective_date") - @JsonProperty("memo") fun memo(): String? = memo + fun memo(): String? = memo.getNullable("memo") + + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExternalPaymentReverseBody = apply { + if (!validated) { + effectiveDate() + memo() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -77,8 +103,8 @@ constructor( class Builder { - private var effectiveDate: LocalDate? = null - private var memo: String? = null + private var effectiveDate: JsonField? = null + private var memo: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(externalPaymentReverseBody: ExternalPaymentReverseBody) = apply { @@ -88,11 +114,15 @@ constructor( externalPaymentReverseBody.additionalProperties.toMutableMap() } - fun effectiveDate(effectiveDate: LocalDate) = apply { + fun effectiveDate(effectiveDate: LocalDate) = effectiveDate(JsonField.of(effectiveDate)) + + fun effectiveDate(effectiveDate: JsonField) = apply { this.effectiveDate = effectiveDate } - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String) = memo(JsonField.of(memo)) + + fun memo(memo: JsonField) = apply { this.memo = memo } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -167,7 +197,32 @@ constructor( fun effectiveDate(effectiveDate: LocalDate) = apply { body.effectiveDate(effectiveDate) } - fun memo(memo: String?) = apply { body.memo(memo) } + fun effectiveDate(effectiveDate: JsonField) = apply { + body.effectiveDate(effectiveDate) + } + + fun memo(memo: String) = apply { body.memo(memo) } + + fun memo(memo: JsonField) = apply { body.memo(memo) } + + 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() @@ -267,25 +322,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ExternalPaymentReverseParams = ExternalPaymentReverseParams( checkNotNull(externalPaymentToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentSettleParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentSettleParams.kt index e7327214..3ede3123 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentSettleParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentSettleParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -36,12 +37,18 @@ constructor( fun progressTo(): ExternalPaymentProgressTo? = body.progressTo() - fun _additionalHeaders(): Headers = additionalHeaders + fun _effectiveDate(): JsonField = body._effectiveDate() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _memo(): JsonField = body._memo() + + fun _progressTo(): JsonField = body._progressTo() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): ExternalPaymentSettleBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -59,23 +66,50 @@ constructor( class ExternalPaymentSettleBody @JsonCreator internal constructor( - @JsonProperty("effective_date") private val effectiveDate: LocalDate, - @JsonProperty("memo") private val memo: String?, - @JsonProperty("progress_to") private val progressTo: ExternalPaymentProgressTo?, + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), + @JsonProperty("progress_to") + @ExcludeMissing + private val progressTo: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("effective_date") fun effectiveDate(): LocalDate = effectiveDate + fun effectiveDate(): LocalDate = effectiveDate.getRequired("effective_date") + + fun memo(): String? = memo.getNullable("memo") + + fun progressTo(): ExternalPaymentProgressTo? = progressTo.getNullable("progress_to") + + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("memo") fun memo(): String? = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - @JsonProperty("progress_to") fun progressTo(): ExternalPaymentProgressTo? = progressTo + @JsonProperty("progress_to") + @ExcludeMissing + fun _progressTo(): JsonField = progressTo @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExternalPaymentSettleBody = apply { + if (!validated) { + effectiveDate() + memo() + progressTo() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -85,9 +119,9 @@ constructor( class Builder { - private var effectiveDate: LocalDate? = null - private var memo: String? = null - private var progressTo: ExternalPaymentProgressTo? = null + private var effectiveDate: JsonField? = null + private var memo: JsonField = JsonMissing.of() + private var progressTo: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(externalPaymentSettleBody: ExternalPaymentSettleBody) = apply { @@ -97,13 +131,20 @@ constructor( additionalProperties = externalPaymentSettleBody.additionalProperties.toMutableMap() } - fun effectiveDate(effectiveDate: LocalDate) = apply { + fun effectiveDate(effectiveDate: LocalDate) = effectiveDate(JsonField.of(effectiveDate)) + + fun effectiveDate(effectiveDate: JsonField) = apply { this.effectiveDate = effectiveDate } - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String) = memo(JsonField.of(memo)) + + fun memo(memo: JsonField) = apply { this.memo = memo } - fun progressTo(progressTo: ExternalPaymentProgressTo?) = apply { + fun progressTo(progressTo: ExternalPaymentProgressTo) = + progressTo(JsonField.of(progressTo)) + + fun progressTo(progressTo: JsonField) = apply { this.progressTo = progressTo } @@ -181,12 +222,41 @@ constructor( fun effectiveDate(effectiveDate: LocalDate) = apply { body.effectiveDate(effectiveDate) } - fun memo(memo: String?) = apply { body.memo(memo) } + fun effectiveDate(effectiveDate: JsonField) = apply { + body.effectiveDate(effectiveDate) + } + + fun memo(memo: String) = apply { body.memo(memo) } + + fun memo(memo: JsonField) = apply { body.memo(memo) } - fun progressTo(progressTo: ExternalPaymentProgressTo?) = apply { + fun progressTo(progressTo: ExternalPaymentProgressTo) = apply { body.progressTo(progressTo) } + fun progressTo(progressTo: JsonField) = apply { + body.progressTo(progressTo) + } + + 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) @@ -285,25 +355,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ExternalPaymentSettleParams = ExternalPaymentSettleParams( checkNotNull(externalPaymentToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccount.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccount.kt index 5962d39a..5d9d6eb1 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccount.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccount.kt @@ -75,28 +75,36 @@ private constructor( fun routingNumber(): String? = routingNumber.getNullable("routing_number") /** Globally unique identifier for the account */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created @JsonProperty("credit_configuration") @ExcludeMissing - fun _creditConfiguration() = creditConfiguration + fun _creditConfiguration(): JsonField = creditConfiguration /** Whether financial account is for the benefit of another entity */ - @JsonProperty("is_for_benefit_of") @ExcludeMissing fun _isForBenefitOf() = isForBenefitOf + @JsonProperty("is_for_benefit_of") + @ExcludeMissing + fun _isForBenefitOf(): JsonField = isForBenefitOf - @JsonProperty("nickname") @ExcludeMissing fun _nickname() = nickname + @JsonProperty("nickname") @ExcludeMissing fun _nickname(): JsonField = nickname - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated - @JsonProperty("account_number") @ExcludeMissing fun _accountNumber() = accountNumber + @JsonProperty("account_number") + @ExcludeMissing + fun _accountNumber(): JsonField = accountNumber - @JsonProperty("routing_number") @ExcludeMissing fun _routingNumber() = routingNumber + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber @JsonAnyGetter @ExcludeMissing @@ -129,14 +137,14 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountToken: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var creditConfiguration: JsonField = JsonMissing.of() - private var isForBenefitOf: JsonField = JsonMissing.of() - private var nickname: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var accountToken: JsonField? = null + private var created: JsonField? = null + private var creditConfiguration: JsonField? = null + private var isForBenefitOf: JsonField? = null + private var nickname: JsonField? = null + private var type: JsonField? = null + private var updated: JsonField? = null private var accountNumber: JsonField = JsonMissing.of() private var routingNumber: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -161,7 +169,7 @@ private constructor( /** Globally unique identifier for the account */ fun token(token: JsonField) = apply { this.token = token } - fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + fun accountToken(accountToken: String?) = accountToken(JsonField.ofNullable(accountToken)) fun accountToken(accountToken: JsonField) = apply { this.accountToken = accountToken @@ -171,8 +179,8 @@ private constructor( fun created(created: JsonField) = apply { this.created = created } - fun creditConfiguration(creditConfiguration: FinancialAccountCreditConfig) = - creditConfiguration(JsonField.of(creditConfiguration)) + fun creditConfiguration(creditConfiguration: FinancialAccountCreditConfig?) = + creditConfiguration(JsonField.ofNullable(creditConfiguration)) fun creditConfiguration(creditConfiguration: JsonField) = apply { @@ -187,7 +195,7 @@ private constructor( this.isForBenefitOf = isForBenefitOf } - fun nickname(nickname: String) = nickname(JsonField.of(nickname)) + fun nickname(nickname: String?) = nickname(JsonField.ofNullable(nickname)) fun nickname(nickname: JsonField) = apply { this.nickname = nickname } @@ -199,13 +207,15 @@ private constructor( fun updated(updated: JsonField) = apply { this.updated = updated } - fun accountNumber(accountNumber: String) = accountNumber(JsonField.of(accountNumber)) + fun accountNumber(accountNumber: String?) = + accountNumber(JsonField.ofNullable(accountNumber)) fun accountNumber(accountNumber: JsonField) = apply { this.accountNumber = accountNumber } - fun routingNumber(routingNumber: String) = routingNumber(JsonField.of(routingNumber)) + fun routingNumber(routingNumber: String?) = + routingNumber(JsonField.ofNullable(routingNumber)) fun routingNumber(routingNumber: JsonField) = apply { this.routingNumber = routingNumber @@ -232,14 +242,16 @@ private constructor( fun build(): FinancialAccount = FinancialAccount( - token, - accountToken, - created, - creditConfiguration, - isForBenefitOf, - nickname, - type, - updated, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountToken) { "`accountToken` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(creditConfiguration) { + "`creditConfiguration` is required but was not set" + }, + checkNotNull(isForBenefitOf) { "`isForBenefitOf` is required but was not set" }, + checkNotNull(nickname) { "`nickname` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, accountNumber, routingNumber, additionalProperties.toImmutable(), @@ -299,28 +311,32 @@ private constructor( /** Reason for the financial account being marked as Charged Off */ @JsonProperty("charged_off_reason") @ExcludeMissing - fun _chargedOffReason() = chargedOffReason + fun _chargedOffReason(): JsonField = chargedOffReason - @JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit() = creditLimit + @JsonProperty("credit_limit") + @ExcludeMissing + fun _creditLimit(): JsonField = creditLimit /** Globally unique identifier for the credit product */ @JsonProperty("credit_product_token") @ExcludeMissing - fun _creditProductToken() = creditProductToken + fun _creditProductToken(): JsonField = creditProductToken @JsonProperty("external_bank_account_token") @ExcludeMissing - fun _externalBankAccountToken() = externalBankAccountToken + fun _externalBankAccountToken(): JsonField = externalBankAccountToken /** State of the financial account */ @JsonProperty("financial_account_state") @ExcludeMissing - fun _financialAccountState() = financialAccountState + fun _financialAccountState(): JsonField = financialAccountState - @JsonProperty("is_spend_blocked") @ExcludeMissing fun _isSpendBlocked() = isSpendBlocked + @JsonProperty("is_spend_blocked") + @ExcludeMissing + fun _isSpendBlocked(): JsonField = isSpendBlocked /** Tier assigned to the financial account */ - @JsonProperty("tier") @ExcludeMissing fun _tier() = tier + @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField = tier @JsonAnyGetter @ExcludeMissing @@ -350,13 +366,13 @@ private constructor( class Builder { - private var chargedOffReason: JsonField = JsonMissing.of() - private var creditLimit: JsonField = JsonMissing.of() - private var creditProductToken: JsonField = JsonMissing.of() - private var externalBankAccountToken: JsonField = JsonMissing.of() - private var financialAccountState: JsonField = JsonMissing.of() - private var isSpendBlocked: JsonField = JsonMissing.of() - private var tier: JsonField = JsonMissing.of() + private var chargedOffReason: JsonField? = null + private var creditLimit: JsonField? = null + private var creditProductToken: JsonField? = null + private var externalBankAccountToken: JsonField? = null + private var financialAccountState: JsonField? = null + private var isSpendBlocked: JsonField? = null + private var tier: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(financialAccountCreditConfig: FinancialAccountCreditConfig) = apply { @@ -372,37 +388,39 @@ private constructor( } /** Reason for the financial account being marked as Charged Off */ - fun chargedOffReason(chargedOffReason: ChargedOffReason) = - chargedOffReason(JsonField.of(chargedOffReason)) + fun chargedOffReason(chargedOffReason: ChargedOffReason?) = + chargedOffReason(JsonField.ofNullable(chargedOffReason)) /** Reason for the financial account being marked as Charged Off */ fun chargedOffReason(chargedOffReason: JsonField) = apply { this.chargedOffReason = chargedOffReason } - fun creditLimit(creditLimit: Long) = creditLimit(JsonField.of(creditLimit)) + fun creditLimit(creditLimit: Long?) = creditLimit(JsonField.ofNullable(creditLimit)) + + fun creditLimit(creditLimit: Long) = creditLimit(creditLimit as Long?) fun creditLimit(creditLimit: JsonField) = apply { this.creditLimit = creditLimit } /** Globally unique identifier for the credit product */ - fun creditProductToken(creditProductToken: String) = - creditProductToken(JsonField.of(creditProductToken)) + fun creditProductToken(creditProductToken: String?) = + creditProductToken(JsonField.ofNullable(creditProductToken)) /** Globally unique identifier for the credit product */ fun creditProductToken(creditProductToken: JsonField) = apply { this.creditProductToken = creditProductToken } - fun externalBankAccountToken(externalBankAccountToken: String) = - externalBankAccountToken(JsonField.of(externalBankAccountToken)) + fun externalBankAccountToken(externalBankAccountToken: String?) = + externalBankAccountToken(JsonField.ofNullable(externalBankAccountToken)) fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { this.externalBankAccountToken = externalBankAccountToken } /** State of the financial account */ - fun financialAccountState(financialAccountState: FinancialAccountState) = - financialAccountState(JsonField.of(financialAccountState)) + fun financialAccountState(financialAccountState: FinancialAccountState?) = + financialAccountState(JsonField.ofNullable(financialAccountState)) /** State of the financial account */ fun financialAccountState(financialAccountState: JsonField) = @@ -418,7 +436,7 @@ private constructor( } /** Tier assigned to the financial account */ - fun tier(tier: String) = tier(JsonField.of(tier)) + fun tier(tier: String?) = tier(JsonField.ofNullable(tier)) /** Tier assigned to the financial account */ fun tier(tier: JsonField) = apply { this.tier = tier } @@ -444,13 +462,21 @@ private constructor( fun build(): FinancialAccountCreditConfig = FinancialAccountCreditConfig( - chargedOffReason, - creditLimit, - creditProductToken, - externalBankAccountToken, - financialAccountState, - isSpendBlocked, - tier, + checkNotNull(chargedOffReason) { + "`chargedOffReason` is required but was not set" + }, + checkNotNull(creditLimit) { "`creditLimit` is required but was not set" }, + checkNotNull(creditProductToken) { + "`creditProductToken` is required but was not set" + }, + checkNotNull(externalBankAccountToken) { + "`externalBankAccountToken` is required but was not set" + }, + checkNotNull(financialAccountState) { + "`financialAccountState` is required but was not set" + }, + checkNotNull(isSpendBlocked) { "`isSpendBlocked` is required but was not set" }, + checkNotNull(tier) { "`tier` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountChargeOffParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountChargeOffParams.kt index 8ba7bcf2..17798cc1 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountChargeOffParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountChargeOffParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -32,12 +33,15 @@ constructor( /** Reason for the financial account being marked as Charged Off */ fun reason(): ChargedOffReason = body.reason() + /** Reason for the financial account being marked as Charged Off */ + fun _reason(): JsonField = body._reason() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): FinancialAccountChargeOffBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -55,18 +59,32 @@ constructor( class FinancialAccountChargeOffBody @JsonCreator internal constructor( - @JsonProperty("reason") private val reason: ChargedOffReason, + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Reason for the financial account being marked as Charged Off */ - @JsonProperty("reason") fun reason(): ChargedOffReason = reason + fun reason(): ChargedOffReason = reason.getRequired("reason") + + /** Reason for the financial account being marked as Charged Off */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): FinancialAccountChargeOffBody = apply { + if (!validated) { + reason() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -76,7 +94,7 @@ constructor( class Builder { - private var reason: ChargedOffReason? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(financialAccountChargeOffBody: FinancialAccountChargeOffBody) = @@ -87,7 +105,10 @@ constructor( } /** Reason for the financial account being marked as Charged Off */ - fun reason(reason: ChargedOffReason) = apply { this.reason = reason } + fun reason(reason: ChargedOffReason) = reason(JsonField.of(reason)) + + /** Reason for the financial account being marked as Charged Off */ + fun reason(reason: JsonField) = apply { this.reason = reason } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -165,6 +186,28 @@ constructor( /** Reason for the financial account being marked as Charged Off */ fun reason(reason: ChargedOffReason) = apply { body.reason(reason) } + /** Reason for the financial account being marked as Charged Off */ + fun reason(reason: JsonField) = apply { body.reason(reason) } + + 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) @@ -263,25 +306,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): FinancialAccountChargeOffParams = FinancialAccountChargeOffParams( checkNotNull(financialAccountToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreateParams.kt index 5787b6e6..546eecc9 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -37,12 +38,20 @@ constructor( fun isForBenefitOf(): Boolean? = body.isForBenefitOf() - fun _additionalHeaders(): Headers = additionalHeaders + fun _nickname(): JsonField = body._nickname() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _type(): JsonField = body._type() + + fun _accountToken(): JsonField = body._accountToken() + + fun _isForBenefitOf(): JsonField = body._isForBenefitOf() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): FinancialAccountCreateBody = body internal fun getHeaders(): Headers { @@ -58,26 +67,56 @@ constructor( class FinancialAccountCreateBody @JsonCreator internal constructor( - @JsonProperty("nickname") private val nickname: String, - @JsonProperty("type") private val type: Type, - @JsonProperty("account_token") private val accountToken: String?, - @JsonProperty("is_for_benefit_of") private val isForBenefitOf: Boolean?, + @JsonProperty("nickname") + @ExcludeMissing + private val nickname: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + private val accountToken: JsonField = JsonMissing.of(), + @JsonProperty("is_for_benefit_of") + @ExcludeMissing + private val isForBenefitOf: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("nickname") fun nickname(): String = nickname + fun nickname(): String = nickname.getRequired("nickname") + + fun type(): Type = type.getRequired("type") - @JsonProperty("type") fun type(): Type = type + fun accountToken(): String? = accountToken.getNullable("account_token") - @JsonProperty("account_token") fun accountToken(): String? = accountToken + fun isForBenefitOf(): Boolean? = isForBenefitOf.getNullable("is_for_benefit_of") - @JsonProperty("is_for_benefit_of") fun isForBenefitOf(): Boolean? = isForBenefitOf + @JsonProperty("nickname") @ExcludeMissing fun _nickname(): JsonField = nickname + + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + @JsonProperty("is_for_benefit_of") + @ExcludeMissing + fun _isForBenefitOf(): JsonField = isForBenefitOf @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): FinancialAccountCreateBody = apply { + if (!validated) { + nickname() + type() + accountToken() + isForBenefitOf() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -87,10 +126,10 @@ constructor( class Builder { - private var nickname: String? = null - private var type: Type? = null - private var accountToken: String? = null - private var isForBenefitOf: Boolean? = null + private var nickname: JsonField? = null + private var type: JsonField? = null + private var accountToken: JsonField = JsonMissing.of() + private var isForBenefitOf: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(financialAccountCreateBody: FinancialAccountCreateBody) = apply { @@ -102,17 +141,26 @@ constructor( financialAccountCreateBody.additionalProperties.toMutableMap() } - fun nickname(nickname: String) = apply { this.nickname = nickname } + fun nickname(nickname: String) = nickname(JsonField.of(nickname)) - fun type(type: Type) = apply { this.type = type } + fun nickname(nickname: JsonField) = apply { this.nickname = nickname } - fun accountToken(accountToken: String?) = apply { this.accountToken = accountToken } + fun type(type: Type) = type(JsonField.of(type)) - fun isForBenefitOf(isForBenefitOf: Boolean?) = apply { - this.isForBenefitOf = isForBenefitOf + fun type(type: JsonField) = apply { this.type = type } + + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken } - fun isForBenefitOf(isForBenefitOf: Boolean) = isForBenefitOf(isForBenefitOf as Boolean?) + fun isForBenefitOf(isForBenefitOf: Boolean) = + isForBenefitOf(JsonField.of(isForBenefitOf)) + + fun isForBenefitOf(isForBenefitOf: JsonField) = apply { + this.isForBenefitOf = isForBenefitOf + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -187,13 +235,42 @@ constructor( fun nickname(nickname: String) = apply { body.nickname(nickname) } + fun nickname(nickname: JsonField) = apply { body.nickname(nickname) } + fun type(type: Type) = apply { body.type(type) } - fun accountToken(accountToken: String?) = apply { body.accountToken(accountToken) } + fun type(type: JsonField) = apply { body.type(type) } + + fun accountToken(accountToken: String) = apply { body.accountToken(accountToken) } + + fun accountToken(accountToken: JsonField) = apply { + body.accountToken(accountToken) + } + + fun isForBenefitOf(isForBenefitOf: Boolean) = apply { body.isForBenefitOf(isForBenefitOf) } + + fun isForBenefitOf(isForBenefitOf: JsonField) = apply { + body.isForBenefitOf(isForBenefitOf) + } + + 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 isForBenefitOf(isForBenefitOf: Boolean?) = apply { body.isForBenefitOf(isForBenefitOf) } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun isForBenefitOf(isForBenefitOf: Boolean) = isForBenefitOf(isForBenefitOf as Boolean?) + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -293,25 +370,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): FinancialAccountCreateParams = FinancialAccountCreateParams( idempotencyKey, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreditConfig.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreditConfig.kt index a2864285..58dc8434 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreditConfig.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreditConfig.kt @@ -70,31 +70,37 @@ private constructor( fun tier(): String? = tier.getNullable("tier") /** Globally unique identifier for the account */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** Reason for the financial account being marked as Charged Off */ - @JsonProperty("charged_off_reason") @ExcludeMissing fun _chargedOffReason() = chargedOffReason + @JsonProperty("charged_off_reason") + @ExcludeMissing + fun _chargedOffReason(): JsonField = chargedOffReason - @JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit() = creditLimit + @JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit(): JsonField = creditLimit /** Globally unique identifier for the credit product */ @JsonProperty("credit_product_token") @ExcludeMissing - fun _creditProductToken() = creditProductToken + fun _creditProductToken(): JsonField = creditProductToken @JsonProperty("external_bank_account_token") @ExcludeMissing - fun _externalBankAccountToken() = externalBankAccountToken + fun _externalBankAccountToken(): JsonField = externalBankAccountToken /** State of the financial account */ @JsonProperty("financial_account_state") @ExcludeMissing - fun _financialAccountState() = financialAccountState + fun _financialAccountState(): JsonField = financialAccountState - @JsonProperty("is_spend_blocked") @ExcludeMissing fun _isSpendBlocked() = isSpendBlocked + @JsonProperty("is_spend_blocked") + @ExcludeMissing + fun _isSpendBlocked(): JsonField = isSpendBlocked /** Tier assigned to the financial account */ - @JsonProperty("tier") @ExcludeMissing fun _tier() = tier + @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField = tier @JsonAnyGetter @ExcludeMissing @@ -125,14 +131,14 @@ private constructor( class Builder { - private var accountToken: JsonField = JsonMissing.of() - private var chargedOffReason: JsonField = JsonMissing.of() - private var creditLimit: JsonField = JsonMissing.of() - private var creditProductToken: JsonField = JsonMissing.of() - private var externalBankAccountToken: JsonField = JsonMissing.of() - private var financialAccountState: JsonField = JsonMissing.of() - private var isSpendBlocked: JsonField = JsonMissing.of() - private var tier: JsonField = JsonMissing.of() + private var accountToken: JsonField? = null + private var chargedOffReason: JsonField? = null + private var creditLimit: JsonField? = null + private var creditProductToken: JsonField? = null + private var externalBankAccountToken: JsonField? = null + private var financialAccountState: JsonField? = null + private var isSpendBlocked: JsonField? = null + private var tier: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(financialAccountCreditConfig: FinancialAccountCreditConfig) = apply { @@ -156,29 +162,31 @@ private constructor( } /** Reason for the financial account being marked as Charged Off */ - fun chargedOffReason(chargedOffReason: ChargedOffReason) = - chargedOffReason(JsonField.of(chargedOffReason)) + fun chargedOffReason(chargedOffReason: ChargedOffReason?) = + chargedOffReason(JsonField.ofNullable(chargedOffReason)) /** Reason for the financial account being marked as Charged Off */ fun chargedOffReason(chargedOffReason: JsonField) = apply { this.chargedOffReason = chargedOffReason } - fun creditLimit(creditLimit: Long) = creditLimit(JsonField.of(creditLimit)) + fun creditLimit(creditLimit: Long?) = creditLimit(JsonField.ofNullable(creditLimit)) + + fun creditLimit(creditLimit: Long) = creditLimit(creditLimit as Long?) fun creditLimit(creditLimit: JsonField) = apply { this.creditLimit = creditLimit } /** Globally unique identifier for the credit product */ - fun creditProductToken(creditProductToken: String) = - creditProductToken(JsonField.of(creditProductToken)) + fun creditProductToken(creditProductToken: String?) = + creditProductToken(JsonField.ofNullable(creditProductToken)) /** Globally unique identifier for the credit product */ fun creditProductToken(creditProductToken: JsonField) = apply { this.creditProductToken = creditProductToken } - fun externalBankAccountToken(externalBankAccountToken: String) = - externalBankAccountToken(JsonField.of(externalBankAccountToken)) + fun externalBankAccountToken(externalBankAccountToken: String?) = + externalBankAccountToken(JsonField.ofNullable(externalBankAccountToken)) fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { this.externalBankAccountToken = externalBankAccountToken @@ -200,7 +208,7 @@ private constructor( } /** Tier assigned to the financial account */ - fun tier(tier: String) = tier(JsonField.of(tier)) + fun tier(tier: String?) = tier(JsonField.ofNullable(tier)) /** Tier assigned to the financial account */ fun tier(tier: JsonField) = apply { this.tier = tier } @@ -226,14 +234,20 @@ private constructor( fun build(): FinancialAccountCreditConfig = FinancialAccountCreditConfig( - accountToken, - chargedOffReason, - creditLimit, - creditProductToken, - externalBankAccountToken, - financialAccountState, - isSpendBlocked, - tier, + checkNotNull(accountToken) { "`accountToken` is required but was not set" }, + checkNotNull(chargedOffReason) { "`chargedOffReason` is required but was not set" }, + checkNotNull(creditLimit) { "`creditLimit` is required but was not set" }, + checkNotNull(creditProductToken) { + "`creditProductToken` is required but was not set" + }, + checkNotNull(externalBankAccountToken) { + "`externalBankAccountToken` is required but was not set" + }, + checkNotNull(financialAccountState) { + "`financialAccountState` is required but was not set" + }, + checkNotNull(isSpendBlocked) { "`isSpendBlocked` is required but was not set" }, + checkNotNull(tier) { "`tier` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreditConfigurationUpdateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreditConfigurationUpdateParams.kt index db12377c..ef235848 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreditConfigurationUpdateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreditConfigurationUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -36,12 +38,22 @@ constructor( /** Tier to assign to a financial account */ fun tier(): String? = body.tier() - fun _additionalHeaders(): Headers = additionalHeaders + fun _creditLimit(): JsonField = body._creditLimit() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Globally unique identifier for the credit product */ + fun _creditProductToken(): JsonField = body._creditProductToken() + + fun _externalBankAccountToken(): JsonField = body._externalBankAccountToken() + + /** Tier to assign to a financial account */ + fun _tier(): JsonField = body._tier() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): FinancialAccountCreditConfigurationUpdateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -59,29 +71,65 @@ constructor( class FinancialAccountCreditConfigurationUpdateBody @JsonCreator internal constructor( - @JsonProperty("credit_limit") private val creditLimit: Long?, - @JsonProperty("credit_product_token") private val creditProductToken: String?, - @JsonProperty("external_bank_account_token") private val externalBankAccountToken: String?, - @JsonProperty("tier") private val tier: String?, + @JsonProperty("credit_limit") + @ExcludeMissing + private val creditLimit: JsonField = JsonMissing.of(), + @JsonProperty("credit_product_token") + @ExcludeMissing + private val creditProductToken: JsonField = JsonMissing.of(), + @JsonProperty("external_bank_account_token") + @ExcludeMissing + private val externalBankAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("tier") + @ExcludeMissing + private val tier: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("credit_limit") fun creditLimit(): Long? = creditLimit + fun creditLimit(): Long? = creditLimit.getNullable("credit_limit") + + /** Globally unique identifier for the credit product */ + fun creditProductToken(): String? = creditProductToken.getNullable("credit_product_token") + + fun externalBankAccountToken(): String? = + externalBankAccountToken.getNullable("external_bank_account_token") + + /** Tier to assign to a financial account */ + fun tier(): String? = tier.getNullable("tier") + + @JsonProperty("credit_limit") + @ExcludeMissing + fun _creditLimit(): JsonField = creditLimit /** Globally unique identifier for the credit product */ - @JsonProperty("credit_product_token") fun creditProductToken(): String? = creditProductToken + @JsonProperty("credit_product_token") + @ExcludeMissing + fun _creditProductToken(): JsonField = creditProductToken @JsonProperty("external_bank_account_token") - fun externalBankAccountToken(): String? = externalBankAccountToken + @ExcludeMissing + fun _externalBankAccountToken(): JsonField = externalBankAccountToken /** Tier to assign to a financial account */ - @JsonProperty("tier") fun tier(): String? = tier + @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField = tier @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): FinancialAccountCreditConfigurationUpdateBody = apply { + if (!validated) { + creditLimit() + creditProductToken() + externalBankAccountToken() + tier() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -91,10 +139,10 @@ constructor( class Builder { - private var creditLimit: Long? = null - private var creditProductToken: String? = null - private var externalBankAccountToken: String? = null - private var tier: String? = null + private var creditLimit: JsonField = JsonMissing.of() + private var creditProductToken: JsonField = JsonMissing.of() + private var externalBankAccountToken: JsonField = JsonMissing.of() + private var tier: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -112,21 +160,31 @@ constructor( .toMutableMap() } - fun creditLimit(creditLimit: Long?) = apply { this.creditLimit = creditLimit } + fun creditLimit(creditLimit: Long) = creditLimit(JsonField.of(creditLimit)) - fun creditLimit(creditLimit: Long) = creditLimit(creditLimit as Long?) + fun creditLimit(creditLimit: JsonField) = apply { this.creditLimit = creditLimit } + + /** Globally unique identifier for the credit product */ + fun creditProductToken(creditProductToken: String) = + creditProductToken(JsonField.of(creditProductToken)) /** Globally unique identifier for the credit product */ - fun creditProductToken(creditProductToken: String?) = apply { + fun creditProductToken(creditProductToken: JsonField) = apply { this.creditProductToken = creditProductToken } - fun externalBankAccountToken(externalBankAccountToken: String?) = apply { + fun externalBankAccountToken(externalBankAccountToken: String) = + externalBankAccountToken(JsonField.of(externalBankAccountToken)) + + fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { this.externalBankAccountToken = externalBankAccountToken } /** Tier to assign to a financial account */ - fun tier(tier: String?) = apply { this.tier = tier } + fun tier(tier: String) = tier(JsonField.of(tier)) + + /** Tier to assign to a financial account */ + fun tier(tier: JsonField) = apply { this.tier = tier } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -208,21 +266,52 @@ constructor( this.financialAccountToken = financialAccountToken } - fun creditLimit(creditLimit: Long?) = apply { body.creditLimit(creditLimit) } + fun creditLimit(creditLimit: Long) = apply { body.creditLimit(creditLimit) } - fun creditLimit(creditLimit: Long) = creditLimit(creditLimit as Long?) + fun creditLimit(creditLimit: JsonField) = apply { body.creditLimit(creditLimit) } + + /** Globally unique identifier for the credit product */ + fun creditProductToken(creditProductToken: String) = apply { + body.creditProductToken(creditProductToken) + } /** Globally unique identifier for the credit product */ - fun creditProductToken(creditProductToken: String?) = apply { + fun creditProductToken(creditProductToken: JsonField) = apply { body.creditProductToken(creditProductToken) } - fun externalBankAccountToken(externalBankAccountToken: String?) = apply { + fun externalBankAccountToken(externalBankAccountToken: String) = apply { + body.externalBankAccountToken(externalBankAccountToken) + } + + fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { body.externalBankAccountToken(externalBankAccountToken) } /** Tier to assign to a financial account */ - fun tier(tier: String?) = apply { body.tier(tier) } + fun tier(tier: String) = apply { body.tier(tier) } + + /** Tier to assign to a financial account */ + fun tier(tier: JsonField) = apply { body.tier(tier) } + + 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() @@ -322,25 +411,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): FinancialAccountCreditConfigurationUpdateParams = FinancialAccountCreditConfigurationUpdateParams( checkNotNull(financialAccountToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountUpdateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountUpdateParams.kt index 1a78c471..28632a3f 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountUpdateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -28,12 +30,14 @@ constructor( fun nickname(): String? = body.nickname() + fun _nickname(): JsonField = body._nickname() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): FinancialAccountUpdateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -51,17 +55,30 @@ constructor( class FinancialAccountUpdateBody @JsonCreator internal constructor( - @JsonProperty("nickname") private val nickname: String?, + @JsonProperty("nickname") + @ExcludeMissing + private val nickname: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("nickname") fun nickname(): String? = nickname + fun nickname(): String? = nickname.getNullable("nickname") + + @JsonProperty("nickname") @ExcludeMissing fun _nickname(): JsonField = nickname @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): FinancialAccountUpdateBody = apply { + if (!validated) { + nickname() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -71,7 +88,7 @@ constructor( class Builder { - private var nickname: String? = null + private var nickname: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(financialAccountUpdateBody: FinancialAccountUpdateBody) = apply { @@ -80,7 +97,9 @@ constructor( financialAccountUpdateBody.additionalProperties.toMutableMap() } - fun nickname(nickname: String?) = apply { this.nickname = nickname } + fun nickname(nickname: String) = nickname(JsonField.of(nickname)) + + fun nickname(nickname: JsonField) = apply { this.nickname = nickname } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -149,7 +168,28 @@ constructor( this.financialAccountToken = financialAccountToken } - fun nickname(nickname: String?) = apply { body.nickname(nickname) } + fun nickname(nickname: String) = apply { body.nickname(nickname) } + + fun nickname(nickname: JsonField) = apply { body.nickname(nickname) } + + 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() @@ -249,25 +289,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): FinancialAccountUpdateParams = FinancialAccountUpdateParams( checkNotNull(financialAccountToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialTransaction.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialTransaction.kt index d224d0d3..14be94bc 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialTransaction.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialTransaction.kt @@ -116,7 +116,7 @@ private constructor( fun updated(): OffsetDateTime = updated.getRequired("updated") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * Status types: @@ -124,41 +124,45 @@ private constructor( * - `ACH` - Transaction over ACH. * - `TRANSFER` - Internal transfer of funds between financial accounts in your program. */ - @JsonProperty("category") @ExcludeMissing fun _category() = category + @JsonProperty("category") @ExcludeMissing fun _category(): JsonField = category /** Date and time when the financial transaction first occurred. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** 3-digit alphabetic ISO 4217 code for the settling currency of the transaction. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * A string that provides a description of the financial transaction; may be useful to display * to users. */ - @JsonProperty("descriptor") @ExcludeMissing fun _descriptor() = descriptor + @JsonProperty("descriptor") @ExcludeMissing fun _descriptor(): JsonField = descriptor /** A list of all financial events that have modified this financial transaction. */ - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events /** * Pending amount of the transaction in the currency's smallest unit (e.g., cents), including * any acquirer fees. The value of this field will go to zero over time once the financial * transaction is settled. */ - @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount /** * APPROVED transactions were successful while DECLINED transactions were declined by user, * Lithic, or the network. */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** * Amount of the transaction that has been settled in the currency's smallest unit (e.g., * cents), including any acquirer fees. This may change over time. */ - @JsonProperty("settled_amount") @ExcludeMissing fun _settledAmount() = settledAmount + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount /** * Status types: @@ -169,10 +173,10 @@ private constructor( * - `SETTLED` - The transaction is completed. * - `VOIDED` - The transaction was voided. Card transaction only. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** Date and time when the financial transaction was last updated. UTC time zone. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated @JsonAnyGetter @ExcludeMissing @@ -206,17 +210,17 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var category: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var descriptor: JsonField = JsonMissing.of() - private var events: JsonField> = JsonMissing.of() - private var pendingAmount: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var settledAmount: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var descriptor: JsonField? = null + private var events: JsonField>? = null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(financialTransaction: FinancialTransaction) = apply { @@ -225,7 +229,7 @@ private constructor( created = financialTransaction.created currency = financialTransaction.currency descriptor = financialTransaction.descriptor - events = financialTransaction.events + events = financialTransaction.events.map { it.toMutableList() } pendingAmount = financialTransaction.pendingAmount result = financialTransaction.result settledAmount = financialTransaction.settledAmount @@ -284,7 +288,21 @@ private constructor( fun events(events: List) = events(JsonField.of(events)) /** A list of all financial events that have modified this financial transaction. */ - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** A list of all financial events that have modified this financial transaction. */ + fun addEvent(event: FinancialEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(event) + } + } /** * Pending amount of the transaction in the currency's smallest unit (e.g., cents), @@ -379,17 +397,18 @@ private constructor( fun build(): FinancialTransaction = FinancialTransaction( - token, - category, - created, - currency, - descriptor, - events.map { it.toImmutable() }, - pendingAmount, - result, - settledAmount, - status, - updated, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(category) { "`category` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(descriptor) { "`descriptor` is required but was not set" }, + checkNotNull(events) { "`events` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(pendingAmount) { "`pendingAmount` is required but was not set" }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(settledAmount) { "`settledAmount` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -501,24 +520,24 @@ private constructor( fun type(): FinancialEventType? = type.getNullable("type") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * Amount of the financial event that has been settled in the currency's smallest unit * (e.g., cents). */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** Date and time when the financial event occurred. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** * APPROVED financial events were successful while DECLINED financial events were declined * by user, Lithic, or the network. */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Kyb.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Kyb.kt index 8d90639b..609981f8 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Kyb.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Kyb.kt @@ -130,7 +130,7 @@ private constructor( */ @JsonProperty("beneficial_owner_entities") @ExcludeMissing - fun _beneficialOwnerEntities() = beneficialOwnerEntities + fun _beneficialOwnerEntities(): JsonField> = beneficialOwnerEntities /** * List of all direct and indirect individuals with >25% ownership in the company. If no entity @@ -143,10 +143,12 @@ private constructor( */ @JsonProperty("beneficial_owner_individuals") @ExcludeMissing - fun _beneficialOwnerIndividuals() = beneficialOwnerIndividuals + fun _beneficialOwnerIndividuals(): JsonField> = beneficialOwnerIndividuals /** Information for business for which the account is being opened and KYB is being run. */ - @JsonProperty("business_entity") @ExcludeMissing fun _businessEntity() = businessEntity + @JsonProperty("business_entity") + @ExcludeMissing + fun _businessEntity(): JsonField = businessEntity /** * An individual with significant responsibility for managing the legal entity (e.g., a Chief @@ -157,23 +159,29 @@ private constructor( * [FinCEN requirements](https://www.fincen.gov/sites/default/files/shared/CDD_Rev6.7_Sept_2017_Certificate.pdf) * (Section II) for more background. */ - @JsonProperty("control_person") @ExcludeMissing fun _controlPerson() = controlPerson + @JsonProperty("control_person") + @ExcludeMissing + fun _controlPerson(): JsonField = controlPerson /** Short description of the company's line of business (i.e., what does the company do?). */ - @JsonProperty("nature_of_business") @ExcludeMissing fun _natureOfBusiness() = natureOfBusiness + @JsonProperty("nature_of_business") + @ExcludeMissing + fun _natureOfBusiness(): JsonField = natureOfBusiness /** * An RFC 3339 timestamp indicating when the account holder accepted the applicable legal * agreements (e.g., cardholder terms) as agreed upon during API customer's implementation with * Lithic. */ - @JsonProperty("tos_timestamp") @ExcludeMissing fun _tosTimestamp() = tosTimestamp + @JsonProperty("tos_timestamp") + @ExcludeMissing + fun _tosTimestamp(): JsonField = tosTimestamp /** Specifies the type of KYB workflow to run. */ - @JsonProperty("workflow") @ExcludeMissing fun _workflow() = workflow + @JsonProperty("workflow") @ExcludeMissing fun _workflow(): JsonField = workflow /** A user provided id that can be used to link an account holder with an external system */ - @JsonProperty("external_id") @ExcludeMissing fun _externalId() = externalId + @JsonProperty("external_id") @ExcludeMissing fun _externalId(): JsonField = externalId /** * An RFC 3339 timestamp indicating when precomputed KYC was completed on the business with a @@ -183,10 +191,10 @@ private constructor( */ @JsonProperty("kyb_passed_timestamp") @ExcludeMissing - fun _kybPassedTimestamp() = kybPassedTimestamp + fun _kybPassedTimestamp(): JsonField = kybPassedTimestamp /** Company website URL. */ - @JsonProperty("website_url") @ExcludeMissing fun _websiteUrl() = websiteUrl + @JsonProperty("website_url") @ExcludeMissing fun _websiteUrl(): JsonField = websiteUrl @JsonAnyGetter @ExcludeMissing @@ -219,21 +227,21 @@ private constructor( class Builder { - private var beneficialOwnerEntities: JsonField> = JsonMissing.of() - private var beneficialOwnerIndividuals: JsonField> = JsonMissing.of() - private var businessEntity: JsonField = JsonMissing.of() - private var controlPerson: JsonField = JsonMissing.of() - private var natureOfBusiness: JsonField = JsonMissing.of() - private var tosTimestamp: JsonField = JsonMissing.of() - private var workflow: JsonField = JsonMissing.of() + private var beneficialOwnerEntities: JsonField>? = null + private var beneficialOwnerIndividuals: JsonField>? = null + private var businessEntity: JsonField? = null + private var controlPerson: JsonField? = null + private var natureOfBusiness: JsonField? = null + private var tosTimestamp: JsonField? = null + private var workflow: JsonField? = null private var externalId: JsonField = JsonMissing.of() private var kybPassedTimestamp: JsonField = JsonMissing.of() private var websiteUrl: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(kyb: Kyb) = apply { - beneficialOwnerEntities = kyb.beneficialOwnerEntities - beneficialOwnerIndividuals = kyb.beneficialOwnerIndividuals + beneficialOwnerEntities = kyb.beneficialOwnerEntities.map { it.toMutableList() } + beneficialOwnerIndividuals = kyb.beneficialOwnerIndividuals.map { it.toMutableList() } businessEntity = kyb.businessEntity controlPerson = kyb.controlPerson natureOfBusiness = kyb.natureOfBusiness @@ -268,9 +276,29 @@ private constructor( */ fun beneficialOwnerEntities(beneficialOwnerEntities: JsonField>) = apply { - this.beneficialOwnerEntities = beneficialOwnerEntities + this.beneficialOwnerEntities = beneficialOwnerEntities.map { it.toMutableList() } } + /** + * List of all entities with >25% ownership in the company. If no entity or individual + * owns >25% of the company, and the largest shareholder is an entity, please identify them + * in this field. See + * [FinCEN requirements](https://www.fincen.gov/sites/default/files/shared/CDD_Rev6.7_Sept_2017_Certificate.pdf) + * (Section I) for more background. If no business owner is an entity, pass in an empty + * list. However, either this parameter or `beneficial_owner_individuals` must be populated. + * on entities that should be included. + */ + fun addBeneficialOwnerEntity(beneficialOwnerEntity: BusinessEntity) = apply { + beneficialOwnerEntities = + (beneficialOwnerEntities ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(beneficialOwnerEntity) + } + } + /** * List of all direct and indirect individuals with >25% ownership in the company. If no * entity or individual owns >25% of the company, and the largest shareholder is an @@ -294,9 +322,30 @@ private constructor( */ fun beneficialOwnerIndividuals(beneficialOwnerIndividuals: JsonField>) = apply { - this.beneficialOwnerIndividuals = beneficialOwnerIndividuals + this.beneficialOwnerIndividuals = + beneficialOwnerIndividuals.map { it.toMutableList() } } + /** + * List of all direct and indirect individuals with >25% ownership in the company. If no + * entity or individual owns >25% of the company, and the largest shareholder is an + * individual, please identify them in this field. See + * [FinCEN requirements](https://www.fincen.gov/sites/default/files/shared/CDD_Rev6.7_Sept_2017_Certificate.pdf) + * (Section I) for more background on individuals that should be included. If no individual + * is an entity, pass in an empty list. However, either this parameter or + * `beneficial_owner_entities` must be populated. + */ + fun addBeneficialOwnerIndividual(beneficialOwnerIndividual: KybIndividual) = apply { + beneficialOwnerIndividuals = + (beneficialOwnerIndividuals ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(beneficialOwnerIndividual) + } + } + /** Information for business for which the account is being opened and KYB is being run. */ fun businessEntity(businessEntity: BusinessEntity) = businessEntity(JsonField.of(businessEntity)) @@ -419,13 +468,19 @@ private constructor( fun build(): Kyb = Kyb( - beneficialOwnerEntities.map { it.toImmutable() }, - beneficialOwnerIndividuals.map { it.toImmutable() }, - businessEntity, - controlPerson, - natureOfBusiness, - tosTimestamp, - workflow, + checkNotNull(beneficialOwnerEntities) { + "`beneficialOwnerEntities` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(beneficialOwnerIndividuals) { + "`beneficialOwnerIndividuals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(businessEntity) { "`businessEntity` is required but was not set" }, + checkNotNull(controlPerson) { "`controlPerson` is required but was not set" }, + checkNotNull(natureOfBusiness) { "`natureOfBusiness` is required but was not set" }, + checkNotNull(tosTimestamp) { "`tosTimestamp` is required but was not set" }, + checkNotNull(workflow) { "`workflow` is required but was not set" }, externalId, kybPassedTimestamp, websiteUrl, @@ -490,30 +545,38 @@ private constructor( * Business's physical address - PO boxes, UPS drops, and FedEx drops are not acceptable; * APO/FPO are acceptable. */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") @ExcludeMissing fun _address(): JsonField
= address /** * Government-issued identification number. US Federal Employer Identification Numbers (EIN) * are currently supported, entered as full nine-digits, with or without hyphens. */ - @JsonProperty("government_id") @ExcludeMissing fun _governmentId() = governmentId + @JsonProperty("government_id") + @ExcludeMissing + fun _governmentId(): JsonField = governmentId /** Legal (formal) business name. */ @JsonProperty("legal_business_name") @ExcludeMissing - fun _legalBusinessName() = legalBusinessName + fun _legalBusinessName(): JsonField = legalBusinessName /** One or more of the business's phone number(s), entered as a list in E.164 format. */ - @JsonProperty("phone_numbers") @ExcludeMissing fun _phoneNumbers() = phoneNumbers + @JsonProperty("phone_numbers") + @ExcludeMissing + fun _phoneNumbers(): JsonField> = phoneNumbers /** * Any name that the business operates under that is not its legal business name (if * applicable). */ - @JsonProperty("dba_business_name") @ExcludeMissing fun _dbaBusinessName() = dbaBusinessName + @JsonProperty("dba_business_name") + @ExcludeMissing + fun _dbaBusinessName(): JsonField = dbaBusinessName /** Parent company name (if applicable). */ - @JsonProperty("parent_company") @ExcludeMissing fun _parentCompany() = parentCompany + @JsonProperty("parent_company") + @ExcludeMissing + fun _parentCompany(): JsonField = parentCompany @JsonAnyGetter @ExcludeMissing @@ -542,10 +605,10 @@ private constructor( class Builder { - private var address: JsonField
= JsonMissing.of() - private var governmentId: JsonField = JsonMissing.of() - private var legalBusinessName: JsonField = JsonMissing.of() - private var phoneNumbers: JsonField> = JsonMissing.of() + private var address: JsonField
? = null + private var governmentId: JsonField? = null + private var legalBusinessName: JsonField? = null + private var phoneNumbers: JsonField>? = null private var dbaBusinessName: JsonField = JsonMissing.of() private var parentCompany: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -554,7 +617,7 @@ private constructor( address = businessEntity.address governmentId = businessEntity.governmentId legalBusinessName = businessEntity.legalBusinessName - phoneNumbers = businessEntity.phoneNumbers + phoneNumbers = businessEntity.phoneNumbers.map { it.toMutableList() } dbaBusinessName = businessEntity.dbaBusinessName parentCompany = businessEntity.parentCompany additionalProperties = businessEntity.additionalProperties.toMutableMap() @@ -600,7 +663,19 @@ private constructor( /** One or more of the business's phone number(s), entered as a list in E.164 format. */ fun phoneNumbers(phoneNumbers: JsonField>) = apply { - this.phoneNumbers = phoneNumbers + this.phoneNumbers = phoneNumbers.map { it.toMutableList() } + } + + /** One or more of the business's phone number(s), entered as a list in E.164 format. */ + fun addPhoneNumber(phoneNumber: String) = apply { + phoneNumbers = + (phoneNumbers ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(phoneNumber) + } } /** @@ -647,10 +722,13 @@ private constructor( fun build(): BusinessEntity = BusinessEntity( - address, - governmentId, - legalBusinessName, - phoneNumbers.map { it.toImmutable() }, + checkNotNull(address) { "`address` is required but was not set" }, + checkNotNull(governmentId) { "`governmentId` is required but was not set" }, + checkNotNull(legalBusinessName) { + "`legalBusinessName` is required but was not set" + }, + checkNotNull(phoneNumbers) { "`phoneNumbers` is required but was not set" } + .map { it.toImmutable() }, dbaBusinessName, parentCompany, additionalProperties.toImmutable(), @@ -739,19 +817,19 @@ private constructor( * Individual's current address - PO boxes, UPS drops, and FedEx drops are not acceptable; * APO/FPO are acceptable. Only USA addresses are currently supported. */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") @ExcludeMissing fun _address(): JsonField
= address /** Individual's date of birth, as an RFC 3339 date. */ - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** * Individual's email address. If utilizing Lithic for chargeback processing, this customer * email address may be used to communicate dispute status and resolution. */ - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email /** Individual's first name, as it appears on government-issued identity documents. */ - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** * Government-issued identification number (required for identity verification and @@ -759,13 +837,17 @@ private constructor( * Taxpayer Identification Numbers (ITIN) are currently supported, entered as full * nine-digits, with or without hyphens */ - @JsonProperty("government_id") @ExcludeMissing fun _governmentId() = governmentId + @JsonProperty("government_id") + @ExcludeMissing + fun _governmentId(): JsonField = governmentId /** Individual's last name, as it appears on government-issued identity documents. */ - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName /** Individual's phone number, entered in E.164 format. */ - @JsonProperty("phone_number") @ExcludeMissing fun _phoneNumber() = phoneNumber + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber @JsonAnyGetter @ExcludeMissing @@ -795,12 +877,12 @@ private constructor( class Builder { - private var address: JsonField
= JsonMissing.of() - private var dob: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var firstName: JsonField = JsonMissing.of() - private var governmentId: JsonField = JsonMissing.of() - private var lastName: JsonField = JsonMissing.of() + private var address: JsonField
? = null + private var dob: JsonField? = null + private var email: JsonField? = null + private var firstName: JsonField? = null + private var governmentId: JsonField? = null + private var lastName: JsonField? = null private var phoneNumber: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -904,12 +986,12 @@ private constructor( fun build(): KybIndividual = KybIndividual( - address, - dob, - email, - firstName, - governmentId, - lastName, + checkNotNull(address) { "`address` is required but was not set" }, + checkNotNull(dob) { "`dob` is required but was not set" }, + checkNotNull(email) { "`email` is required but was not set" }, + checkNotNull(firstName) { "`firstName` is required but was not set" }, + checkNotNull(governmentId) { "`governmentId` is required but was not set" }, + checkNotNull(lastName) { "`lastName` is required but was not set" }, phoneNumber, additionalProperties.toImmutable(), ) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Kyc.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Kyc.kt index 18766e82..4c52f83c 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Kyc.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Kyc.kt @@ -64,20 +64,24 @@ private constructor( fun kycPassedTimestamp(): String? = kycPassedTimestamp.getNullable("kyc_passed_timestamp") /** Information on individual for whom the account is being opened and KYC is being run. */ - @JsonProperty("individual") @ExcludeMissing fun _individual() = individual + @JsonProperty("individual") + @ExcludeMissing + fun _individual(): JsonField = individual /** * An RFC 3339 timestamp indicating when the account holder accepted the applicable legal * agreements (e.g., cardholder terms) as agreed upon during API customer's implementation with * Lithic. */ - @JsonProperty("tos_timestamp") @ExcludeMissing fun _tosTimestamp() = tosTimestamp + @JsonProperty("tos_timestamp") + @ExcludeMissing + fun _tosTimestamp(): JsonField = tosTimestamp /** Specifies the type of KYC workflow to run. */ - @JsonProperty("workflow") @ExcludeMissing fun _workflow() = workflow + @JsonProperty("workflow") @ExcludeMissing fun _workflow(): JsonField = workflow /** A user provided id that can be used to link an account holder with an external system */ - @JsonProperty("external_id") @ExcludeMissing fun _externalId() = externalId + @JsonProperty("external_id") @ExcludeMissing fun _externalId(): JsonField = externalId /** * An RFC 3339 timestamp indicating when precomputed KYC was completed on the individual with a @@ -87,7 +91,7 @@ private constructor( */ @JsonProperty("kyc_passed_timestamp") @ExcludeMissing - fun _kycPassedTimestamp() = kycPassedTimestamp + fun _kycPassedTimestamp(): JsonField = kycPassedTimestamp @JsonAnyGetter @ExcludeMissing @@ -115,9 +119,9 @@ private constructor( class Builder { - private var individual: JsonField = JsonMissing.of() - private var tosTimestamp: JsonField = JsonMissing.of() - private var workflow: JsonField = JsonMissing.of() + private var individual: JsonField? = null + private var tosTimestamp: JsonField? = null + private var workflow: JsonField? = null private var externalId: JsonField = JsonMissing.of() private var kycPassedTimestamp: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -205,9 +209,9 @@ private constructor( fun build(): Kyc = Kyc( - individual, - tosTimestamp, - workflow, + checkNotNull(individual) { "`individual` is required but was not set" }, + checkNotNull(tosTimestamp) { "`tosTimestamp` is required but was not set" }, + checkNotNull(workflow) { "`workflow` is required but was not set" }, externalId, kycPassedTimestamp, additionalProperties.toImmutable(), @@ -278,19 +282,19 @@ private constructor( * Individual's current address - PO boxes, UPS drops, and FedEx drops are not acceptable; * APO/FPO are acceptable. Only USA addresses are currently supported. */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") @ExcludeMissing fun _address(): JsonField
= address /** Individual's date of birth, as an RFC 3339 date. */ - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** * Individual's email address. If utilizing Lithic for chargeback processing, this customer * email address may be used to communicate dispute status and resolution. */ - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email /** Individual's first name, as it appears on government-issued identity documents. */ - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** * Government-issued identification number (required for identity verification and @@ -298,13 +302,17 @@ private constructor( * Taxpayer Identification Numbers (ITIN) are currently supported, entered as full * nine-digits, with or without hyphens */ - @JsonProperty("government_id") @ExcludeMissing fun _governmentId() = governmentId + @JsonProperty("government_id") + @ExcludeMissing + fun _governmentId(): JsonField = governmentId /** Individual's last name, as it appears on government-issued identity documents. */ - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName /** Individual's phone number, entered in E.164 format. */ - @JsonProperty("phone_number") @ExcludeMissing fun _phoneNumber() = phoneNumber + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber @JsonAnyGetter @ExcludeMissing @@ -334,13 +342,13 @@ private constructor( class Builder { - private var address: JsonField
= JsonMissing.of() - private var dob: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var firstName: JsonField = JsonMissing.of() - private var governmentId: JsonField = JsonMissing.of() - private var lastName: JsonField = JsonMissing.of() - private var phoneNumber: JsonField = JsonMissing.of() + private var address: JsonField
? = null + private var dob: JsonField? = null + private var email: JsonField? = null + private var firstName: JsonField? = null + private var governmentId: JsonField? = null + private var lastName: JsonField? = null + private var phoneNumber: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(individual: Individual) = apply { @@ -443,13 +451,13 @@ private constructor( fun build(): Individual = Individual( - address, - dob, - email, - firstName, - governmentId, - lastName, - phoneNumber, + checkNotNull(address) { "`address` is required but was not set" }, + checkNotNull(dob) { "`dob` is required but was not set" }, + checkNotNull(email) { "`email` is required but was not set" }, + checkNotNull(firstName) { "`firstName` is required but was not set" }, + checkNotNull(governmentId) { "`governmentId` is required but was not set" }, + checkNotNull(lastName) { "`lastName` is required but was not set" }, + checkNotNull(phoneNumber) { "`phoneNumber` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/KycExempt.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/KycExempt.kt index 101f033e..e6920cf4 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/KycExempt.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/KycExempt.kt @@ -87,25 +87,29 @@ private constructor( * KYC Exempt user's current address - PO boxes, UPS drops, and FedEx drops are not acceptable; * APO/FPO are acceptable. */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") @ExcludeMissing fun _address(): JsonField
= address /** The KYC Exempt user's email */ - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email /** The KYC Exempt user's first name */ - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** Specifies the type of KYC Exempt user */ - @JsonProperty("kyc_exemption_type") @ExcludeMissing fun _kycExemptionType() = kycExemptionType + @JsonProperty("kyc_exemption_type") + @ExcludeMissing + fun _kycExemptionType(): JsonField = kycExemptionType /** The KYC Exempt user's last name */ - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName /** The KYC Exempt user's phone number */ - @JsonProperty("phone_number") @ExcludeMissing fun _phoneNumber() = phoneNumber + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber /** Specifies the workflow type. This must be 'KYC_EXEMPT' */ - @JsonProperty("workflow") @ExcludeMissing fun _workflow() = workflow + @JsonProperty("workflow") @ExcludeMissing fun _workflow(): JsonField = workflow /** * Only applicable for customers using the KYC-Exempt workflow to enroll authorized users of @@ -114,10 +118,10 @@ private constructor( */ @JsonProperty("business_account_token") @ExcludeMissing - fun _businessAccountToken() = businessAccountToken + fun _businessAccountToken(): JsonField = businessAccountToken /** A user provided id that can be used to link an account holder with an external system */ - @JsonProperty("external_id") @ExcludeMissing fun _externalId() = externalId + @JsonProperty("external_id") @ExcludeMissing fun _externalId(): JsonField = externalId @JsonAnyGetter @ExcludeMissing @@ -149,13 +153,13 @@ private constructor( class Builder { - private var address: JsonField
= JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var firstName: JsonField = JsonMissing.of() - private var kycExemptionType: JsonField = JsonMissing.of() - private var lastName: JsonField = JsonMissing.of() - private var phoneNumber: JsonField = JsonMissing.of() - private var workflow: JsonField = JsonMissing.of() + private var address: JsonField
? = null + private var email: JsonField? = null + private var firstName: JsonField? = null + private var kycExemptionType: JsonField? = null + private var lastName: JsonField? = null + private var phoneNumber: JsonField? = null + private var workflow: JsonField? = null private var businessAccountToken: JsonField = JsonMissing.of() private var externalId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -268,13 +272,13 @@ private constructor( fun build(): KycExempt = KycExempt( - address, - email, - firstName, - kycExemptionType, - lastName, - phoneNumber, - workflow, + checkNotNull(address) { "`address` is required but was not set" }, + checkNotNull(email) { "`email` is required but was not set" }, + checkNotNull(firstName) { "`firstName` is required but was not set" }, + checkNotNull(kycExemptionType) { "`kycExemptionType` is required but was not set" }, + checkNotNull(lastName) { "`lastName` is required but was not set" }, + checkNotNull(phoneNumber) { "`phoneNumber` is required but was not set" }, + checkNotNull(workflow) { "`workflow` is required but was not set" }, businessAccountToken, externalId, additionalProperties.toImmutable(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/LineItemListResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/LineItemListResponse.kt index 3cbb620c..40d91792 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/LineItemListResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/LineItemListResponse.kt @@ -95,43 +95,49 @@ private constructor( fun descriptor(): String? = descriptor.getNullable("descriptor") /** Globally unique identifier for a Statement Line Item */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Transaction amount in cents */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("category") @ExcludeMissing fun _category() = category + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category /** Timestamp of when the line item was generated */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** 3-digit alphabetic ISO 4217 code for the settling currency of the transaction */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** Date that the transaction effected the account balance */ - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("event_type") @ExcludeMissing fun _eventType() = eventType + @JsonProperty("event_type") + @ExcludeMissing + fun _eventType(): JsonField = eventType /** Globally unique identifier for a financial account */ @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken /** Globally unique identifier for a financial transaction event */ @JsonProperty("financial_transaction_event_token") @ExcludeMissing - fun _financialTransactionEventToken() = financialTransactionEventToken + fun _financialTransactionEventToken(): JsonField = financialTransactionEventToken /** Globally unique identifier for a financial transaction */ @JsonProperty("financial_transaction_token") @ExcludeMissing - fun _financialTransactionToken() = financialTransactionToken + fun _financialTransactionToken(): JsonField = financialTransactionToken /** Globally unique identifier for a card */ - @JsonProperty("card_token") @ExcludeMissing fun _cardToken() = cardToken + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken - @JsonProperty("descriptor") @ExcludeMissing fun _descriptor() = descriptor + @JsonProperty("descriptor") @ExcludeMissing fun _descriptor(): JsonField = descriptor @JsonAnyGetter @ExcludeMissing @@ -166,16 +172,16 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var category: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var effectiveDate: JsonField = JsonMissing.of() - private var eventType: JsonField = JsonMissing.of() - private var financialAccountToken: JsonField = JsonMissing.of() - private var financialTransactionEventToken: JsonField = JsonMissing.of() - private var financialTransactionToken: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var amount: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var effectiveDate: JsonField? = null + private var eventType: JsonField? = null + private var financialAccountToken: JsonField? = null + private var financialTransactionEventToken: JsonField? = null + private var financialTransactionToken: JsonField? = null private var cardToken: JsonField = JsonMissing.of() private var descriptor: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -297,16 +303,22 @@ private constructor( fun build(): LineItemListResponse = LineItemListResponse( - token, - amount, - category, - created, - currency, - effectiveDate, - eventType, - financialAccountToken, - financialTransactionEventToken, - financialTransactionToken, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(category) { "`category` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + checkNotNull(eventType) { "`eventType` is required but was not set" }, + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + checkNotNull(financialTransactionEventToken) { + "`financialTransactionEventToken` is required but was not set" + }, + checkNotNull(financialTransactionToken) { + "`financialTransactionToken` is required but was not set" + }, cardToken, descriptor, additionalProperties.toImmutable(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/LoanTape.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/LoanTape.kt index 5c3cc23d..3b9af258 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/LoanTape.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/LoanTape.kt @@ -154,76 +154,96 @@ private constructor( fun tier(): String? = tier.getNullable("tier") /** Globally unique identifier for a loan tape */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - @JsonProperty("account_standing") @ExcludeMissing fun _accountStanding() = accountStanding + @JsonProperty("account_standing") + @ExcludeMissing + fun _accountStanding(): JsonField = accountStanding /** Amount of credit available to spend in cents */ - @JsonProperty("available_credit") @ExcludeMissing fun _availableCredit() = availableCredit + @JsonProperty("available_credit") + @ExcludeMissing + fun _availableCredit(): JsonField = availableCredit - @JsonProperty("balances") @ExcludeMissing fun _balances() = balances + @JsonProperty("balances") @ExcludeMissing fun _balances(): JsonField = balances /** Timestamp of when the loan tape was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** * For prepay accounts, this is the minimum prepay balance that must be maintained. For charge * card accounts, this is the maximum credit balance extended by a lender */ - @JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit() = creditLimit + @JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit(): JsonField = creditLimit /** Globally unique identifier for a credit product */ @JsonProperty("credit_product_token") @ExcludeMissing - fun _creditProductToken() = creditProductToken + fun _creditProductToken(): JsonField = creditProductToken /** Date of transactions that this loan tape covers */ - @JsonProperty("date") @ExcludeMissing fun _date() = date + @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date - @JsonProperty("day_totals") @ExcludeMissing fun _dayTotals() = dayTotals + @JsonProperty("day_totals") + @ExcludeMissing + fun _dayTotals(): JsonField = dayTotals /** Balance at the end of the day */ - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance /** * Excess credits in the form of provisional credits, payments, or purchase refunds. If * positive, the account is in net credit state with no outstanding balances. An overpayment * could land an account in this state */ - @JsonProperty("excess_credits") @ExcludeMissing fun _excessCredits() = excessCredits + @JsonProperty("excess_credits") + @ExcludeMissing + fun _excessCredits(): JsonField = excessCredits /** Globally unique identifier for a financial account */ @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken - @JsonProperty("interest_details") @ExcludeMissing fun _interestDetails() = interestDetails + @JsonProperty("interest_details") + @ExcludeMissing + fun _interestDetails(): JsonField = interestDetails @JsonProperty("minimum_payment_balance") @ExcludeMissing - fun _minimumPaymentBalance() = minimumPaymentBalance + fun _minimumPaymentBalance(): JsonField = minimumPaymentBalance - @JsonProperty("payment_allocation") @ExcludeMissing fun _paymentAllocation() = paymentAllocation + @JsonProperty("payment_allocation") + @ExcludeMissing + fun _paymentAllocation(): JsonField = paymentAllocation - @JsonProperty("period_totals") @ExcludeMissing fun _periodTotals() = periodTotals + @JsonProperty("period_totals") + @ExcludeMissing + fun _periodTotals(): JsonField = periodTotals @JsonProperty("previous_statement_balance") @ExcludeMissing - fun _previousStatementBalance() = previousStatementBalance + fun _previousStatementBalance(): JsonField = previousStatementBalance /** Balance at the start of the day */ - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance /** Timestamp of when the loan tape was updated */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated /** Version number of the loan tape. This starts at 1 */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - @JsonProperty("ytd_totals") @ExcludeMissing fun _ytdTotals() = ytdTotals + @JsonProperty("ytd_totals") + @ExcludeMissing + fun _ytdTotals(): JsonField = ytdTotals /** Interest tier to which this account belongs to */ - @JsonProperty("tier") @ExcludeMissing fun _tier() = tier + @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField = tier @JsonAnyGetter @ExcludeMissing @@ -268,27 +288,27 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountStanding: JsonField = JsonMissing.of() - private var availableCredit: JsonField = JsonMissing.of() - private var balances: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var creditLimit: JsonField = JsonMissing.of() - private var creditProductToken: JsonField = JsonMissing.of() - private var date: JsonField = JsonMissing.of() - private var dayTotals: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var excessCredits: JsonField = JsonMissing.of() - private var financialAccountToken: JsonField = JsonMissing.of() - private var interestDetails: JsonField = JsonMissing.of() - private var minimumPaymentBalance: JsonField = JsonMissing.of() - private var paymentAllocation: JsonField = JsonMissing.of() - private var periodTotals: JsonField = JsonMissing.of() - private var previousStatementBalance: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var ytdTotals: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var accountStanding: JsonField? = null + private var availableCredit: JsonField? = null + private var balances: JsonField? = null + private var created: JsonField? = null + private var creditLimit: JsonField? = null + private var creditProductToken: JsonField? = null + private var date: JsonField? = null + private var dayTotals: JsonField? = null + private var endingBalance: JsonField? = null + private var excessCredits: JsonField? = null + private var financialAccountToken: JsonField? = null + private var interestDetails: JsonField? = null + private var minimumPaymentBalance: JsonField? = null + private var paymentAllocation: JsonField? = null + private var periodTotals: JsonField? = null + private var previousStatementBalance: JsonField? = null + private var startingBalance: JsonField? = null + private var updated: JsonField? = null + private var version: JsonField? = null + private var ytdTotals: JsonField? = null private var tier: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -413,8 +433,8 @@ private constructor( this.financialAccountToken = financialAccountToken } - fun interestDetails(interestDetails: InterestDetails) = - interestDetails(JsonField.of(interestDetails)) + fun interestDetails(interestDetails: InterestDetails?) = + interestDetails(JsonField.ofNullable(interestDetails)) fun interestDetails(interestDetails: JsonField) = apply { this.interestDetails = interestDetails @@ -498,27 +518,37 @@ private constructor( fun build(): LoanTape = LoanTape( - token, - accountStanding, - availableCredit, - balances, - created, - creditLimit, - creditProductToken, - date, - dayTotals, - endingBalance, - excessCredits, - financialAccountToken, - interestDetails, - minimumPaymentBalance, - paymentAllocation, - periodTotals, - previousStatementBalance, - startingBalance, - updated, - version, - ytdTotals, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountStanding) { "`accountStanding` is required but was not set" }, + checkNotNull(availableCredit) { "`availableCredit` is required but was not set" }, + checkNotNull(balances) { "`balances` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(creditLimit) { "`creditLimit` is required but was not set" }, + checkNotNull(creditProductToken) { + "`creditProductToken` is required but was not set" + }, + checkNotNull(date) { "`date` is required but was not set" }, + checkNotNull(dayTotals) { "`dayTotals` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(excessCredits) { "`excessCredits` is required but was not set" }, + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + checkNotNull(interestDetails) { "`interestDetails` is required but was not set" }, + checkNotNull(minimumPaymentBalance) { + "`minimumPaymentBalance` is required but was not set" + }, + checkNotNull(paymentAllocation) { + "`paymentAllocation` is required but was not set" + }, + checkNotNull(periodTotals) { "`periodTotals` is required but was not set" }, + checkNotNull(previousStatementBalance) { + "`previousStatementBalance` is required but was not set" + }, + checkNotNull(startingBalance) { "`startingBalance` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, + checkNotNull(ytdTotals) { "`ytdTotals` is required but was not set" }, tier, additionalProperties.toImmutable(), ) @@ -579,28 +609,34 @@ private constructor( /** Number of consecutive full payments made */ @JsonProperty("consecutive_full_payments_made") @ExcludeMissing - fun _consecutiveFullPaymentsMade() = consecutiveFullPaymentsMade + fun _consecutiveFullPaymentsMade(): JsonField = consecutiveFullPaymentsMade /** Number of consecutive minimum payments made */ @JsonProperty("consecutive_minimum_payments_made") @ExcludeMissing - fun _consecutiveMinimumPaymentsMade() = consecutiveMinimumPaymentsMade + fun _consecutiveMinimumPaymentsMade(): JsonField = consecutiveMinimumPaymentsMade /** Number of consecutive minimum payments missed */ @JsonProperty("consecutive_minimum_payments_missed") @ExcludeMissing - fun _consecutiveMinimumPaymentsMissed() = consecutiveMinimumPaymentsMissed + fun _consecutiveMinimumPaymentsMissed(): JsonField = consecutiveMinimumPaymentsMissed /** Number of days past due */ - @JsonProperty("days_past_due") @ExcludeMissing fun _daysPastDue() = daysPastDue + @JsonProperty("days_past_due") + @ExcludeMissing + fun _daysPastDue(): JsonField = daysPastDue /** Whether the account currently has grace or not */ - @JsonProperty("has_grace") @ExcludeMissing fun _hasGrace() = hasGrace + @JsonProperty("has_grace") @ExcludeMissing fun _hasGrace(): JsonField = hasGrace /** Current overall period number */ - @JsonProperty("period_number") @ExcludeMissing fun _periodNumber() = periodNumber + @JsonProperty("period_number") + @ExcludeMissing + fun _periodNumber(): JsonField = periodNumber - @JsonProperty("period_state") @ExcludeMissing fun _periodState() = periodState + @JsonProperty("period_state") + @ExcludeMissing + fun _periodState(): JsonField = periodState @JsonAnyGetter @ExcludeMissing @@ -630,13 +666,13 @@ private constructor( class Builder { - private var consecutiveFullPaymentsMade: JsonField = JsonMissing.of() - private var consecutiveMinimumPaymentsMade: JsonField = JsonMissing.of() - private var consecutiveMinimumPaymentsMissed: JsonField = JsonMissing.of() - private var daysPastDue: JsonField = JsonMissing.of() - private var hasGrace: JsonField = JsonMissing.of() - private var periodNumber: JsonField = JsonMissing.of() - private var periodState: JsonField = JsonMissing.of() + private var consecutiveFullPaymentsMade: JsonField? = null + private var consecutiveMinimumPaymentsMade: JsonField? = null + private var consecutiveMinimumPaymentsMissed: JsonField? = null + private var daysPastDue: JsonField? = null + private var hasGrace: JsonField? = null + private var periodNumber: JsonField? = null + private var periodState: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(accountStanding: AccountStanding) = apply { @@ -725,13 +761,19 @@ private constructor( fun build(): AccountStanding = AccountStanding( - consecutiveFullPaymentsMade, - consecutiveMinimumPaymentsMade, - consecutiveMinimumPaymentsMissed, - daysPastDue, - hasGrace, - periodNumber, - periodState, + checkNotNull(consecutiveFullPaymentsMade) { + "`consecutiveFullPaymentsMade` is required but was not set" + }, + checkNotNull(consecutiveMinimumPaymentsMade) { + "`consecutiveMinimumPaymentsMade` is required but was not set" + }, + checkNotNull(consecutiveMinimumPaymentsMissed) { + "`consecutiveMinimumPaymentsMissed` is required but was not set" + }, + checkNotNull(daysPastDue) { "`daysPastDue` is required but was not set" }, + checkNotNull(hasGrace) { "`hasGrace` is required but was not set" }, + checkNotNull(periodNumber) { "`periodNumber` is required but was not set" }, + checkNotNull(periodState) { "`periodState` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -861,7 +903,7 @@ private constructor( * Amount due for the prior billing cycle. Any amounts not fully paid off on this due date * will be considered past due the next day */ - @JsonProperty("due") @ExcludeMissing fun _due() = due + @JsonProperty("due") @ExcludeMissing fun _due(): JsonField = due /** * Amount due for the current billing cycle. Any amounts not paid off by early payments or @@ -869,15 +911,17 @@ private constructor( */ @JsonProperty("next_statement_due") @ExcludeMissing - fun _nextStatementDue() = nextStatementDue + fun _nextStatementDue(): JsonField = nextStatementDue /** Amount not paid off on previous due dates */ - @JsonProperty("past_due") @ExcludeMissing fun _pastDue() = pastDue + @JsonProperty("past_due") + @ExcludeMissing + fun _pastDue(): JsonField = pastDue /** Amount due for the past billing cycles. */ @JsonProperty("past_statements_due") @ExcludeMissing - fun _pastStatementsDue() = pastStatementsDue + fun _pastStatementsDue(): JsonField = pastStatementsDue @JsonAnyGetter @ExcludeMissing @@ -904,10 +948,10 @@ private constructor( class Builder { - private var due: JsonField = JsonMissing.of() - private var nextStatementDue: JsonField = JsonMissing.of() - private var pastDue: JsonField = JsonMissing.of() - private var pastStatementsDue: JsonField = JsonMissing.of() + private var due: JsonField? = null + private var nextStatementDue: JsonField? = null + private var pastDue: JsonField? = null + private var pastStatementsDue: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(balances: Balances) = apply { @@ -981,10 +1025,14 @@ private constructor( fun build(): Balances = Balances( - due, - nextStatementDue, - pastDue, - pastStatementsDue, + checkNotNull(due) { "`due` is required but was not set" }, + checkNotNull(nextStatementDue) { + "`nextStatementDue` is required but was not set" + }, + checkNotNull(pastDue) { "`pastDue` is required but was not set" }, + checkNotNull(pastStatementsDue) { + "`pastStatementsDue` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -1016,11 +1064,11 @@ private constructor( fun principal(): Long = principal.getRequired("principal") - @JsonProperty("fees") @ExcludeMissing fun _fees() = fees + @JsonProperty("fees") @ExcludeMissing fun _fees(): JsonField = fees - @JsonProperty("interest") @ExcludeMissing fun _interest() = interest + @JsonProperty("interest") @ExcludeMissing fun _interest(): JsonField = interest - @JsonProperty("principal") @ExcludeMissing fun _principal() = principal + @JsonProperty("principal") @ExcludeMissing fun _principal(): JsonField = principal @JsonAnyGetter @ExcludeMissing @@ -1046,9 +1094,9 @@ private constructor( class Builder { - private var fees: JsonField = JsonMissing.of() - private var interest: JsonField = JsonMissing.of() - private var principal: JsonField = JsonMissing.of() + private var fees: JsonField? = null + private var interest: JsonField? = null + private var principal: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(categoryBalances: CategoryBalances) = apply { @@ -1094,9 +1142,9 @@ private constructor( fun build(): CategoryBalances = CategoryBalances( - fees, - interest, - principal, + checkNotNull(fees) { "`fees` is required but was not set" }, + checkNotNull(interest) { "`interest` is required but was not set" }, + checkNotNull(principal) { "`principal` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1190,27 +1238,29 @@ private constructor( /** Opening balance transferred from previous account in cents */ @JsonProperty("balance_transfers") @ExcludeMissing - fun _balanceTransfers() = balanceTransfers + fun _balanceTransfers(): JsonField = balanceTransfers /** ATM and cashback transactions in cents */ - @JsonProperty("cash_advances") @ExcludeMissing fun _cashAdvances() = cashAdvances + @JsonProperty("cash_advances") + @ExcludeMissing + fun _cashAdvances(): JsonField = cashAdvances /** * Volume of credit management operation transactions less any balance transfers in cents */ - @JsonProperty("credits") @ExcludeMissing fun _credits() = credits + @JsonProperty("credits") @ExcludeMissing fun _credits(): JsonField = credits /** Volume of debit management operation transactions less any interest in cents */ - @JsonProperty("fees") @ExcludeMissing fun _fees() = fees + @JsonProperty("fees") @ExcludeMissing fun _fees(): JsonField = fees /** Interest accrued in cents */ - @JsonProperty("interest") @ExcludeMissing fun _interest() = interest + @JsonProperty("interest") @ExcludeMissing fun _interest(): JsonField = interest /** Any funds transfers which affective the balance in cents */ - @JsonProperty("payments") @ExcludeMissing fun _payments() = payments + @JsonProperty("payments") @ExcludeMissing fun _payments(): JsonField = payments /** Net card transaction volume less any cash advances in cents */ - @JsonProperty("purchases") @ExcludeMissing fun _purchases() = purchases + @JsonProperty("purchases") @ExcludeMissing fun _purchases(): JsonField = purchases @JsonAnyGetter @ExcludeMissing @@ -1240,13 +1290,13 @@ private constructor( class Builder { - private var balanceTransfers: JsonField = JsonMissing.of() - private var cashAdvances: JsonField = JsonMissing.of() - private var credits: JsonField = JsonMissing.of() - private var fees: JsonField = JsonMissing.of() - private var interest: JsonField = JsonMissing.of() - private var payments: JsonField = JsonMissing.of() - private var purchases: JsonField = JsonMissing.of() + private var balanceTransfers: JsonField? = null + private var cashAdvances: JsonField? = null + private var credits: JsonField? = null + private var fees: JsonField? = null + private var interest: JsonField? = null + private var payments: JsonField? = null + private var purchases: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(statementTotals: StatementTotals) = apply { @@ -1334,13 +1384,15 @@ private constructor( fun build(): StatementTotals = StatementTotals( - balanceTransfers, - cashAdvances, - credits, - fees, - interest, - payments, - purchases, + checkNotNull(balanceTransfers) { + "`balanceTransfers` is required but was not set" + }, + checkNotNull(cashAdvances) { "`cashAdvances` is required but was not set" }, + checkNotNull(credits) { "`credits` is required but was not set" }, + checkNotNull(fees) { "`fees` is required but was not set" }, + checkNotNull(interest) { "`interest` is required but was not set" }, + checkNotNull(payments) { "`payments` is required but was not set" }, + checkNotNull(purchases) { "`purchases` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1414,27 +1466,30 @@ private constructor( @JsonProperty("actual_interest_charged") @ExcludeMissing - fun _actualInterestCharged() = actualInterestCharged + fun _actualInterestCharged(): JsonField = actualInterestCharged @JsonProperty("daily_balance_amounts") @ExcludeMissing - fun _dailyBalanceAmounts() = dailyBalanceAmounts + fun _dailyBalanceAmounts(): JsonField = dailyBalanceAmounts - @JsonProperty("effective_apr") @ExcludeMissing fun _effectiveApr() = effectiveApr + @JsonProperty("effective_apr") + @ExcludeMissing + fun _effectiveApr(): JsonField = effectiveApr @JsonProperty("interest_calculation_method") @ExcludeMissing - fun _interestCalculationMethod() = interestCalculationMethod + fun _interestCalculationMethod(): JsonField = + interestCalculationMethod @JsonProperty("interest_for_period") @ExcludeMissing - fun _interestForPeriod() = interestForPeriod + fun _interestForPeriod(): JsonField = interestForPeriod - @JsonProperty("prime_rate") @ExcludeMissing fun _primeRate() = primeRate + @JsonProperty("prime_rate") @ExcludeMissing fun _primeRate(): JsonField = primeRate @JsonProperty("minimum_interest_charged") @ExcludeMissing - fun _minimumInterestCharged() = minimumInterestCharged + fun _minimumInterestCharged(): JsonField = minimumInterestCharged @JsonAnyGetter @ExcludeMissing @@ -1464,13 +1519,12 @@ private constructor( class Builder { - private var actualInterestCharged: JsonField = JsonMissing.of() - private var dailyBalanceAmounts: JsonField = JsonMissing.of() - private var effectiveApr: JsonField = JsonMissing.of() - private var interestCalculationMethod: JsonField = - JsonMissing.of() - private var interestForPeriod: JsonField = JsonMissing.of() - private var primeRate: JsonField = JsonMissing.of() + private var actualInterestCharged: JsonField? = null + private var dailyBalanceAmounts: JsonField? = null + private var effectiveApr: JsonField? = null + private var interestCalculationMethod: JsonField? = null + private var interestForPeriod: JsonField? = null + private var primeRate: JsonField? = null private var minimumInterestCharged: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1485,8 +1539,11 @@ private constructor( additionalProperties = interestDetails.additionalProperties.toMutableMap() } + fun actualInterestCharged(actualInterestCharged: Long?) = + actualInterestCharged(JsonField.ofNullable(actualInterestCharged)) + fun actualInterestCharged(actualInterestCharged: Long) = - actualInterestCharged(JsonField.of(actualInterestCharged)) + actualInterestCharged(actualInterestCharged as Long?) fun actualInterestCharged(actualInterestCharged: JsonField) = apply { this.actualInterestCharged = actualInterestCharged @@ -1520,12 +1577,15 @@ private constructor( this.interestForPeriod = interestForPeriod } - fun primeRate(primeRate: String) = primeRate(JsonField.of(primeRate)) + fun primeRate(primeRate: String?) = primeRate(JsonField.ofNullable(primeRate)) fun primeRate(primeRate: JsonField) = apply { this.primeRate = primeRate } + fun minimumInterestCharged(minimumInterestCharged: Long?) = + minimumInterestCharged(JsonField.ofNullable(minimumInterestCharged)) + fun minimumInterestCharged(minimumInterestCharged: Long) = - minimumInterestCharged(JsonField.of(minimumInterestCharged)) + minimumInterestCharged(minimumInterestCharged as Long?) fun minimumInterestCharged(minimumInterestCharged: JsonField) = apply { this.minimumInterestCharged = minimumInterestCharged @@ -1552,12 +1612,20 @@ private constructor( fun build(): InterestDetails = InterestDetails( - actualInterestCharged, - dailyBalanceAmounts, - effectiveApr, - interestCalculationMethod, - interestForPeriod, - primeRate, + checkNotNull(actualInterestCharged) { + "`actualInterestCharged` is required but was not set" + }, + checkNotNull(dailyBalanceAmounts) { + "`dailyBalanceAmounts` is required but was not set" + }, + checkNotNull(effectiveApr) { "`effectiveApr` is required but was not set" }, + checkNotNull(interestCalculationMethod) { + "`interestCalculationMethod` is required but was not set" + }, + checkNotNull(interestForPeriod) { + "`interestForPeriod` is required but was not set" + }, + checkNotNull(primeRate) { "`primeRate` is required but was not set" }, minimumInterestCharged, additionalProperties.toImmutable(), ) @@ -1588,11 +1656,15 @@ private constructor( @JsonProperty("balance_transfers") @ExcludeMissing - fun _balanceTransfers() = balanceTransfers + fun _balanceTransfers(): JsonField = balanceTransfers - @JsonProperty("cash_advances") @ExcludeMissing fun _cashAdvances() = cashAdvances + @JsonProperty("cash_advances") + @ExcludeMissing + fun _cashAdvances(): JsonField = cashAdvances - @JsonProperty("purchases") @ExcludeMissing fun _purchases() = purchases + @JsonProperty("purchases") + @ExcludeMissing + fun _purchases(): JsonField = purchases @JsonAnyGetter @ExcludeMissing @@ -1618,9 +1690,9 @@ private constructor( class Builder { - private var balanceTransfers: JsonField = JsonMissing.of() - private var cashAdvances: JsonField = JsonMissing.of() - private var purchases: JsonField = JsonMissing.of() + private var balanceTransfers: JsonField? = null + private var cashAdvances: JsonField? = null + private var purchases: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(categoryDetails: CategoryDetails) = apply { @@ -1671,9 +1743,11 @@ private constructor( fun build(): CategoryDetails = CategoryDetails( - balanceTransfers, - cashAdvances, - purchases, + checkNotNull(balanceTransfers) { + "`balanceTransfers` is required but was not set" + }, + checkNotNull(cashAdvances) { "`cashAdvances` is required but was not set" }, + checkNotNull(purchases) { "`purchases` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1792,9 +1866,9 @@ private constructor( fun remaining(): Long = remaining.getRequired("remaining") - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("remaining") @ExcludeMissing fun _remaining() = remaining + @JsonProperty("remaining") @ExcludeMissing fun _remaining(): JsonField = remaining @JsonAnyGetter @ExcludeMissing @@ -1819,8 +1893,8 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var remaining: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var remaining: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(balanceDetails: BalanceDetails) = apply { @@ -1858,8 +1932,8 @@ private constructor( fun build(): BalanceDetails = BalanceDetails( - amount, - remaining, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(remaining) { "`remaining` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1903,11 +1977,11 @@ private constructor( fun principal(): Long = principal.getRequired("principal") - @JsonProperty("fees") @ExcludeMissing fun _fees() = fees + @JsonProperty("fees") @ExcludeMissing fun _fees(): JsonField = fees - @JsonProperty("interest") @ExcludeMissing fun _interest() = interest + @JsonProperty("interest") @ExcludeMissing fun _interest(): JsonField = interest - @JsonProperty("principal") @ExcludeMissing fun _principal() = principal + @JsonProperty("principal") @ExcludeMissing fun _principal(): JsonField = principal @JsonAnyGetter @ExcludeMissing @@ -1933,9 +2007,9 @@ private constructor( class Builder { - private var fees: JsonField = JsonMissing.of() - private var interest: JsonField = JsonMissing.of() - private var principal: JsonField = JsonMissing.of() + private var fees: JsonField? = null + private var interest: JsonField? = null + private var principal: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(categoryBalances: CategoryBalances) = apply { @@ -1978,9 +2052,9 @@ private constructor( fun build(): CategoryBalances = CategoryBalances( - fees, - interest, - principal, + checkNotNull(fees) { "`fees` is required but was not set" }, + checkNotNull(interest) { "`interest` is required but was not set" }, + checkNotNull(principal) { "`principal` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreateParams.kt index 1525a285..5f757a23 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -47,12 +48,32 @@ constructor( fun userDefinedId(): String? = body.userDefinedId() - fun _additionalHeaders(): Headers = additionalHeaders + fun _amount(): JsonField = body._amount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _category(): JsonField = body._category() + + fun _direction(): JsonField = body._direction() + + fun _effectiveDate(): JsonField = body._effectiveDate() + + fun _eventType(): JsonField = body._eventType() + + fun _financialAccountToken(): JsonField = body._financialAccountToken() + + fun _token(): JsonField = body._token() + + fun _memo(): JsonField = body._memo() + + fun _subtype(): JsonField = body._subtype() + + fun _userDefinedId(): JsonField = body._userDefinedId() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): ManagementOperationCreateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -63,45 +84,115 @@ constructor( class ManagementOperationCreateBody @JsonCreator internal constructor( - @JsonProperty("amount") private val amount: Long, - @JsonProperty("category") private val category: ManagementOperationCategory, - @JsonProperty("direction") private val direction: ManagementOperationDirection, - @JsonProperty("effective_date") private val effectiveDate: LocalDate, - @JsonProperty("event_type") private val eventType: ManagementOperationEventType, - @JsonProperty("financial_account_token") private val financialAccountToken: String, - @JsonProperty("token") private val token: String?, - @JsonProperty("memo") private val memo: String?, - @JsonProperty("subtype") private val subtype: String?, - @JsonProperty("user_defined_id") private val userDefinedId: String?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + private val category: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + private val direction: JsonField = JsonMissing.of(), + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + private val eventType: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + private val financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("token") + @ExcludeMissing + private val token: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), + @JsonProperty("subtype") + @ExcludeMissing + private val subtype: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + private val userDefinedId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("amount") fun amount(): Long = amount + fun amount(): Long = amount.getRequired("amount") + + fun category(): ManagementOperationCategory = category.getRequired("category") + + fun direction(): ManagementOperationDirection = direction.getRequired("direction") + + fun effectiveDate(): LocalDate = effectiveDate.getRequired("effective_date") - @JsonProperty("category") fun category(): ManagementOperationCategory = category + fun eventType(): ManagementOperationEventType = eventType.getRequired("event_type") - @JsonProperty("direction") fun direction(): ManagementOperationDirection = direction + fun financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") - @JsonProperty("effective_date") fun effectiveDate(): LocalDate = effectiveDate + fun token(): String? = token.getNullable("token") - @JsonProperty("event_type") fun eventType(): ManagementOperationEventType = eventType + fun memo(): String? = memo.getNullable("memo") + + fun subtype(): String? = subtype.getNullable("subtype") + + fun userDefinedId(): String? = userDefinedId.getNullable("user_defined_id") + + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category + + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction + + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + @JsonProperty("event_type") + @ExcludeMissing + fun _eventType(): JsonField = eventType @JsonProperty("financial_account_token") - fun financialAccountToken(): String = financialAccountToken + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken - @JsonProperty("token") fun token(): String? = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - @JsonProperty("memo") fun memo(): String? = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - @JsonProperty("subtype") fun subtype(): String? = subtype + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype - @JsonProperty("user_defined_id") fun userDefinedId(): String? = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ManagementOperationCreateBody = apply { + if (!validated) { + amount() + category() + direction() + effectiveDate() + eventType() + financialAccountToken() + token() + memo() + subtype() + userDefinedId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -111,16 +202,16 @@ constructor( class Builder { - private var amount: Long? = null - private var category: ManagementOperationCategory? = null - private var direction: ManagementOperationDirection? = null - private var effectiveDate: LocalDate? = null - private var eventType: ManagementOperationEventType? = null - private var financialAccountToken: String? = null - private var token: String? = null - private var memo: String? = null - private var subtype: String? = null - private var userDefinedId: String? = null + private var amount: JsonField? = null + private var category: JsonField? = null + private var direction: JsonField? = null + private var effectiveDate: JsonField? = null + private var eventType: JsonField? = null + private var financialAccountToken: JsonField? = null + private var token: JsonField = JsonMissing.of() + private var memo: JsonField = JsonMissing.of() + private var subtype: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(managementOperationCreateBody: ManagementOperationCreateBody) = @@ -139,33 +230,60 @@ constructor( managementOperationCreateBody.additionalProperties.toMutableMap() } - fun amount(amount: Long) = apply { this.amount = amount } + fun amount(amount: Long) = amount(JsonField.of(amount)) - fun category(category: ManagementOperationCategory) = apply { this.category = category } + fun amount(amount: JsonField) = apply { this.amount = amount } - fun direction(direction: ManagementOperationDirection) = apply { + fun category(category: ManagementOperationCategory) = category(JsonField.of(category)) + + fun category(category: JsonField) = apply { + this.category = category + } + + fun direction(direction: ManagementOperationDirection) = + direction(JsonField.of(direction)) + + fun direction(direction: JsonField) = apply { this.direction = direction } - fun effectiveDate(effectiveDate: LocalDate) = apply { + fun effectiveDate(effectiveDate: LocalDate) = effectiveDate(JsonField.of(effectiveDate)) + + fun effectiveDate(effectiveDate: JsonField) = apply { this.effectiveDate = effectiveDate } - fun eventType(eventType: ManagementOperationEventType) = apply { + fun eventType(eventType: ManagementOperationEventType) = + eventType(JsonField.of(eventType)) + + fun eventType(eventType: JsonField) = apply { this.eventType = eventType } - fun financialAccountToken(financialAccountToken: String) = apply { + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + fun financialAccountToken(financialAccountToken: JsonField) = apply { this.financialAccountToken = financialAccountToken } - fun token(token: String?) = apply { this.token = token } + fun token(token: String) = token(JsonField.of(token)) + + fun token(token: JsonField) = apply { this.token = token } + + fun memo(memo: String) = memo(JsonField.of(memo)) - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: JsonField) = apply { this.memo = memo } - fun subtype(subtype: String?) = apply { this.subtype = subtype } + fun subtype(subtype: String) = subtype(JsonField.of(subtype)) - fun userDefinedId(userDefinedId: String?) = apply { this.userDefinedId = userDefinedId } + fun subtype(subtype: JsonField) = apply { this.subtype = subtype } + + fun userDefinedId(userDefinedId: String) = userDefinedId(JsonField.of(userDefinedId)) + + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -247,25 +365,76 @@ constructor( fun amount(amount: Long) = apply { body.amount(amount) } + fun amount(amount: JsonField) = apply { body.amount(amount) } + fun category(category: ManagementOperationCategory) = apply { body.category(category) } + fun category(category: JsonField) = apply { + body.category(category) + } + fun direction(direction: ManagementOperationDirection) = apply { body.direction(direction) } + fun direction(direction: JsonField) = apply { + body.direction(direction) + } + fun effectiveDate(effectiveDate: LocalDate) = apply { body.effectiveDate(effectiveDate) } + fun effectiveDate(effectiveDate: JsonField) = apply { + body.effectiveDate(effectiveDate) + } + fun eventType(eventType: ManagementOperationEventType) = apply { body.eventType(eventType) } + fun eventType(eventType: JsonField) = apply { + body.eventType(eventType) + } + fun financialAccountToken(financialAccountToken: String) = apply { body.financialAccountToken(financialAccountToken) } - fun token(token: String?) = apply { body.token(token) } + fun financialAccountToken(financialAccountToken: JsonField) = apply { + body.financialAccountToken(financialAccountToken) + } + + fun token(token: String) = apply { body.token(token) } + + fun token(token: JsonField) = apply { body.token(token) } + + fun memo(memo: String) = apply { body.memo(memo) } - fun memo(memo: String?) = apply { body.memo(memo) } + fun memo(memo: JsonField) = apply { body.memo(memo) } - fun subtype(subtype: String?) = apply { body.subtype(subtype) } + fun subtype(subtype: String) = apply { body.subtype(subtype) } - fun userDefinedId(userDefinedId: String?) = apply { body.userDefinedId(userDefinedId) } + fun subtype(subtype: JsonField) = apply { body.subtype(subtype) } + + fun userDefinedId(userDefinedId: String) = apply { body.userDefinedId(userDefinedId) } + + fun userDefinedId(userDefinedId: JsonField) = apply { + body.userDefinedId(userDefinedId) + } + + 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() @@ -365,25 +534,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ManagementOperationCreateParams = ManagementOperationCreateParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ManagementOperationReverseParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ManagementOperationReverseParams.kt index f73568d1..daa06588 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ManagementOperationReverseParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ManagementOperationReverseParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -31,12 +33,16 @@ constructor( fun memo(): String? = body.memo() - fun _additionalHeaders(): Headers = additionalHeaders + fun _effectiveDate(): JsonField = body._effectiveDate() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _memo(): JsonField = body._memo() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): ManagementOperationReverseBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -54,20 +60,40 @@ constructor( class ManagementOperationReverseBody @JsonCreator internal constructor( - @JsonProperty("effective_date") private val effectiveDate: LocalDate, - @JsonProperty("memo") private val memo: String?, + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("effective_date") fun effectiveDate(): LocalDate = effectiveDate + fun effectiveDate(): LocalDate = effectiveDate.getRequired("effective_date") - @JsonProperty("memo") fun memo(): String? = memo + fun memo(): String? = memo.getNullable("memo") + + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ManagementOperationReverseBody = apply { + if (!validated) { + effectiveDate() + memo() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -77,8 +103,8 @@ constructor( class Builder { - private var effectiveDate: LocalDate? = null - private var memo: String? = null + private var effectiveDate: JsonField? = null + private var memo: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(managementOperationReverseBody: ManagementOperationReverseBody) = @@ -89,11 +115,15 @@ constructor( managementOperationReverseBody.additionalProperties.toMutableMap() } - fun effectiveDate(effectiveDate: LocalDate) = apply { + fun effectiveDate(effectiveDate: LocalDate) = effectiveDate(JsonField.of(effectiveDate)) + + fun effectiveDate(effectiveDate: JsonField) = apply { this.effectiveDate = effectiveDate } - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String) = memo(JsonField.of(memo)) + + fun memo(memo: JsonField) = apply { this.memo = memo } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -171,7 +201,32 @@ constructor( fun effectiveDate(effectiveDate: LocalDate) = apply { body.effectiveDate(effectiveDate) } - fun memo(memo: String?) = apply { body.memo(memo) } + fun effectiveDate(effectiveDate: JsonField) = apply { + body.effectiveDate(effectiveDate) + } + + fun memo(memo: String) = apply { body.memo(memo) } + + fun memo(memo: JsonField) = apply { body.memo(memo) } + + 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() @@ -271,25 +326,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ManagementOperationReverseParams = ManagementOperationReverseParams( checkNotNull(managementOperationToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt index f753a29a..a7a7d199 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt @@ -90,33 +90,45 @@ private constructor( fun userDefinedId(): String? = userDefinedId.getNullable("user_defined_id") - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - @JsonProperty("category") @ExcludeMissing fun _category() = category + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken - @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result - @JsonProperty("settled_amount") @ExcludeMissing fun _settledAmount() = settledAmount + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated - @JsonProperty("user_defined_id") @ExcludeMissing fun _userDefinedId() = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId @JsonAnyGetter @ExcludeMissing @@ -152,18 +164,18 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var category: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var direction: JsonField = JsonMissing.of() - private var events: JsonField> = JsonMissing.of() - private var financialAccountToken: JsonField = JsonMissing.of() - private var pendingAmount: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var settledAmount: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var direction: JsonField? = null + private var events: JsonField>? = null + private var financialAccountToken: JsonField? = null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null private var userDefinedId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -173,7 +185,7 @@ private constructor( created = managementOperationTransaction.created currency = managementOperationTransaction.currency direction = managementOperationTransaction.direction - events = managementOperationTransaction.events + events = managementOperationTransaction.events.map { it.toMutableList() } financialAccountToken = managementOperationTransaction.financialAccountToken pendingAmount = managementOperationTransaction.pendingAmount result = managementOperationTransaction.result @@ -212,7 +224,18 @@ private constructor( fun events(events: List) = events(JsonField.of(events)) fun events(events: JsonField>) = apply { - this.events = events + this.events = events.map { it.toMutableList() } + } + + fun addEvent(event: ManagementOperationEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(event) + } } fun financialAccountToken(financialAccountToken: String) = @@ -273,18 +296,21 @@ private constructor( fun build(): ManagementOperationTransaction = ManagementOperationTransaction( - token, - category, - created, - currency, - direction, - events.map { it.toImmutable() }, - financialAccountToken, - pendingAmount, - result, - settledAmount, - status, - updated, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(category) { "`category` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(direction) { "`direction` is required but was not set" }, + checkNotNull(events) { "`events` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + checkNotNull(pendingAmount) { "`pendingAmount` is required but was not set" }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(settledAmount) { "`settledAmount` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, userDefinedId, additionalProperties.toImmutable(), ) @@ -472,23 +498,29 @@ private constructor( fun subtype(): String? = subtype.getNullable("subtype") - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - @JsonProperty("detailed_results") @ExcludeMissing fun _detailedResults() = detailedResults + @JsonProperty("detailed_results") + @ExcludeMissing + fun _detailedResults(): JsonField> = detailedResults - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("memo") @ExcludeMissing fun _memo() = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type - @JsonProperty("subtype") @ExcludeMissing fun _subtype() = subtype + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype @JsonAnyGetter @ExcludeMissing @@ -520,14 +552,14 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var detailedResults: JsonField> = JsonMissing.of() - private var effectiveDate: JsonField = JsonMissing.of() - private var memo: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var amount: JsonField? = null + private var created: JsonField? = null + private var detailedResults: JsonField>? = null + private var effectiveDate: JsonField? = null + private var memo: JsonField? = null + private var result: JsonField? = null + private var type: JsonField? = null private var subtype: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -535,7 +567,8 @@ private constructor( token = managementOperationEvent.token amount = managementOperationEvent.amount created = managementOperationEvent.created - detailedResults = managementOperationEvent.detailedResults + detailedResults = + managementOperationEvent.detailedResults.map { it.toMutableList() } effectiveDate = managementOperationEvent.effectiveDate memo = managementOperationEvent.memo result = managementOperationEvent.result @@ -560,7 +593,18 @@ private constructor( detailedResults(JsonField.of(detailedResults)) fun detailedResults(detailedResults: JsonField>) = apply { - this.detailedResults = detailedResults + this.detailedResults = detailedResults.map { it.toMutableList() } + } + + fun addDetailedResult(detailedResult: DetailedResults) = apply { + detailedResults = + (detailedResults ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(detailedResult) + } } fun effectiveDate(effectiveDate: LocalDate) = effectiveDate(JsonField.of(effectiveDate)) @@ -606,14 +650,17 @@ private constructor( fun build(): ManagementOperationEvent = ManagementOperationEvent( - token, - amount, - created, - detailedResults.map { it.toImmutable() }, - effectiveDate, - memo, - result, - type, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(detailedResults) { + "`detailedResults` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + checkNotNull(memo) { "`memo` is required but was not set" }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, subtype, additionalProperties.toImmutable(), ) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/MessageAttempt.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/MessageAttempt.kt index 7a8c2dab..2428615a 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/MessageAttempt.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/MessageAttempt.kt @@ -75,35 +75,35 @@ private constructor( fun url(): String = url.getRequired("url") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * An RFC 3339 timestamp for when the event was created. UTC time zone. * * If no timezone is specified, UTC will be used. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Globally unique identifier. */ @JsonProperty("event_subscription_token") @ExcludeMissing - fun _eventSubscriptionToken() = eventSubscriptionToken + fun _eventSubscriptionToken(): JsonField = eventSubscriptionToken /** Globally unique identifier. */ - @JsonProperty("event_token") @ExcludeMissing fun _eventToken() = eventToken + @JsonProperty("event_token") @ExcludeMissing fun _eventToken(): JsonField = eventToken /** The response body from the event subscription's URL. */ - @JsonProperty("response") @ExcludeMissing fun _response() = response + @JsonProperty("response") @ExcludeMissing fun _response(): JsonField = response /** The response status code from the event subscription's URL. */ @JsonProperty("response_status_code") @ExcludeMissing - fun _responseStatusCode() = responseStatusCode + fun _responseStatusCode(): JsonField = responseStatusCode /** The status of the event attempt. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url @JsonAnyGetter @ExcludeMissing @@ -134,14 +134,14 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var eventSubscriptionToken: JsonField = JsonMissing.of() - private var eventToken: JsonField = JsonMissing.of() - private var response: JsonField = JsonMissing.of() - private var responseStatusCode: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var created: JsonField? = null + private var eventSubscriptionToken: JsonField? = null + private var eventToken: JsonField? = null + private var response: JsonField? = null + private var responseStatusCode: JsonField? = null + private var status: JsonField? = null + private var url: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(messageAttempt: MessageAttempt) = apply { @@ -237,14 +237,18 @@ private constructor( fun build(): MessageAttempt = MessageAttempt( - token, - created, - eventSubscriptionToken, - eventToken, - response, - responseStatusCode, - status, - url, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(eventSubscriptionToken) { + "`eventSubscriptionToken` is required but was not set" + }, + checkNotNull(eventToken) { "`eventToken` is required but was not set" }, + checkNotNull(response) { "`response` is required but was not set" }, + checkNotNull(responseStatusCode) { + "`responseStatusCode` is required but was not set" + }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(url) { "`url` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/MicroDepositCreateResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/MicroDepositCreateResponse.kt index 8bd4a6d5..eb52cbcb 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/MicroDepositCreateResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/MicroDepositCreateResponse.kt @@ -171,82 +171,94 @@ private constructor( * program links an external bank account to more than one end-user or to both the program and * the end-user, then Lithic will return each record of the association */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * The country that the bank account is located in using ISO 3166-1. We will only accept USA * bank accounts e.g., USA */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** An ISO 8601 string representing when this funding source was added to the Lithic account. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** currency of the external account 3-digit alphabetic ISO 4217 code */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The last 4 digits of the bank account. Derived by Lithic from the account number passed */ - @JsonProperty("last_four") @ExcludeMissing fun _lastFour() = lastFour + @JsonProperty("last_four") @ExcludeMissing fun _lastFour(): JsonField = lastFour /** * Legal Name of the business or individual who owns the external account. This will appear in * statements */ - @JsonProperty("owner") @ExcludeMissing fun _owner() = owner + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner /** Owner Type */ - @JsonProperty("owner_type") @ExcludeMissing fun _ownerType() = ownerType + @JsonProperty("owner_type") @ExcludeMissing fun _ownerType(): JsonField = ownerType /** Routing Number */ - @JsonProperty("routing_number") @ExcludeMissing fun _routingNumber() = routingNumber + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber /** Account State */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** Account Type */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** The number of attempts at verification */ @JsonProperty("verification_attempts") @ExcludeMissing - fun _verificationAttempts() = verificationAttempts + fun _verificationAttempts(): JsonField = verificationAttempts /** Verification Method */ @JsonProperty("verification_method") @ExcludeMissing - fun _verificationMethod() = verificationMethod + fun _verificationMethod(): JsonField = verificationMethod /** Verification State */ - @JsonProperty("verification_state") @ExcludeMissing fun _verificationState() = verificationState + @JsonProperty("verification_state") + @ExcludeMissing + fun _verificationState(): JsonField = verificationState /** * Indicates which Lithic account the external account is associated with. For external accounts * that are associated with the program, account_token field returned will be null */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** Address */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") + @ExcludeMissing + fun _address(): JsonField = address /** Optional field that helps identify bank accounts in receipts */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Date of Birth of the Individual that owns the external bank account */ - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob /** Doing Business As */ - @JsonProperty("doing_business_as") @ExcludeMissing fun _doingBusinessAs() = doingBusinessAs + @JsonProperty("doing_business_as") + @ExcludeMissing + fun _doingBusinessAs(): JsonField = doingBusinessAs /** The financial account token of the operating account to fund the micro deposits */ @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken /** The nickname for this External Bank Account */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** User Defined ID */ - @JsonProperty("user_defined_id") @ExcludeMissing fun _userDefinedId() = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId /** * Optional free text description of the reason for the failed verification. For ACH @@ -255,7 +267,7 @@ private constructor( */ @JsonProperty("verification_failed_reason") @ExcludeMissing - fun _verificationFailedReason() = verificationFailedReason + fun _verificationFailedReason(): JsonField = verificationFailedReason @JsonAnyGetter @ExcludeMissing @@ -300,19 +312,19 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var lastFour: JsonField = JsonMissing.of() - private var owner: JsonField = JsonMissing.of() - private var ownerType: JsonField = JsonMissing.of() - private var routingNumber: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var verificationAttempts: JsonField = JsonMissing.of() - private var verificationMethod: JsonField = JsonMissing.of() - private var verificationState: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var country: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var lastFour: JsonField? = null + private var owner: JsonField? = null + private var ownerType: JsonField? = null + private var routingNumber: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var verificationAttempts: JsonField? = null + private var verificationMethod: JsonField? = null + private var verificationState: JsonField? = null private var accountToken: JsonField = JsonMissing.of() private var address: JsonField = JsonMissing.of() private var companyId: JsonField = JsonMissing.of() @@ -571,19 +583,25 @@ private constructor( fun build(): MicroDepositCreateResponse = MicroDepositCreateResponse( - token, - country, - created, - currency, - lastFour, - owner, - ownerType, - routingNumber, - state, - type, - verificationAttempts, - verificationMethod, - verificationState, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(lastFour) { "`lastFour` is required but was not set" }, + checkNotNull(owner) { "`owner` is required but was not set" }, + checkNotNull(ownerType) { "`ownerType` is required but was not set" }, + checkNotNull(routingNumber) { "`routingNumber` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(verificationAttempts) { + "`verificationAttempts` is required but was not set" + }, + checkNotNull(verificationMethod) { + "`verificationMethod` is required but was not set" + }, + checkNotNull(verificationState) { + "`verificationState` is required but was not set" + }, accountToken, address, companyId, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Payment.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Payment.kt index 7184e951..e22be927 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Payment.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Payment.kt @@ -143,55 +143,61 @@ private constructor( fun userDefinedId(): String? = userDefinedId.getNullable("user_defined_id") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Payment category */ - @JsonProperty("category") @ExcludeMissing fun _category() = category + @JsonProperty("category") @ExcludeMissing fun _category(): JsonField = category /** Date and time when the payment first occurred. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** 3-digit alphabetic ISO 4217 code for the settling currency of the payment. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** A string that provides a description of the payment; may be useful to display to users. */ - @JsonProperty("descriptor") @ExcludeMissing fun _descriptor() = descriptor + @JsonProperty("descriptor") @ExcludeMissing fun _descriptor(): JsonField = descriptor - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction + @JsonProperty("direction") @ExcludeMissing fun _direction(): JsonField = direction /** A list of all payment events that have modified this payment. */ - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events @JsonProperty("external_bank_account_token") @ExcludeMissing - fun _externalBankAccountToken() = externalBankAccountToken + fun _externalBankAccountToken(): JsonField = externalBankAccountToken @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken - @JsonProperty("method") @ExcludeMissing fun _method() = method + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method - @JsonProperty("method_attributes") @ExcludeMissing fun _methodAttributes() = methodAttributes + @JsonProperty("method_attributes") + @ExcludeMissing + fun _methodAttributes(): JsonField = methodAttributes /** * Pending amount of the payment in the currency's smallest unit (e.g., cents). The value of * this field will go to zero over time once the payment is settled. */ - @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount /** * APPROVED payments were successful while DECLINED payments were declined by Lithic or * returned. */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** * Amount of the payment that has been settled in the currency's smallest unit (e.g., cents). */ - @JsonProperty("settled_amount") @ExcludeMissing fun _settledAmount() = settledAmount + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount - @JsonProperty("source") @ExcludeMissing fun _source() = source + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source /** * Status types: @@ -201,12 +207,14 @@ private constructor( * - `RETURNED` - The payment has been returned. * - `SETTLED` - The payment is completed. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** Date and time when the financial transaction was last updated. UTC time zone. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated - @JsonProperty("user_defined_id") @ExcludeMissing fun _userDefinedId() = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId @JsonAnyGetter @ExcludeMissing @@ -247,24 +255,24 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var category: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var descriptor: JsonField = JsonMissing.of() - private var direction: JsonField = JsonMissing.of() - private var events: JsonField> = JsonMissing.of() - private var externalBankAccountToken: JsonField = JsonMissing.of() - private var financialAccountToken: JsonField = JsonMissing.of() - private var method: JsonField = JsonMissing.of() - private var methodAttributes: JsonField = JsonMissing.of() - private var pendingAmount: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var settledAmount: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() - private var userDefinedId: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var descriptor: JsonField? = null + private var direction: JsonField? = null + private var events: JsonField>? = null + private var externalBankAccountToken: JsonField? = null + private var financialAccountToken: JsonField? = null + private var method: JsonField? = null + private var methodAttributes: JsonField? = null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var source: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var userDefinedId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(payment: Payment) = apply { @@ -274,7 +282,7 @@ private constructor( currency = payment.currency descriptor = payment.descriptor direction = payment.direction - events = payment.events + events = payment.events.map { it.toMutableList() } externalBankAccountToken = payment.externalBankAccountToken financialAccountToken = payment.financialAccountToken method = payment.method @@ -331,10 +339,24 @@ private constructor( fun events(events: List) = events(JsonField.of(events)) /** A list of all payment events that have modified this payment. */ - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } - fun externalBankAccountToken(externalBankAccountToken: String) = - externalBankAccountToken(JsonField.of(externalBankAccountToken)) + /** A list of all payment events that have modified this payment. */ + fun addEvent(event: PaymentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(event) + } + } + + fun externalBankAccountToken(externalBankAccountToken: String?) = + externalBankAccountToken(JsonField.ofNullable(externalBankAccountToken)) fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { this.externalBankAccountToken = externalBankAccountToken @@ -428,7 +450,8 @@ private constructor( /** Date and time when the financial transaction was last updated. UTC time zone. */ fun updated(updated: JsonField) = apply { this.updated = updated } - fun userDefinedId(userDefinedId: String) = userDefinedId(JsonField.of(userDefinedId)) + fun userDefinedId(userDefinedId: String?) = + userDefinedId(JsonField.ofNullable(userDefinedId)) fun userDefinedId(userDefinedId: JsonField) = apply { this.userDefinedId = userDefinedId @@ -455,24 +478,29 @@ private constructor( fun build(): Payment = Payment( - token, - category, - created, - currency, - descriptor, - direction, - events.map { it.toImmutable() }, - externalBankAccountToken, - financialAccountToken, - method, - methodAttributes, - pendingAmount, - result, - settledAmount, - source, - status, - updated, - userDefinedId, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(category) { "`category` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(descriptor) { "`descriptor` is required but was not set" }, + checkNotNull(direction) { "`direction` is required but was not set" }, + checkNotNull(events) { "`events` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(externalBankAccountToken) { + "`externalBankAccountToken` is required but was not set" + }, + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + checkNotNull(method) { "`method` is required but was not set" }, + checkNotNull(methodAttributes) { "`methodAttributes` is required but was not set" }, + checkNotNull(pendingAmount) { "`pendingAmount` is required but was not set" }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(settledAmount) { "`settledAmount` is required but was not set" }, + checkNotNull(source) { "`source` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, + checkNotNull(userDefinedId) { "`userDefinedId` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -653,22 +681,22 @@ private constructor( detailedResults.getNullable("detailed_results") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * Amount of the financial event that has been settled in the currency's smallest unit * (e.g., cents). */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** Date and time when the financial event occurred. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** * APPROVED financial events were successful while DECLINED financial events were declined * by user, Lithic, or the network. */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** * Event types: @@ -687,10 +715,12 @@ private constructor( * - `ACH_RECEIPT_SETTLED` - ACH receipt funds have settled. * - `ACH_RECEIPT_RELEASED` - ACH receipt released from pending to available balance. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** More detailed reasons for the event */ - @JsonProperty("detailed_results") @ExcludeMissing fun _detailedResults() = detailedResults + @JsonProperty("detailed_results") + @ExcludeMissing + fun _detailedResults(): JsonField> = detailedResults @JsonAnyGetter @ExcludeMissing @@ -719,12 +749,12 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var detailedResults: JsonField> = JsonMissing.of() + private var token: JsonField? = null + private var amount: JsonField? = null + private var created: JsonField? = null + private var result: JsonField? = null + private var type: JsonField? = null + private var detailedResults: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentEvent: PaymentEvent) = apply { @@ -733,7 +763,7 @@ private constructor( created = paymentEvent.created result = paymentEvent.result type = paymentEvent.type - detailedResults = paymentEvent.detailedResults + detailedResults = paymentEvent.detailedResults.map { it.toMutableList() } additionalProperties = paymentEvent.additionalProperties.toMutableMap() } @@ -819,7 +849,19 @@ private constructor( /** More detailed reasons for the event */ fun detailedResults(detailedResults: JsonField>) = apply { - this.detailedResults = detailedResults + this.detailedResults = detailedResults.map { it.toMutableList() } + } + + /** More detailed reasons for the event */ + fun addDetailedResult(detailedResult: DetailedResult) = apply { + detailedResults = + (detailedResults ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(detailedResult) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -843,12 +885,12 @@ private constructor( fun build(): PaymentEvent = PaymentEvent( - token, - amount, - created, - result, - type, - detailedResults.map { it.toImmutable() }, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + (detailedResults ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -1210,21 +1252,23 @@ private constructor( fun traceNumbers(): List = traceNumbers.getRequired("trace_numbers") - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId @JsonProperty("receipt_routing_number") @ExcludeMissing - fun _receiptRoutingNumber() = receiptRoutingNumber + fun _receiptRoutingNumber(): JsonField = receiptRoutingNumber - @JsonProperty("retries") @ExcludeMissing fun _retries() = retries + @JsonProperty("retries") @ExcludeMissing fun _retries(): JsonField = retries @JsonProperty("return_reason_code") @ExcludeMissing - fun _returnReasonCode() = returnReasonCode + fun _returnReasonCode(): JsonField = returnReasonCode - @JsonProperty("sec_code") @ExcludeMissing fun _secCode() = secCode + @JsonProperty("sec_code") @ExcludeMissing fun _secCode(): JsonField = secCode - @JsonProperty("trace_numbers") @ExcludeMissing fun _traceNumbers() = traceNumbers + @JsonProperty("trace_numbers") + @ExcludeMissing + fun _traceNumbers(): JsonField> = traceNumbers @JsonAnyGetter @ExcludeMissing @@ -1253,12 +1297,12 @@ private constructor( class Builder { - private var companyId: JsonField = JsonMissing.of() - private var receiptRoutingNumber: JsonField = JsonMissing.of() - private var retries: JsonField = JsonMissing.of() - private var returnReasonCode: JsonField = JsonMissing.of() - private var secCode: JsonField = JsonMissing.of() - private var traceNumbers: JsonField> = JsonMissing.of() + private var companyId: JsonField? = null + private var receiptRoutingNumber: JsonField? = null + private var retries: JsonField? = null + private var returnReasonCode: JsonField? = null + private var secCode: JsonField? = null + private var traceNumbers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentMethodAttributes: PaymentMethodAttributes) = apply { @@ -1267,27 +1311,29 @@ private constructor( retries = paymentMethodAttributes.retries returnReasonCode = paymentMethodAttributes.returnReasonCode secCode = paymentMethodAttributes.secCode - traceNumbers = paymentMethodAttributes.traceNumbers + traceNumbers = paymentMethodAttributes.traceNumbers.map { it.toMutableList() } additionalProperties = paymentMethodAttributes.additionalProperties.toMutableMap() } - fun companyId(companyId: String) = companyId(JsonField.of(companyId)) + fun companyId(companyId: String?) = companyId(JsonField.ofNullable(companyId)) fun companyId(companyId: JsonField) = apply { this.companyId = companyId } - fun receiptRoutingNumber(receiptRoutingNumber: String) = - receiptRoutingNumber(JsonField.of(receiptRoutingNumber)) + fun receiptRoutingNumber(receiptRoutingNumber: String?) = + receiptRoutingNumber(JsonField.ofNullable(receiptRoutingNumber)) fun receiptRoutingNumber(receiptRoutingNumber: JsonField) = apply { this.receiptRoutingNumber = receiptRoutingNumber } - fun retries(retries: Long) = retries(JsonField.of(retries)) + fun retries(retries: Long?) = retries(JsonField.ofNullable(retries)) + + fun retries(retries: Long) = retries(retries as Long?) fun retries(retries: JsonField) = apply { this.retries = retries } - fun returnReasonCode(returnReasonCode: String) = - returnReasonCode(JsonField.of(returnReasonCode)) + fun returnReasonCode(returnReasonCode: String?) = + returnReasonCode(JsonField.ofNullable(returnReasonCode)) fun returnReasonCode(returnReasonCode: JsonField) = apply { this.returnReasonCode = returnReasonCode @@ -1300,7 +1346,18 @@ private constructor( fun traceNumbers(traceNumbers: List) = traceNumbers(JsonField.of(traceNumbers)) fun traceNumbers(traceNumbers: JsonField>) = apply { - this.traceNumbers = traceNumbers + this.traceNumbers = traceNumbers.map { it.toMutableList() } + } + + fun addTraceNumber(traceNumber: String) = apply { + traceNumbers = + (traceNumbers ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(traceNumber) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -1324,12 +1381,17 @@ private constructor( fun build(): PaymentMethodAttributes = PaymentMethodAttributes( - companyId, - receiptRoutingNumber, - retries, - returnReasonCode, - secCode, - traceNumbers.map { it.toImmutable() }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkNotNull(receiptRoutingNumber) { + "`receiptRoutingNumber` is required but was not set" + }, + checkNotNull(retries) { "`retries` is required but was not set" }, + checkNotNull(returnReasonCode) { + "`returnReasonCode` is required but was not set" + }, + checkNotNull(secCode) { "`secCode` is required but was not set" }, + checkNotNull(traceNumbers) { "`traceNumbers` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentCreateParams.kt index aa7958d5..b33e9f52 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentCreateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -48,12 +49,34 @@ constructor( fun userDefinedId(): String? = body.userDefinedId() - fun _additionalHeaders(): Headers = additionalHeaders + fun _amount(): JsonField = body._amount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _externalBankAccountToken(): JsonField = body._externalBankAccountToken() + + fun _financialAccountToken(): JsonField = body._financialAccountToken() + + fun _method(): JsonField = body._method() + + fun _methodAttributes(): JsonField = body._methodAttributes() + + fun _type(): JsonField = body._type() + + /** + * Customer-provided token that will serve as an idempotency token. This token will become the + * transaction token. + */ + fun _token(): JsonField = body._token() + + fun _memo(): JsonField = body._memo() + + fun _userDefinedId(): JsonField = body._userDefinedId() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): PaymentCreateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -64,49 +87,111 @@ constructor( class PaymentCreateBody @JsonCreator internal constructor( - @JsonProperty("amount") private val amount: Long, - @JsonProperty("external_bank_account_token") private val externalBankAccountToken: String, - @JsonProperty("financial_account_token") private val financialAccountToken: String, - @JsonProperty("method") private val method: Method, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("external_bank_account_token") + @ExcludeMissing + private val externalBankAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + private val financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("method") + @ExcludeMissing + private val method: JsonField = JsonMissing.of(), @JsonProperty("method_attributes") - private val methodAttributes: PaymentMethodRequestAttributes, - @JsonProperty("type") private val type: Type, - @JsonProperty("token") private val token: String?, - @JsonProperty("memo") private val memo: String?, - @JsonProperty("user_defined_id") private val userDefinedId: String?, + @ExcludeMissing + private val methodAttributes: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("token") + @ExcludeMissing + private val token: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + private val userDefinedId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("amount") fun amount(): Long = amount + fun amount(): Long = amount.getRequired("amount") + + fun externalBankAccountToken(): String = + externalBankAccountToken.getRequired("external_bank_account_token") + + fun financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + fun method(): Method = method.getRequired("method") + + fun methodAttributes(): PaymentMethodRequestAttributes = + methodAttributes.getRequired("method_attributes") + + fun type(): Type = type.getRequired("type") + + /** + * Customer-provided token that will serve as an idempotency token. This token will become + * the transaction token. + */ + fun token(): String? = token.getNullable("token") + + fun memo(): String? = memo.getNullable("memo") + + fun userDefinedId(): String? = userDefinedId.getNullable("user_defined_id") + + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount @JsonProperty("external_bank_account_token") - fun externalBankAccountToken(): String = externalBankAccountToken + @ExcludeMissing + fun _externalBankAccountToken(): JsonField = externalBankAccountToken @JsonProperty("financial_account_token") - fun financialAccountToken(): String = financialAccountToken + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken - @JsonProperty("method") fun method(): Method = method + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method @JsonProperty("method_attributes") - fun methodAttributes(): PaymentMethodRequestAttributes = methodAttributes + @ExcludeMissing + fun _methodAttributes(): JsonField = methodAttributes - @JsonProperty("type") fun type(): Type = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Customer-provided token that will serve as an idempotency token. This token will become * the transaction token. */ - @JsonProperty("token") fun token(): String? = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - @JsonProperty("memo") fun memo(): String? = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - @JsonProperty("user_defined_id") fun userDefinedId(): String? = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PaymentCreateBody = apply { + if (!validated) { + amount() + externalBankAccountToken() + financialAccountToken() + method() + methodAttributes().validate() + type() + token() + memo() + userDefinedId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -116,15 +201,15 @@ constructor( class Builder { - private var amount: Long? = null - private var externalBankAccountToken: String? = null - private var financialAccountToken: String? = null - private var method: Method? = null - private var methodAttributes: PaymentMethodRequestAttributes? = null - private var type: Type? = null - private var token: String? = null - private var memo: String? = null - private var userDefinedId: String? = null + private var amount: JsonField? = null + private var externalBankAccountToken: JsonField? = null + private var financialAccountToken: JsonField? = null + private var method: JsonField? = null + private var methodAttributes: JsonField? = null + private var type: JsonField? = null + private var token: JsonField = JsonMissing.of() + private var memo: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentCreateBody: PaymentCreateBody) = apply { @@ -140,33 +225,61 @@ constructor( additionalProperties = paymentCreateBody.additionalProperties.toMutableMap() } - fun amount(amount: Long) = apply { this.amount = amount } + fun amount(amount: Long) = amount(JsonField.of(amount)) + + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun externalBankAccountToken(externalBankAccountToken: String) = + externalBankAccountToken(JsonField.of(externalBankAccountToken)) - fun externalBankAccountToken(externalBankAccountToken: String) = apply { + fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { this.externalBankAccountToken = externalBankAccountToken } - fun financialAccountToken(financialAccountToken: String) = apply { + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + fun financialAccountToken(financialAccountToken: JsonField) = apply { this.financialAccountToken = financialAccountToken } - fun method(method: Method) = apply { this.method = method } + fun method(method: Method) = method(JsonField.of(method)) - fun methodAttributes(methodAttributes: PaymentMethodRequestAttributes) = apply { - this.methodAttributes = methodAttributes - } + fun method(method: JsonField) = apply { this.method = method } + + fun methodAttributes(methodAttributes: PaymentMethodRequestAttributes) = + methodAttributes(JsonField.of(methodAttributes)) + + fun methodAttributes(methodAttributes: JsonField) = + apply { + this.methodAttributes = methodAttributes + } + + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } - fun type(type: Type) = apply { this.type = type } + /** + * Customer-provided token that will serve as an idempotency token. This token will + * become the transaction token. + */ + fun token(token: String) = token(JsonField.of(token)) /** * Customer-provided token that will serve as an idempotency token. This token will * become the transaction token. */ - fun token(token: String?) = apply { this.token = token } + fun token(token: JsonField) = apply { this.token = token } - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String) = memo(JsonField.of(memo)) - fun userDefinedId(userDefinedId: String?) = apply { this.userDefinedId = userDefinedId } + fun memo(memo: JsonField) = apply { this.memo = memo } + + fun userDefinedId(userDefinedId: String) = userDefinedId(JsonField.of(userDefinedId)) + + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -248,31 +361,80 @@ constructor( fun amount(amount: Long) = apply { body.amount(amount) } + fun amount(amount: JsonField) = apply { body.amount(amount) } + fun externalBankAccountToken(externalBankAccountToken: String) = apply { body.externalBankAccountToken(externalBankAccountToken) } + fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { + body.externalBankAccountToken(externalBankAccountToken) + } + fun financialAccountToken(financialAccountToken: String) = apply { body.financialAccountToken(financialAccountToken) } + fun financialAccountToken(financialAccountToken: JsonField) = apply { + body.financialAccountToken(financialAccountToken) + } + fun method(method: Method) = apply { body.method(method) } + fun method(method: JsonField) = apply { body.method(method) } + fun methodAttributes(methodAttributes: PaymentMethodRequestAttributes) = apply { body.methodAttributes(methodAttributes) } + fun methodAttributes(methodAttributes: JsonField) = apply { + body.methodAttributes(methodAttributes) + } + fun type(type: Type) = apply { body.type(type) } + fun type(type: JsonField) = apply { body.type(type) } + + /** + * Customer-provided token that will serve as an idempotency token. This token will become + * the transaction token. + */ + fun token(token: String) = apply { body.token(token) } + /** * Customer-provided token that will serve as an idempotency token. This token will become * the transaction token. */ - fun token(token: String?) = apply { body.token(token) } + fun token(token: JsonField) = apply { body.token(token) } + + fun memo(memo: String) = apply { body.memo(memo) } + + fun memo(memo: JsonField) = apply { body.memo(memo) } + + fun userDefinedId(userDefinedId: String) = apply { body.userDefinedId(userDefinedId) } + + fun userDefinedId(userDefinedId: JsonField) = apply { + body.userDefinedId(userDefinedId) + } + + 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 memo(memo: String?) = apply { body.memo(memo) } + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - fun userDefinedId(userDefinedId: String?) = apply { body.userDefinedId(userDefinedId) } + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -372,25 +534,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): PaymentCreateParams = PaymentCreateParams( body.build(), @@ -460,17 +603,30 @@ constructor( class PaymentMethodRequestAttributes @JsonCreator private constructor( - @JsonProperty("sec_code") private val secCode: SecCode, + @JsonProperty("sec_code") + @ExcludeMissing + private val secCode: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("sec_code") fun secCode(): SecCode = secCode + fun secCode(): SecCode = secCode.getRequired("sec_code") + + @JsonProperty("sec_code") @ExcludeMissing fun _secCode(): JsonField = secCode @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PaymentMethodRequestAttributes = apply { + if (!validated) { + secCode() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -480,7 +636,7 @@ constructor( class Builder { - private var secCode: SecCode? = null + private var secCode: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentMethodRequestAttributes: PaymentMethodRequestAttributes) = @@ -490,7 +646,9 @@ constructor( paymentMethodRequestAttributes.additionalProperties.toMutableMap() } - fun secCode(secCode: SecCode) = apply { this.secCode = secCode } + fun secCode(secCode: SecCode) = secCode(JsonField.of(secCode)) + + fun secCode(secCode: JsonField) = apply { this.secCode = secCode } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentCreateResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentCreateResponse.kt index 9889c155..56e83651 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentCreateResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentCreateResponse.kt @@ -147,55 +147,67 @@ private constructor( fun balance(): Balance? = balance.getNullable("balance") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Payment category */ - @JsonProperty("category") @ExcludeMissing fun _category() = category + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category /** Date and time when the payment first occurred. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** 3-digit alphabetic ISO 4217 code for the settling currency of the payment. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** A string that provides a description of the payment; may be useful to display to users. */ - @JsonProperty("descriptor") @ExcludeMissing fun _descriptor() = descriptor + @JsonProperty("descriptor") @ExcludeMissing fun _descriptor(): JsonField = descriptor - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction /** A list of all payment events that have modified this payment. */ - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events @JsonProperty("external_bank_account_token") @ExcludeMissing - fun _externalBankAccountToken() = externalBankAccountToken + fun _externalBankAccountToken(): JsonField = externalBankAccountToken @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken - @JsonProperty("method") @ExcludeMissing fun _method() = method + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method - @JsonProperty("method_attributes") @ExcludeMissing fun _methodAttributes() = methodAttributes + @JsonProperty("method_attributes") + @ExcludeMissing + fun _methodAttributes(): JsonField = methodAttributes /** * Pending amount of the payment in the currency's smallest unit (e.g., cents). The value of * this field will go to zero over time once the payment is settled. */ - @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount /** * APPROVED payments were successful while DECLINED payments were declined by Lithic or * returned. */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** * Amount of the payment that has been settled in the currency's smallest unit (e.g., cents). */ - @JsonProperty("settled_amount") @ExcludeMissing fun _settledAmount() = settledAmount + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount - @JsonProperty("source") @ExcludeMissing fun _source() = source + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source /** * Status types: @@ -205,15 +217,17 @@ private constructor( * - `RETURNED` - The payment has been returned. * - `SETTLED` - The payment is completed. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** Date and time when the financial transaction was last updated. UTC time zone. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated - @JsonProperty("user_defined_id") @ExcludeMissing fun _userDefinedId() = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId /** Balance */ - @JsonProperty("balance") @ExcludeMissing fun _balance() = balance + @JsonProperty("balance") @ExcludeMissing fun _balance(): JsonField = balance @JsonAnyGetter @ExcludeMissing @@ -277,24 +291,24 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var category: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var descriptor: JsonField = JsonMissing.of() - private var direction: JsonField = JsonMissing.of() - private var events: JsonField> = JsonMissing.of() - private var externalBankAccountToken: JsonField = JsonMissing.of() - private var financialAccountToken: JsonField = JsonMissing.of() - private var method: JsonField = JsonMissing.of() - private var methodAttributes: JsonField = JsonMissing.of() - private var pendingAmount: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var settledAmount: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() - private var userDefinedId: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var descriptor: JsonField? = null + private var direction: JsonField? = null + private var events: JsonField>? = null + private var externalBankAccountToken: JsonField? = null + private var financialAccountToken: JsonField? = null + private var method: JsonField? = null + private var methodAttributes: JsonField? = null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var source: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var userDefinedId: JsonField? = null private var balance: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -305,7 +319,7 @@ private constructor( currency = paymentCreateResponse.currency descriptor = paymentCreateResponse.descriptor direction = paymentCreateResponse.direction - events = paymentCreateResponse.events + events = paymentCreateResponse.events.map { it.toMutableList() } externalBankAccountToken = paymentCreateResponse.externalBankAccountToken financialAccountToken = paymentCreateResponse.financialAccountToken method = paymentCreateResponse.method @@ -365,10 +379,24 @@ private constructor( fun events(events: List) = events(JsonField.of(events)) /** A list of all payment events that have modified this payment. */ - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** A list of all payment events that have modified this payment. */ + fun addEvent(event: Payment.PaymentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(event) + } + } - fun externalBankAccountToken(externalBankAccountToken: String) = - externalBankAccountToken(JsonField.of(externalBankAccountToken)) + fun externalBankAccountToken(externalBankAccountToken: String?) = + externalBankAccountToken(JsonField.ofNullable(externalBankAccountToken)) fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { this.externalBankAccountToken = externalBankAccountToken @@ -462,7 +490,8 @@ private constructor( /** Date and time when the financial transaction was last updated. UTC time zone. */ fun updated(updated: JsonField) = apply { this.updated = updated } - fun userDefinedId(userDefinedId: String) = userDefinedId(JsonField.of(userDefinedId)) + fun userDefinedId(userDefinedId: String?) = + userDefinedId(JsonField.ofNullable(userDefinedId)) fun userDefinedId(userDefinedId: JsonField) = apply { this.userDefinedId = userDefinedId @@ -495,24 +524,29 @@ private constructor( fun build(): PaymentCreateResponse = PaymentCreateResponse( - token, - category, - created, - currency, - descriptor, - direction, - events.map { it.toImmutable() }, - externalBankAccountToken, - financialAccountToken, - method, - methodAttributes, - pendingAmount, - result, - settledAmount, - source, - status, - updated, - userDefinedId, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(category) { "`category` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(descriptor) { "`descriptor` is required but was not set" }, + checkNotNull(direction) { "`direction` is required but was not set" }, + checkNotNull(events) { "`events` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(externalBankAccountToken) { + "`externalBankAccountToken` is required but was not set" + }, + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + checkNotNull(method) { "`method` is required but was not set" }, + checkNotNull(methodAttributes) { "`methodAttributes` is required but was not set" }, + checkNotNull(pendingAmount) { "`pendingAmount` is required but was not set" }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(settledAmount) { "`settledAmount` is required but was not set" }, + checkNotNull(source) { "`source` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, + checkNotNull(userDefinedId) { "`userDefinedId` is required but was not set" }, balance, additionalProperties.toImmutable(), ) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentRetryResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentRetryResponse.kt index 91418121..60e89637 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentRetryResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentRetryResponse.kt @@ -147,55 +147,67 @@ private constructor( fun balance(): Balance? = balance.getNullable("balance") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Payment category */ - @JsonProperty("category") @ExcludeMissing fun _category() = category + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category /** Date and time when the payment first occurred. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** 3-digit alphabetic ISO 4217 code for the settling currency of the payment. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** A string that provides a description of the payment; may be useful to display to users. */ - @JsonProperty("descriptor") @ExcludeMissing fun _descriptor() = descriptor + @JsonProperty("descriptor") @ExcludeMissing fun _descriptor(): JsonField = descriptor - @JsonProperty("direction") @ExcludeMissing fun _direction() = direction + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction /** A list of all payment events that have modified this payment. */ - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events @JsonProperty("external_bank_account_token") @ExcludeMissing - fun _externalBankAccountToken() = externalBankAccountToken + fun _externalBankAccountToken(): JsonField = externalBankAccountToken @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken - @JsonProperty("method") @ExcludeMissing fun _method() = method + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method - @JsonProperty("method_attributes") @ExcludeMissing fun _methodAttributes() = methodAttributes + @JsonProperty("method_attributes") + @ExcludeMissing + fun _methodAttributes(): JsonField = methodAttributes /** * Pending amount of the payment in the currency's smallest unit (e.g., cents). The value of * this field will go to zero over time once the payment is settled. */ - @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount /** * APPROVED payments were successful while DECLINED payments were declined by Lithic or * returned. */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** * Amount of the payment that has been settled in the currency's smallest unit (e.g., cents). */ - @JsonProperty("settled_amount") @ExcludeMissing fun _settledAmount() = settledAmount + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount - @JsonProperty("source") @ExcludeMissing fun _source() = source + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source /** * Status types: @@ -205,15 +217,17 @@ private constructor( * - `RETURNED` - The payment has been returned. * - `SETTLED` - The payment is completed. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** Date and time when the financial transaction was last updated. UTC time zone. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated - @JsonProperty("user_defined_id") @ExcludeMissing fun _userDefinedId() = userDefinedId + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId /** Balance */ - @JsonProperty("balance") @ExcludeMissing fun _balance() = balance + @JsonProperty("balance") @ExcludeMissing fun _balance(): JsonField = balance @JsonAnyGetter @ExcludeMissing @@ -277,24 +291,24 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var category: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var descriptor: JsonField = JsonMissing.of() - private var direction: JsonField = JsonMissing.of() - private var events: JsonField> = JsonMissing.of() - private var externalBankAccountToken: JsonField = JsonMissing.of() - private var financialAccountToken: JsonField = JsonMissing.of() - private var method: JsonField = JsonMissing.of() - private var methodAttributes: JsonField = JsonMissing.of() - private var pendingAmount: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var settledAmount: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() - private var userDefinedId: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var descriptor: JsonField? = null + private var direction: JsonField? = null + private var events: JsonField>? = null + private var externalBankAccountToken: JsonField? = null + private var financialAccountToken: JsonField? = null + private var method: JsonField? = null + private var methodAttributes: JsonField? = null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var source: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var userDefinedId: JsonField? = null private var balance: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -305,7 +319,7 @@ private constructor( currency = paymentRetryResponse.currency descriptor = paymentRetryResponse.descriptor direction = paymentRetryResponse.direction - events = paymentRetryResponse.events + events = paymentRetryResponse.events.map { it.toMutableList() } externalBankAccountToken = paymentRetryResponse.externalBankAccountToken financialAccountToken = paymentRetryResponse.financialAccountToken method = paymentRetryResponse.method @@ -365,10 +379,24 @@ private constructor( fun events(events: List) = events(JsonField.of(events)) /** A list of all payment events that have modified this payment. */ - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** A list of all payment events that have modified this payment. */ + fun addEvent(event: Payment.PaymentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(event) + } + } - fun externalBankAccountToken(externalBankAccountToken: String) = - externalBankAccountToken(JsonField.of(externalBankAccountToken)) + fun externalBankAccountToken(externalBankAccountToken: String?) = + externalBankAccountToken(JsonField.ofNullable(externalBankAccountToken)) fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { this.externalBankAccountToken = externalBankAccountToken @@ -462,7 +490,8 @@ private constructor( /** Date and time when the financial transaction was last updated. UTC time zone. */ fun updated(updated: JsonField) = apply { this.updated = updated } - fun userDefinedId(userDefinedId: String) = userDefinedId(JsonField.of(userDefinedId)) + fun userDefinedId(userDefinedId: String?) = + userDefinedId(JsonField.ofNullable(userDefinedId)) fun userDefinedId(userDefinedId: JsonField) = apply { this.userDefinedId = userDefinedId @@ -495,24 +524,29 @@ private constructor( fun build(): PaymentRetryResponse = PaymentRetryResponse( - token, - category, - created, - currency, - descriptor, - direction, - events.map { it.toImmutable() }, - externalBankAccountToken, - financialAccountToken, - method, - methodAttributes, - pendingAmount, - result, - settledAmount, - source, - status, - updated, - userDefinedId, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(category) { "`category` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(descriptor) { "`descriptor` is required but was not set" }, + checkNotNull(direction) { "`direction` is required but was not set" }, + checkNotNull(events) { "`events` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(externalBankAccountToken) { + "`externalBankAccountToken` is required but was not set" + }, + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + checkNotNull(method) { "`method` is required but was not set" }, + checkNotNull(methodAttributes) { "`methodAttributes` is required but was not set" }, + checkNotNull(pendingAmount) { "`pendingAmount` is required but was not set" }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(settledAmount) { "`settledAmount` is required but was not set" }, + checkNotNull(source) { "`source` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, + checkNotNull(userDefinedId) { "`userDefinedId` is required but was not set" }, balance, additionalProperties.toImmutable(), ) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateActionParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateActionParams.kt index 0f1d855c..3ad18064 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateActionParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateActionParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -38,12 +39,21 @@ constructor( /** Return Reason Code */ fun returnReasonCode(): String? = body.returnReasonCode() - fun _additionalHeaders(): Headers = additionalHeaders + /** Event Type */ + fun _eventType(): JsonField = body._eventType() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Decline reason */ + fun _declineReason(): JsonField = body._declineReason() + + /** Return Reason Code */ + fun _returnReasonCode(): JsonField = body._returnReasonCode() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): PaymentSimulateActionBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -61,28 +71,59 @@ constructor( class PaymentSimulateActionBody @JsonCreator internal constructor( - @JsonProperty("event_type") private val eventType: SupportedSimulationTypes, + @JsonProperty("event_type") + @ExcludeMissing + private val eventType: JsonField = JsonMissing.of(), @JsonProperty("decline_reason") - private val declineReason: SupportedSimulationDeclineReasons?, - @JsonProperty("return_reason_code") private val returnReasonCode: String?, + @ExcludeMissing + private val declineReason: JsonField = JsonMissing.of(), + @JsonProperty("return_reason_code") + @ExcludeMissing + private val returnReasonCode: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Event Type */ - @JsonProperty("event_type") fun eventType(): SupportedSimulationTypes = eventType + fun eventType(): SupportedSimulationTypes = eventType.getRequired("event_type") + + /** Decline reason */ + fun declineReason(): SupportedSimulationDeclineReasons? = + declineReason.getNullable("decline_reason") + + /** Return Reason Code */ + fun returnReasonCode(): String? = returnReasonCode.getNullable("return_reason_code") + + /** Event Type */ + @JsonProperty("event_type") + @ExcludeMissing + fun _eventType(): JsonField = eventType /** Decline reason */ @JsonProperty("decline_reason") - fun declineReason(): SupportedSimulationDeclineReasons? = declineReason + @ExcludeMissing + fun _declineReason(): JsonField = declineReason /** Return Reason Code */ - @JsonProperty("return_reason_code") fun returnReasonCode(): String? = returnReasonCode + @JsonProperty("return_reason_code") + @ExcludeMissing + fun _returnReasonCode(): JsonField = returnReasonCode @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PaymentSimulateActionBody = apply { + if (!validated) { + eventType() + declineReason() + returnReasonCode() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -92,9 +133,10 @@ constructor( class Builder { - private var eventType: SupportedSimulationTypes? = null - private var declineReason: SupportedSimulationDeclineReasons? = null - private var returnReasonCode: String? = null + private var eventType: JsonField? = null + private var declineReason: JsonField = + JsonMissing.of() + private var returnReasonCode: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentSimulateActionBody: PaymentSimulateActionBody) = apply { @@ -105,17 +147,28 @@ constructor( } /** Event Type */ - fun eventType(eventType: SupportedSimulationTypes) = apply { + fun eventType(eventType: SupportedSimulationTypes) = eventType(JsonField.of(eventType)) + + /** Event Type */ + fun eventType(eventType: JsonField) = apply { this.eventType = eventType } /** Decline reason */ - fun declineReason(declineReason: SupportedSimulationDeclineReasons?) = apply { + fun declineReason(declineReason: SupportedSimulationDeclineReasons) = + declineReason(JsonField.of(declineReason)) + + /** Decline reason */ + fun declineReason(declineReason: JsonField) = apply { this.declineReason = declineReason } /** Return Reason Code */ - fun returnReasonCode(returnReasonCode: String?) = apply { + fun returnReasonCode(returnReasonCode: String) = + returnReasonCode(JsonField.of(returnReasonCode)) + + /** Return Reason Code */ + fun returnReasonCode(returnReasonCode: JsonField) = apply { this.returnReasonCode = returnReasonCode } @@ -192,16 +245,50 @@ constructor( /** Event Type */ fun eventType(eventType: SupportedSimulationTypes) = apply { body.eventType(eventType) } + /** Event Type */ + fun eventType(eventType: JsonField) = apply { + body.eventType(eventType) + } + + /** Decline reason */ + fun declineReason(declineReason: SupportedSimulationDeclineReasons) = apply { + body.declineReason(declineReason) + } + /** Decline reason */ - fun declineReason(declineReason: SupportedSimulationDeclineReasons?) = apply { + fun declineReason(declineReason: JsonField) = apply { body.declineReason(declineReason) } /** Return Reason Code */ - fun returnReasonCode(returnReasonCode: String?) = apply { + fun returnReasonCode(returnReasonCode: String) = apply { body.returnReasonCode(returnReasonCode) } + /** Return Reason Code */ + fun returnReasonCode(returnReasonCode: JsonField) = apply { + body.returnReasonCode(returnReasonCode) + } + + 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) @@ -300,25 +387,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): PaymentSimulateActionParams = PaymentSimulateActionParams( checkNotNull(paymentToken) { "`paymentToken` is required but was not set" }, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateActionResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateActionResponse.kt index 5ba55c07..b4d5e968 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateActionResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateActionResponse.kt @@ -46,15 +46,15 @@ private constructor( /** Debugging Request Id */ @JsonProperty("debugging_request_id") @ExcludeMissing - fun _debuggingRequestId() = debuggingRequestId + fun _debuggingRequestId(): JsonField = debuggingRequestId /** Request Result */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** Transaction Event Token */ @JsonProperty("transaction_event_token") @ExcludeMissing - fun _transactionEventToken() = transactionEventToken + fun _transactionEventToken(): JsonField = transactionEventToken @JsonAnyGetter @ExcludeMissing @@ -80,9 +80,9 @@ private constructor( class Builder { - private var debuggingRequestId: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var transactionEventToken: JsonField = JsonMissing.of() + private var debuggingRequestId: JsonField? = null + private var result: JsonField? = null + private var transactionEventToken: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentSimulateActionResponse: PaymentSimulateActionResponse) = apply { @@ -137,9 +137,13 @@ private constructor( fun build(): PaymentSimulateActionResponse = PaymentSimulateActionResponse( - debuggingRequestId, - result, - transactionEventToken, + checkNotNull(debuggingRequestId) { + "`debuggingRequestId` is required but was not set" + }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(transactionEventToken) { + "`transactionEventToken` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReceiptParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReceiptParams.kt index 5ededf73..0e0e00ae 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReceiptParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReceiptParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -41,12 +42,27 @@ constructor( /** Memo */ fun memo(): String? = body.memo() - fun _additionalHeaders(): Headers = additionalHeaders + /** Payment token */ + fun _token(): JsonField = body._token() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Amount */ + fun _amount(): JsonField = body._amount() + + /** Financial Account Token */ + fun _financialAccountToken(): JsonField = body._financialAccountToken() + + /** Receipt Type */ + fun _receiptType(): JsonField = body._receiptType() + + /** Memo */ + fun _memo(): JsonField = body._memo() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): PaymentSimulateReceiptBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -57,35 +73,77 @@ constructor( class PaymentSimulateReceiptBody @JsonCreator internal constructor( - @JsonProperty("token") private val token: String, - @JsonProperty("amount") private val amount: Long, - @JsonProperty("financial_account_token") private val financialAccountToken: String, - @JsonProperty("receipt_type") private val receiptType: ReceiptType, - @JsonProperty("memo") private val memo: String?, + @JsonProperty("token") + @ExcludeMissing + private val token: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + private val financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("receipt_type") + @ExcludeMissing + private val receiptType: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Payment token */ - @JsonProperty("token") fun token(): String = token + fun token(): String = token.getRequired("token") /** Amount */ - @JsonProperty("amount") fun amount(): Long = amount + fun amount(): Long = amount.getRequired("amount") + + /** Financial Account Token */ + fun financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + /** Receipt Type */ + fun receiptType(): ReceiptType = receiptType.getRequired("receipt_type") + + /** Memo */ + fun memo(): String? = memo.getNullable("memo") + + /** Payment token */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** Amount */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** Financial Account Token */ @JsonProperty("financial_account_token") - fun financialAccountToken(): String = financialAccountToken + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken /** Receipt Type */ - @JsonProperty("receipt_type") fun receiptType(): ReceiptType = receiptType + @JsonProperty("receipt_type") + @ExcludeMissing + fun _receiptType(): JsonField = receiptType /** Memo */ - @JsonProperty("memo") fun memo(): String? = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PaymentSimulateReceiptBody = apply { + if (!validated) { + token() + amount() + financialAccountToken() + receiptType() + memo() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -95,11 +153,11 @@ constructor( class Builder { - private var token: String? = null - private var amount: Long? = null - private var financialAccountToken: String? = null - private var receiptType: ReceiptType? = null - private var memo: String? = null + private var token: JsonField? = null + private var amount: JsonField? = null + private var financialAccountToken: JsonField? = null + private var receiptType: JsonField? = null + private var memo: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentSimulateReceiptBody: PaymentSimulateReceiptBody) = apply { @@ -113,21 +171,39 @@ constructor( } /** Payment token */ - fun token(token: String) = apply { this.token = token } + fun token(token: String) = token(JsonField.of(token)) + + /** Payment token */ + fun token(token: JsonField) = apply { this.token = token } + + /** Amount */ + fun amount(amount: Long) = amount(JsonField.of(amount)) /** Amount */ - fun amount(amount: Long) = apply { this.amount = amount } + fun amount(amount: JsonField) = apply { this.amount = amount } /** Financial Account Token */ - fun financialAccountToken(financialAccountToken: String) = apply { + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** Financial Account Token */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { this.financialAccountToken = financialAccountToken } /** Receipt Type */ - fun receiptType(receiptType: ReceiptType) = apply { this.receiptType = receiptType } + fun receiptType(receiptType: ReceiptType) = receiptType(JsonField.of(receiptType)) + + /** Receipt Type */ + fun receiptType(receiptType: JsonField) = apply { + this.receiptType = receiptType + } + + /** Memo */ + fun memo(memo: String) = memo(JsonField.of(memo)) /** Memo */ - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: JsonField) = apply { this.memo = memo } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -202,19 +278,57 @@ constructor( /** Payment token */ fun token(token: String) = apply { body.token(token) } + /** Payment token */ + fun token(token: JsonField) = apply { body.token(token) } + /** Amount */ fun amount(amount: Long) = apply { body.amount(amount) } + /** Amount */ + fun amount(amount: JsonField) = apply { body.amount(amount) } + /** Financial Account Token */ fun financialAccountToken(financialAccountToken: String) = apply { body.financialAccountToken(financialAccountToken) } + /** Financial Account Token */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + body.financialAccountToken(financialAccountToken) + } + /** Receipt Type */ fun receiptType(receiptType: ReceiptType) = apply { body.receiptType(receiptType) } + /** Receipt Type */ + fun receiptType(receiptType: JsonField) = apply { + body.receiptType(receiptType) + } + + /** Memo */ + fun memo(memo: String) = apply { body.memo(memo) } + /** Memo */ - fun memo(memo: String?) = apply { body.memo(memo) } + fun memo(memo: JsonField) = apply { body.memo(memo) } + + 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() @@ -314,25 +428,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): PaymentSimulateReceiptParams = PaymentSimulateReceiptParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReceiptResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReceiptResponse.kt index 78896344..bc6e7bd6 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReceiptResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReceiptResponse.kt @@ -46,15 +46,15 @@ private constructor( /** Debugging Request Id */ @JsonProperty("debugging_request_id") @ExcludeMissing - fun _debuggingRequestId() = debuggingRequestId + fun _debuggingRequestId(): JsonField = debuggingRequestId /** Request Result */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** Transaction Event Token */ @JsonProperty("transaction_event_token") @ExcludeMissing - fun _transactionEventToken() = transactionEventToken + fun _transactionEventToken(): JsonField = transactionEventToken @JsonAnyGetter @ExcludeMissing @@ -80,9 +80,9 @@ private constructor( class Builder { - private var debuggingRequestId: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var transactionEventToken: JsonField = JsonMissing.of() + private var debuggingRequestId: JsonField? = null + private var result: JsonField? = null + private var transactionEventToken: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentSimulateReceiptResponse: PaymentSimulateReceiptResponse) = apply { @@ -138,9 +138,13 @@ private constructor( fun build(): PaymentSimulateReceiptResponse = PaymentSimulateReceiptResponse( - debuggingRequestId, - result, - transactionEventToken, + checkNotNull(debuggingRequestId) { + "`debuggingRequestId` is required but was not set" + }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(transactionEventToken) { + "`transactionEventToken` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReleaseParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReleaseParams.kt index de961a24..69c3fde6 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReleaseParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReleaseParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -26,12 +28,15 @@ constructor( /** Payment Token */ fun paymentToken(): String = body.paymentToken() + /** Payment Token */ + fun _paymentToken(): JsonField = body._paymentToken() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): PaymentSimulateReleaseBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -42,18 +47,34 @@ constructor( class PaymentSimulateReleaseBody @JsonCreator internal constructor( - @JsonProperty("payment_token") private val paymentToken: String, + @JsonProperty("payment_token") + @ExcludeMissing + private val paymentToken: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Payment Token */ - @JsonProperty("payment_token") fun paymentToken(): String = paymentToken + fun paymentToken(): String = paymentToken.getRequired("payment_token") + + /** Payment Token */ + @JsonProperty("payment_token") + @ExcludeMissing + fun _paymentToken(): JsonField = paymentToken @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PaymentSimulateReleaseBody = apply { + if (!validated) { + paymentToken() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -63,7 +84,7 @@ constructor( class Builder { - private var paymentToken: String? = null + private var paymentToken: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentSimulateReleaseBody: PaymentSimulateReleaseBody) = apply { @@ -73,7 +94,12 @@ constructor( } /** Payment Token */ - fun paymentToken(paymentToken: String) = apply { this.paymentToken = paymentToken } + fun paymentToken(paymentToken: String) = paymentToken(JsonField.of(paymentToken)) + + /** Payment Token */ + fun paymentToken(paymentToken: JsonField) = apply { + this.paymentToken = paymentToken + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -142,6 +168,30 @@ constructor( /** Payment Token */ fun paymentToken(paymentToken: String) = apply { body.paymentToken(paymentToken) } + /** Payment Token */ + fun paymentToken(paymentToken: JsonField) = apply { + body.paymentToken(paymentToken) + } + + 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) @@ -240,25 +290,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): PaymentSimulateReleaseParams = PaymentSimulateReleaseParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReleaseResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReleaseResponse.kt index 24159b4a..ba2960f0 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReleaseResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReleaseResponse.kt @@ -46,15 +46,15 @@ private constructor( /** Debugging Request Id */ @JsonProperty("debugging_request_id") @ExcludeMissing - fun _debuggingRequestId() = debuggingRequestId + fun _debuggingRequestId(): JsonField = debuggingRequestId /** Request Result */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** Transaction Event Token */ @JsonProperty("transaction_event_token") @ExcludeMissing - fun _transactionEventToken() = transactionEventToken + fun _transactionEventToken(): JsonField = transactionEventToken @JsonAnyGetter @ExcludeMissing @@ -80,9 +80,9 @@ private constructor( class Builder { - private var debuggingRequestId: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var transactionEventToken: JsonField = JsonMissing.of() + private var debuggingRequestId: JsonField? = null + private var result: JsonField? = null + private var transactionEventToken: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentSimulateReleaseResponse: PaymentSimulateReleaseResponse) = apply { @@ -138,9 +138,13 @@ private constructor( fun build(): PaymentSimulateReleaseResponse = PaymentSimulateReleaseResponse( - debuggingRequestId, - result, - transactionEventToken, + checkNotNull(debuggingRequestId) { + "`debuggingRequestId` is required but was not set" + }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(transactionEventToken) { + "`transactionEventToken` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReturnParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReturnParams.kt index 1741f602..784d4288 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReturnParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReturnParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -29,12 +31,18 @@ constructor( /** Return Reason Code */ fun returnReasonCode(): String? = body.returnReasonCode() - fun _additionalHeaders(): Headers = additionalHeaders + /** Payment Token */ + fun _paymentToken(): JsonField = body._paymentToken() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Return Reason Code */ + fun _returnReasonCode(): JsonField = body._returnReasonCode() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): PaymentSimulateReturnBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -45,22 +53,46 @@ constructor( class PaymentSimulateReturnBody @JsonCreator internal constructor( - @JsonProperty("payment_token") private val paymentToken: String, - @JsonProperty("return_reason_code") private val returnReasonCode: String?, + @JsonProperty("payment_token") + @ExcludeMissing + private val paymentToken: JsonField = JsonMissing.of(), + @JsonProperty("return_reason_code") + @ExcludeMissing + private val returnReasonCode: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Payment Token */ - @JsonProperty("payment_token") fun paymentToken(): String = paymentToken + fun paymentToken(): String = paymentToken.getRequired("payment_token") /** Return Reason Code */ - @JsonProperty("return_reason_code") fun returnReasonCode(): String? = returnReasonCode + fun returnReasonCode(): String? = returnReasonCode.getNullable("return_reason_code") + + /** Payment Token */ + @JsonProperty("payment_token") + @ExcludeMissing + fun _paymentToken(): JsonField = paymentToken + + /** Return Reason Code */ + @JsonProperty("return_reason_code") + @ExcludeMissing + fun _returnReasonCode(): JsonField = returnReasonCode @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PaymentSimulateReturnBody = apply { + if (!validated) { + paymentToken() + returnReasonCode() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -70,8 +102,8 @@ constructor( class Builder { - private var paymentToken: String? = null - private var returnReasonCode: String? = null + private var paymentToken: JsonField? = null + private var returnReasonCode: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentSimulateReturnBody: PaymentSimulateReturnBody) = apply { @@ -81,10 +113,19 @@ constructor( } /** Payment Token */ - fun paymentToken(paymentToken: String) = apply { this.paymentToken = paymentToken } + fun paymentToken(paymentToken: String) = paymentToken(JsonField.of(paymentToken)) + + /** Payment Token */ + fun paymentToken(paymentToken: JsonField) = apply { + this.paymentToken = paymentToken + } /** Return Reason Code */ - fun returnReasonCode(returnReasonCode: String?) = apply { + fun returnReasonCode(returnReasonCode: String) = + returnReasonCode(JsonField.of(returnReasonCode)) + + /** Return Reason Code */ + fun returnReasonCode(returnReasonCode: JsonField) = apply { this.returnReasonCode = returnReasonCode } @@ -156,11 +197,40 @@ constructor( /** Payment Token */ fun paymentToken(paymentToken: String) = apply { body.paymentToken(paymentToken) } + /** Payment Token */ + fun paymentToken(paymentToken: JsonField) = apply { + body.paymentToken(paymentToken) + } + + /** Return Reason Code */ + fun returnReasonCode(returnReasonCode: String) = apply { + body.returnReasonCode(returnReasonCode) + } + /** Return Reason Code */ - fun returnReasonCode(returnReasonCode: String?) = apply { + fun returnReasonCode(returnReasonCode: JsonField) = apply { body.returnReasonCode(returnReasonCode) } + 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) @@ -259,25 +329,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): PaymentSimulateReturnParams = PaymentSimulateReturnParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReturnResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReturnResponse.kt index 01dbd8a0..b02e18d7 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReturnResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateReturnResponse.kt @@ -46,15 +46,15 @@ private constructor( /** Debugging Request Id */ @JsonProperty("debugging_request_id") @ExcludeMissing - fun _debuggingRequestId() = debuggingRequestId + fun _debuggingRequestId(): JsonField = debuggingRequestId /** Request Result */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** Transaction Event Token */ @JsonProperty("transaction_event_token") @ExcludeMissing - fun _transactionEventToken() = transactionEventToken + fun _transactionEventToken(): JsonField = transactionEventToken @JsonAnyGetter @ExcludeMissing @@ -80,9 +80,9 @@ private constructor( class Builder { - private var debuggingRequestId: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var transactionEventToken: JsonField = JsonMissing.of() + private var debuggingRequestId: JsonField? = null + private var result: JsonField? = null + private var transactionEventToken: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentSimulateReturnResponse: PaymentSimulateReturnResponse) = apply { @@ -137,9 +137,13 @@ private constructor( fun build(): PaymentSimulateReturnResponse = PaymentSimulateReturnResponse( - debuggingRequestId, - result, - transactionEventToken, + checkNotNull(debuggingRequestId) { + "`debuggingRequestId` is required but was not set" + }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(transactionEventToken) { + "`transactionEventToken` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PrimeRateRetrieveResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PrimeRateRetrieveResponse.kt index f22590e0..c1cc0378 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PrimeRateRetrieveResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PrimeRateRetrieveResponse.kt @@ -36,10 +36,10 @@ private constructor( fun hasMore(): Boolean = hasMore.getRequired("has_more") /** List of prime rates */ - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data /** Whether there are more prime rates */ - @JsonProperty("has_more") @ExcludeMissing fun _hasMore() = hasMore + @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore @JsonAnyGetter @ExcludeMissing @@ -64,12 +64,12 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() - private var hasMore: JsonField = JsonMissing.of() + private var data: JsonField>? = null + private var hasMore: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(primeRateRetrieveResponse: PrimeRateRetrieveResponse) = apply { - data = primeRateRetrieveResponse.data + data = primeRateRetrieveResponse.data.map { it.toMutableList() } hasMore = primeRateRetrieveResponse.hasMore additionalProperties = primeRateRetrieveResponse.additionalProperties.toMutableMap() } @@ -78,7 +78,21 @@ private constructor( fun data(data: List) = data(JsonField.of(data)) /** List of prime rates */ - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** List of prime rates */ + fun addData(data: InterestRate) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(data) + } + } /** Whether there are more prime rates */ fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) @@ -107,8 +121,9 @@ private constructor( fun build(): PrimeRateRetrieveResponse = PrimeRateRetrieveResponse( - data.map { it.toImmutable() }, - hasMore, + checkNotNull(data) { "`data` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(hasMore) { "`hasMore` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -134,10 +149,12 @@ private constructor( fun rate(): String = rate.getRequired("rate") /** Date the rate goes into effect */ - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate /** The rate in decimal format */ - @JsonProperty("rate") @ExcludeMissing fun _rate() = rate + @JsonProperty("rate") @ExcludeMissing fun _rate(): JsonField = rate @JsonAnyGetter @ExcludeMissing @@ -162,8 +179,8 @@ private constructor( class Builder { - private var effectiveDate: JsonField = JsonMissing.of() - private var rate: JsonField = JsonMissing.of() + private var effectiveDate: JsonField? = null + private var rate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(interestRate: InterestRate) = apply { @@ -207,8 +224,8 @@ private constructor( fun build(): InterestRate = InterestRate( - effectiveDate, - rate, + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + checkNotNull(rate) { "`rate` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/RequiredDocument.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/RequiredDocument.kt index d9beb638..6fb577ca 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/RequiredDocument.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/RequiredDocument.kt @@ -45,17 +45,23 @@ private constructor( fun validDocuments(): List = validDocuments.getRequired("valid_documents") /** Globally unique identifier for an entity. */ - @JsonProperty("entity_token") @ExcludeMissing fun _entityToken() = entityToken + @JsonProperty("entity_token") + @ExcludeMissing + fun _entityToken(): JsonField = entityToken /** * rovides the status reasons that will be satisfied by providing one of the valid documents. */ - @JsonProperty("status_reasons") @ExcludeMissing fun _statusReasons() = statusReasons + @JsonProperty("status_reasons") + @ExcludeMissing + fun _statusReasons(): JsonField> = statusReasons /** * A list of valid documents that will satisfy the KYC requirements for the specified entity. */ - @JsonProperty("valid_documents") @ExcludeMissing fun _validDocuments() = validDocuments + @JsonProperty("valid_documents") + @ExcludeMissing + fun _validDocuments(): JsonField> = validDocuments @JsonAnyGetter @ExcludeMissing @@ -81,15 +87,15 @@ private constructor( class Builder { - private var entityToken: JsonField = JsonMissing.of() - private var statusReasons: JsonField> = JsonMissing.of() - private var validDocuments: JsonField> = JsonMissing.of() + private var entityToken: JsonField? = null + private var statusReasons: JsonField>? = null + private var validDocuments: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(requiredDocument: RequiredDocument) = apply { entityToken = requiredDocument.entityToken - statusReasons = requiredDocument.statusReasons - validDocuments = requiredDocument.validDocuments + statusReasons = requiredDocument.statusReasons.map { it.toMutableList() } + validDocuments = requiredDocument.validDocuments.map { it.toMutableList() } additionalProperties = requiredDocument.additionalProperties.toMutableMap() } @@ -110,7 +116,22 @@ private constructor( * documents. */ fun statusReasons(statusReasons: JsonField>) = apply { - this.statusReasons = statusReasons + this.statusReasons = statusReasons.map { it.toMutableList() } + } + + /** + * rovides the status reasons that will be satisfied by providing one of the valid + * documents. + */ + fun addStatusReason(statusReason: String) = apply { + statusReasons = + (statusReasons ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(statusReason) + } } /** @@ -125,7 +146,22 @@ private constructor( * entity. */ fun validDocuments(validDocuments: JsonField>) = apply { - this.validDocuments = validDocuments + this.validDocuments = validDocuments.map { it.toMutableList() } + } + + /** + * A list of valid documents that will satisfy the KYC requirements for the specified + * entity. + */ + fun addValidDocument(validDocument: String) = apply { + validDocuments = + (validDocuments ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(validDocument) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -149,9 +185,11 @@ private constructor( fun build(): RequiredDocument = RequiredDocument( - entityToken, - statusReasons.map { it.toImmutable() }, - validDocuments.map { it.toImmutable() }, + checkNotNull(entityToken) { "`entityToken` is required but was not set" }, + checkNotNull(statusReasons) { "`statusReasons` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(validDocuments) { "`validDocuments` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ResponderEndpointCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ResponderEndpointCreateParams.kt index edcf5e56..f6f1cf13 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ResponderEndpointCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ResponderEndpointCreateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -32,12 +33,18 @@ constructor( /** The URL for the responder endpoint (must be http(s)). */ fun url(): String? = body.url() - fun _additionalHeaders(): Headers = additionalHeaders + /** The type of the endpoint. */ + fun _type(): JsonField = body._type() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The URL for the responder endpoint (must be http(s)). */ + fun _url(): JsonField = body._url() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): ResponderEndpointCreateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -48,22 +55,38 @@ constructor( class ResponderEndpointCreateBody @JsonCreator internal constructor( - @JsonProperty("type") private val type: Type?, - @JsonProperty("url") private val url: String?, + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing private val url: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The type of the endpoint. */ - @JsonProperty("type") fun type(): Type? = type + fun type(): Type? = type.getNullable("type") /** The URL for the responder endpoint (must be http(s)). */ - @JsonProperty("url") fun url(): String? = url + fun url(): String? = url.getNullable("url") + + /** The type of the endpoint. */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** The URL for the responder endpoint (must be http(s)). */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ResponderEndpointCreateBody = apply { + if (!validated) { + type() + url() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -73,8 +96,8 @@ constructor( class Builder { - private var type: Type? = null - private var url: String? = null + private var type: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(responderEndpointCreateBody: ResponderEndpointCreateBody) = apply { @@ -85,10 +108,16 @@ constructor( } /** The type of the endpoint. */ - fun type(type: Type?) = apply { this.type = type } + fun type(type: Type) = type(JsonField.of(type)) + + /** The type of the endpoint. */ + fun type(type: JsonField) = apply { this.type = type } + + /** The URL for the responder endpoint (must be http(s)). */ + fun url(url: String) = url(JsonField.of(url)) /** The URL for the responder endpoint (must be http(s)). */ - fun url(url: String?) = apply { this.url = url } + fun url(url: JsonField) = apply { this.url = url } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -157,10 +186,35 @@ constructor( } /** The type of the endpoint. */ - fun type(type: Type?) = apply { body.type(type) } + fun type(type: Type) = apply { body.type(type) } + + /** The type of the endpoint. */ + fun type(type: JsonField) = apply { body.type(type) } + + /** The URL for the responder endpoint (must be http(s)). */ + fun url(url: String) = apply { body.url(url) } /** The URL for the responder endpoint (must be http(s)). */ - fun url(url: String?) = apply { body.url(url) } + fun url(url: JsonField) = apply { body.url(url) } + + 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() @@ -260,25 +314,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ResponderEndpointCreateParams = ResponderEndpointCreateParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ResponderEndpointCreateResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ResponderEndpointCreateResponse.kt index 22c949d9..1a3f1fb7 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ResponderEndpointCreateResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ResponderEndpointCreateResponse.kt @@ -29,7 +29,7 @@ private constructor( fun enrolled(): Boolean? = enrolled.getNullable("enrolled") /** True if the endpoint was enrolled successfully. */ - @JsonProperty("enrolled") @ExcludeMissing fun _enrolled() = enrolled + @JsonProperty("enrolled") @ExcludeMissing fun _enrolled(): JsonField = enrolled @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ResponderEndpointStatus.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ResponderEndpointStatus.kt index ad1b280c..2a498062 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ResponderEndpointStatus.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ResponderEndpointStatus.kt @@ -33,10 +33,10 @@ private constructor( fun url(): String? = url.getNullable("url") /** True if the instance has an endpoint enrolled. */ - @JsonProperty("enrolled") @ExcludeMissing fun _enrolled() = enrolled + @JsonProperty("enrolled") @ExcludeMissing fun _enrolled(): JsonField = enrolled /** The URL of the currently enrolled endpoint or null. */ - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url @JsonAnyGetter @ExcludeMissing @@ -78,7 +78,7 @@ private constructor( fun enrolled(enrolled: JsonField) = apply { this.enrolled = enrolled } /** The URL of the currently enrolled endpoint or null. */ - fun url(url: String) = url(JsonField.of(url)) + fun url(url: String?) = url(JsonField.ofNullable(url)) /** The URL of the currently enrolled endpoint or null. */ fun url(url: JsonField) = apply { this.url = url } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementDetail.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementDetail.kt index cf2e2f19..2e1c0636 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementDetail.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementDetail.kt @@ -157,66 +157,78 @@ private constructor( fun feeDescription(): String? = feeDescription.getNullable("fee_description") /** Globally unique identifier denoting the Settlement Detail. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** * Globally unique identifier denoting the card program that the associated Transaction occurred * on. */ - @JsonProperty("card_program_token") @ExcludeMissing fun _cardProgramToken() = cardProgramToken + @JsonProperty("card_program_token") + @ExcludeMissing + fun _cardProgramToken(): JsonField = cardProgramToken /** Globally unique identifier denoting the card that the associated Transaction occurred on. */ - @JsonProperty("card_token") @ExcludeMissing fun _cardToken() = cardToken + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken /** Date and time when the transaction first occurred. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** Three-digit alphabetic ISO 4217 code. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The total gross amount of disputes settlements. */ @JsonProperty("disputes_gross_amount") @ExcludeMissing - fun _disputesGrossAmount() = disputesGrossAmount + fun _disputesGrossAmount(): JsonField = disputesGrossAmount /** Globally unique identifiers denoting the Events associated with this settlement. */ - @JsonProperty("event_tokens") @ExcludeMissing fun _eventTokens() = eventTokens + @JsonProperty("event_tokens") + @ExcludeMissing + fun _eventTokens(): JsonField> = eventTokens /** The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). */ - @JsonProperty("institution") @ExcludeMissing fun _institution() = institution + @JsonProperty("institution") @ExcludeMissing fun _institution(): JsonField = institution /** The total amount of interchange in six-digit extended precision. */ @JsonProperty("interchange_fee_extended_precision") @ExcludeMissing - fun _interchangeFeeExtendedPrecision() = interchangeFeeExtendedPrecision + fun _interchangeFeeExtendedPrecision(): JsonField = interchangeFeeExtendedPrecision /** The total amount of interchange. */ @JsonProperty("interchange_gross_amount") @ExcludeMissing - fun _interchangeGrossAmount() = interchangeGrossAmount + fun _interchangeGrossAmount(): JsonField = interchangeGrossAmount /** Card network where the transaction took place. */ - @JsonProperty("network") @ExcludeMissing fun _network() = network + @JsonProperty("network") @ExcludeMissing fun _network(): JsonField = network /** The total gross amount of other fees by type. */ - @JsonProperty("other_fees_details") @ExcludeMissing fun _otherFeesDetails() = otherFeesDetails + @JsonProperty("other_fees_details") + @ExcludeMissing + fun _otherFeesDetails(): JsonField = otherFeesDetails /** Total amount of gross other fees outside of interchange. */ @JsonProperty("other_fees_gross_amount") @ExcludeMissing - fun _otherFeesGrossAmount() = otherFeesGrossAmount + fun _otherFeesGrossAmount(): JsonField = otherFeesGrossAmount /** Date of when the report was first generated. */ - @JsonProperty("report_date") @ExcludeMissing fun _reportDate() = reportDate + @JsonProperty("report_date") @ExcludeMissing fun _reportDate(): JsonField = reportDate /** Date of when money movement is triggered for the transaction. */ - @JsonProperty("settlement_date") @ExcludeMissing fun _settlementDate() = settlementDate + @JsonProperty("settlement_date") + @ExcludeMissing + fun _settlementDate(): JsonField = settlementDate /** Globally unique identifier denoting the associated Transaction object. */ - @JsonProperty("transaction_token") @ExcludeMissing fun _transactionToken() = transactionToken + @JsonProperty("transaction_token") + @ExcludeMissing + fun _transactionToken(): JsonField = transactionToken /** * The total amount of settlement impacting transactions (excluding interchange, fees, and @@ -224,16 +236,18 @@ private constructor( */ @JsonProperty("transactions_gross_amount") @ExcludeMissing - fun _transactionsGrossAmount() = transactionsGrossAmount + fun _transactionsGrossAmount(): JsonField = transactionsGrossAmount /** The type of settlement record. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** Date and time when the transaction first occurred. UTC time zone. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated /** Network's description of a fee, only present on records with type `FEE`. */ - @JsonProperty("fee_description") @ExcludeMissing fun _feeDescription() = feeDescription + @JsonProperty("fee_description") + @ExcludeMissing + fun _feeDescription(): JsonField = feeDescription @JsonAnyGetter @ExcludeMissing @@ -277,26 +291,26 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountToken: JsonField = JsonMissing.of() - private var cardProgramToken: JsonField = JsonMissing.of() - private var cardToken: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var disputesGrossAmount: JsonField = JsonMissing.of() - private var eventTokens: JsonField> = JsonMissing.of() - private var institution: JsonField = JsonMissing.of() - private var interchangeFeeExtendedPrecision: JsonField = JsonMissing.of() - private var interchangeGrossAmount: JsonField = JsonMissing.of() - private var network: JsonField = JsonMissing.of() - private var otherFeesDetails: JsonField = JsonMissing.of() - private var otherFeesGrossAmount: JsonField = JsonMissing.of() - private var reportDate: JsonField = JsonMissing.of() - private var settlementDate: JsonField = JsonMissing.of() - private var transactionToken: JsonField = JsonMissing.of() - private var transactionsGrossAmount: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var accountToken: JsonField? = null + private var cardProgramToken: JsonField? = null + private var cardToken: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var disputesGrossAmount: JsonField? = null + private var eventTokens: JsonField>? = null + private var institution: JsonField? = null + private var interchangeFeeExtendedPrecision: JsonField? = null + private var interchangeGrossAmount: JsonField? = null + private var network: JsonField? = null + private var otherFeesDetails: JsonField? = null + private var otherFeesGrossAmount: JsonField? = null + private var reportDate: JsonField? = null + private var settlementDate: JsonField? = null + private var transactionToken: JsonField? = null + private var transactionsGrossAmount: JsonField? = null + private var type: JsonField? = null + private var updated: JsonField? = null private var feeDescription: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -308,7 +322,7 @@ private constructor( created = settlementDetail.created currency = settlementDetail.currency disputesGrossAmount = settlementDetail.disputesGrossAmount - eventTokens = settlementDetail.eventTokens + eventTokens = settlementDetail.eventTokens.map { it.toMutableList() } institution = settlementDetail.institution interchangeFeeExtendedPrecision = settlementDetail.interchangeFeeExtendedPrecision interchangeGrossAmount = settlementDetail.interchangeGrossAmount @@ -394,7 +408,19 @@ private constructor( /** Globally unique identifiers denoting the Events associated with this settlement. */ fun eventTokens(eventTokens: JsonField>) = apply { - this.eventTokens = eventTokens + this.eventTokens = eventTokens.map { it.toMutableList() } + } + + /** Globally unique identifiers denoting the Events associated with this settlement. */ + fun addEventToken(eventToken: String) = apply { + eventTokens = + (eventTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(eventToken) + } } /** @@ -529,26 +555,37 @@ private constructor( fun build(): SettlementDetail = SettlementDetail( - token, - accountToken, - cardProgramToken, - cardToken, - created, - currency, - disputesGrossAmount, - eventTokens.map { it.toImmutable() }, - institution, - interchangeFeeExtendedPrecision, - interchangeGrossAmount, - network, - otherFeesDetails, - otherFeesGrossAmount, - reportDate, - settlementDate, - transactionToken, - transactionsGrossAmount, - type, - updated, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountToken) { "`accountToken` is required but was not set" }, + checkNotNull(cardProgramToken) { "`cardProgramToken` is required but was not set" }, + checkNotNull(cardToken) { "`cardToken` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(disputesGrossAmount) { + "`disputesGrossAmount` is required but was not set" + }, + checkNotNull(eventTokens) { "`eventTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(institution) { "`institution` is required but was not set" }, + checkNotNull(interchangeFeeExtendedPrecision) { + "`interchangeFeeExtendedPrecision` is required but was not set" + }, + checkNotNull(interchangeGrossAmount) { + "`interchangeGrossAmount` is required but was not set" + }, + checkNotNull(network) { "`network` is required but was not set" }, + checkNotNull(otherFeesDetails) { "`otherFeesDetails` is required but was not set" }, + checkNotNull(otherFeesGrossAmount) { + "`otherFeesGrossAmount` is required but was not set" + }, + checkNotNull(reportDate) { "`reportDate` is required but was not set" }, + checkNotNull(settlementDate) { "`settlementDate` is required but was not set" }, + checkNotNull(transactionToken) { "`transactionToken` is required but was not set" }, + checkNotNull(transactionsGrossAmount) { + "`transactionsGrossAmount` is required but was not set" + }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, feeDescription, additionalProperties.toImmutable(), ) @@ -641,7 +678,7 @@ private constructor( fun isa(): Long? = isa.getNullable("ISA") - @JsonProperty("ISA") @ExcludeMissing fun _isa() = isa + @JsonProperty("ISA") @ExcludeMissing fun _isa(): JsonField = isa @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementReport.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementReport.kt index 4f3721c0..307daaf8 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementReport.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementReport.kt @@ -116,15 +116,17 @@ private constructor( fun updated(): OffsetDateTime = updated.getRequired("updated") /** Date and time when the transaction first occurred. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** * Three-digit alphabetic ISO 4217 code. (This field is deprecated and will be removed in a * future version of the API.) */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("details") @ExcludeMissing fun _details() = details + @JsonProperty("details") + @ExcludeMissing + fun _details(): JsonField> = details /** * The total gross amount of disputes settlements. (This field is deprecated and will be removed @@ -133,7 +135,7 @@ private constructor( */ @JsonProperty("disputes_gross_amount") @ExcludeMissing - fun _disputesGrossAmount() = disputesGrossAmount + fun _disputesGrossAmount(): JsonField = disputesGrossAmount /** * The total amount of interchange. (This field is deprecated and will be removed in a future @@ -142,10 +144,10 @@ private constructor( */ @JsonProperty("interchange_gross_amount") @ExcludeMissing - fun _interchangeGrossAmount() = interchangeGrossAmount + fun _interchangeGrossAmount(): JsonField = interchangeGrossAmount /** Indicates that all data expected on the given report date is available. */ - @JsonProperty("is_complete") @ExcludeMissing fun _isComplete() = isComplete + @JsonProperty("is_complete") @ExcludeMissing fun _isComplete(): JsonField = isComplete /** * Total amount of gross other fees outside of interchange. (This field is deprecated and will @@ -154,10 +156,10 @@ private constructor( */ @JsonProperty("other_fees_gross_amount") @ExcludeMissing - fun _otherFeesGrossAmount() = otherFeesGrossAmount + fun _otherFeesGrossAmount(): JsonField = otherFeesGrossAmount /** Date of when the report was first generated. */ - @JsonProperty("report_date") @ExcludeMissing fun _reportDate() = reportDate + @JsonProperty("report_date") @ExcludeMissing fun _reportDate(): JsonField = reportDate /** * The total net amount of cash moved. (net value of settled_gross_amount, interchange, fees). @@ -165,7 +167,9 @@ private constructor( * total amounts, Lithic recommends that customers sum the relevant settlement amounts found * within `details`.) */ - @JsonProperty("settled_net_amount") @ExcludeMissing fun _settledNetAmount() = settledNetAmount + @JsonProperty("settled_net_amount") + @ExcludeMissing + fun _settledNetAmount(): JsonField = settledNetAmount /** * The total amount of settlement impacting transactions (excluding interchange, fees, and @@ -175,10 +179,10 @@ private constructor( */ @JsonProperty("transactions_gross_amount") @ExcludeMissing - fun _transactionsGrossAmount() = transactionsGrossAmount + fun _transactionsGrossAmount(): JsonField = transactionsGrossAmount /** Date and time when the transaction first occurred. UTC time zone. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated @JsonAnyGetter @ExcludeMissing @@ -212,23 +216,23 @@ private constructor( class Builder { - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var details: JsonField> = JsonMissing.of() - private var disputesGrossAmount: JsonField = JsonMissing.of() - private var interchangeGrossAmount: JsonField = JsonMissing.of() - private var isComplete: JsonField = JsonMissing.of() - private var otherFeesGrossAmount: JsonField = JsonMissing.of() - private var reportDate: JsonField = JsonMissing.of() - private var settledNetAmount: JsonField = JsonMissing.of() - private var transactionsGrossAmount: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() + private var created: JsonField? = null + private var currency: JsonField? = null + private var details: JsonField>? = null + private var disputesGrossAmount: JsonField? = null + private var interchangeGrossAmount: JsonField? = null + private var isComplete: JsonField? = null + private var otherFeesGrossAmount: JsonField? = null + private var reportDate: JsonField? = null + private var settledNetAmount: JsonField? = null + private var transactionsGrossAmount: JsonField? = null + private var updated: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(settlementReport: SettlementReport) = apply { created = settlementReport.created currency = settlementReport.currency - details = settlementReport.details + details = settlementReport.details.map { it.toMutableList() } disputesGrossAmount = settlementReport.disputesGrossAmount interchangeGrossAmount = settlementReport.interchangeGrossAmount isComplete = settlementReport.isComplete @@ -261,7 +265,18 @@ private constructor( fun details(details: List) = details(JsonField.of(details)) fun details(details: JsonField>) = apply { - this.details = details + this.details = details.map { it.toMutableList() } + } + + fun addDetail(detail: SettlementSummaryDetails) = apply { + details = + (details ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(detail) + } } /** @@ -392,17 +407,26 @@ private constructor( fun build(): SettlementReport = SettlementReport( - created, - currency, - details.map { it.toImmutable() }, - disputesGrossAmount, - interchangeGrossAmount, - isComplete, - otherFeesGrossAmount, - reportDate, - settledNetAmount, - transactionsGrossAmount, - updated, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(details) { "`details` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(disputesGrossAmount) { + "`disputesGrossAmount` is required but was not set" + }, + checkNotNull(interchangeGrossAmount) { + "`interchangeGrossAmount` is required but was not set" + }, + checkNotNull(isComplete) { "`isComplete` is required but was not set" }, + checkNotNull(otherFeesGrossAmount) { + "`otherFeesGrossAmount` is required but was not set" + }, + checkNotNull(reportDate) { "`reportDate` is required but was not set" }, + checkNotNull(settledNetAmount) { "`settledNetAmount` is required but was not set" }, + checkNotNull(transactionsGrossAmount) { + "`transactionsGrossAmount` is required but was not set" + }, + checkNotNull(updated) { "`updated` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementSummaryDetails.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementSummaryDetails.kt index f70e27e1..5da41a2a 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementSummaryDetails.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementSummaryDetails.kt @@ -80,33 +80,35 @@ private constructor( transactionsGrossAmount.getNullable("transactions_gross_amount") /** ISO 4217 alpha 3 code. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The total gross amount of disputes settlements. */ @JsonProperty("disputes_gross_amount") @ExcludeMissing - fun _disputesGrossAmount() = disputesGrossAmount + fun _disputesGrossAmount(): JsonField = disputesGrossAmount /** The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). */ - @JsonProperty("institution") @ExcludeMissing fun _institution() = institution + @JsonProperty("institution") @ExcludeMissing fun _institution(): JsonField = institution /** The total amount of interchange. */ @JsonProperty("interchange_gross_amount") @ExcludeMissing - fun _interchangeGrossAmount() = interchangeGrossAmount + fun _interchangeGrossAmount(): JsonField = interchangeGrossAmount /** Card network where the transaction took place */ - @JsonProperty("network") @ExcludeMissing fun _network() = network + @JsonProperty("network") @ExcludeMissing fun _network(): JsonField = network /** Total amount of gross other fees outside of interchange. */ @JsonProperty("other_fees_gross_amount") @ExcludeMissing - fun _otherFeesGrossAmount() = otherFeesGrossAmount + fun _otherFeesGrossAmount(): JsonField = otherFeesGrossAmount /** * The total net amount of cash moved. (net value of settled_gross_amount, interchange, fees). */ - @JsonProperty("settled_net_amount") @ExcludeMissing fun _settledNetAmount() = settledNetAmount + @JsonProperty("settled_net_amount") + @ExcludeMissing + fun _settledNetAmount(): JsonField = settledNetAmount /** * The total amount of settlement impacting transactions (excluding interchange, fees, and @@ -114,7 +116,7 @@ private constructor( */ @JsonProperty("transactions_gross_amount") @ExcludeMissing - fun _transactionsGrossAmount() = transactionsGrossAmount + fun _transactionsGrossAmount(): JsonField = transactionsGrossAmount @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ShippingAddress.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ShippingAddress.kt index 1f10826b..34e61821 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ShippingAddress.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ShippingAddress.kt @@ -104,58 +104,60 @@ private constructor( fun phoneNumber(): String? = phoneNumber.getNullable("phone_number") /** Valid USPS routable address. */ - @JsonProperty("address1") @ExcludeMissing fun _address1() = address1 + @JsonProperty("address1") @ExcludeMissing fun _address1(): JsonField = address1 /** City */ - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city /** Uppercase ISO 3166-1 alpha-3 three character abbreviation. */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** * Customer's first name. This will be the first name printed on the physical card. The combined * length of `first_name` and `last_name` may not exceed 25 characters. */ - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** * Customer's surname (family name). This will be the last name printed on the physical card. * The combined length of `first_name` and `last_name` may not exceed 25 characters. */ - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName /** * Postal code (formerly zipcode). For US addresses, either five-digit postal code or nine-digit * postal code (ZIP+4) using the format 12345-1234. */ - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") @ExcludeMissing fun _postalCode(): JsonField = postalCode /** * Uppercase ISO 3166-2 two character abbreviation for US and CA. Optional with a limit of 24 * characters for other countries. */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** Unit number (if applicable). */ - @JsonProperty("address2") @ExcludeMissing fun _address2() = address2 + @JsonProperty("address2") @ExcludeMissing fun _address2(): JsonField = address2 /** * Email address to be contacted for expedited shipping process purposes. Required if * `shipping_method` is `EXPEDITED`. */ - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email /** * Text to be printed on line two of the physical card. Use of this field requires additional * permissions. */ - @JsonProperty("line2_text") @ExcludeMissing fun _line2Text() = line2Text + @JsonProperty("line2_text") @ExcludeMissing fun _line2Text(): JsonField = line2Text /** * Cardholder's phone number in E.164 format to be contacted for expedited shipping process * purposes. Required if `shipping_method` is `EXPEDITED`. */ - @JsonProperty("phone_number") @ExcludeMissing fun _phoneNumber() = phoneNumber + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber @JsonAnyGetter @ExcludeMissing @@ -189,13 +191,13 @@ private constructor( class Builder { - private var address1: JsonField = JsonMissing.of() - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var firstName: JsonField = JsonMissing.of() - private var lastName: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() + private var address1: JsonField? = null + private var city: JsonField? = null + private var country: JsonField? = null + private var firstName: JsonField? = null + private var lastName: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null private var address2: JsonField = JsonMissing.of() private var email: JsonField = JsonMissing.of() private var line2Text: JsonField = JsonMissing.of() @@ -346,13 +348,13 @@ private constructor( fun build(): ShippingAddress = ShippingAddress( - address1, - city, - country, - firstName, - lastName, - postalCode, - state, + checkNotNull(address1) { "`address1` is required but was not set" }, + checkNotNull(city) { "`city` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(firstName) { "`firstName` is required but was not set" }, + checkNotNull(lastName) { "`lastName` is required but was not set" }, + checkNotNull(postalCode) { "`postalCode` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, address2, email, line2Text, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Statement.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Statement.kt index c1dc4dbc..efccb7a6 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Statement.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Statement.kt @@ -150,76 +150,96 @@ private constructor( nextStatementEndDate.getNullable("next_statement_end_date") /** Globally unique identifier for a statement */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - @JsonProperty("account_standing") @ExcludeMissing fun _accountStanding() = accountStanding + @JsonProperty("account_standing") + @ExcludeMissing + fun _accountStanding(): JsonField = accountStanding - @JsonProperty("amount_due") @ExcludeMissing fun _amountDue() = amountDue + @JsonProperty("amount_due") @ExcludeMissing fun _amountDue(): JsonField = amountDue /** Amount of credit available to spend in cents */ - @JsonProperty("available_credit") @ExcludeMissing fun _availableCredit() = availableCredit + @JsonProperty("available_credit") + @ExcludeMissing + fun _availableCredit(): JsonField = availableCredit /** Timestamp of when the statement was created */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** This is the maximum credit balance extended by the lender in cents */ - @JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit() = creditLimit + @JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit(): JsonField = creditLimit /** Globally unique identifier for a credit product */ @JsonProperty("credit_product_token") @ExcludeMissing - fun _creditProductToken() = creditProductToken + fun _creditProductToken(): JsonField = creditProductToken /** Number of days in the billing cycle */ @JsonProperty("days_in_billing_cycle") @ExcludeMissing - fun _daysInBillingCycle() = daysInBillingCycle + fun _daysInBillingCycle(): JsonField = daysInBillingCycle /** * Balance at the end of the billing period. For charge cards, this should be the same at the * statement amount due in cents */ - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance /** Globally unique identifier for a financial account */ @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken /** Date when the payment is due */ - @JsonProperty("payment_due_date") @ExcludeMissing fun _paymentDueDate() = paymentDueDate + @JsonProperty("payment_due_date") + @ExcludeMissing + fun _paymentDueDate(): JsonField = paymentDueDate - @JsonProperty("period_totals") @ExcludeMissing fun _periodTotals() = periodTotals + @JsonProperty("period_totals") + @ExcludeMissing + fun _periodTotals(): JsonField = periodTotals /** Balance at the start of the billing period */ - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance /** Date when the billing period ended */ - @JsonProperty("statement_end_date") @ExcludeMissing fun _statementEndDate() = statementEndDate + @JsonProperty("statement_end_date") + @ExcludeMissing + fun _statementEndDate(): JsonField = statementEndDate /** Date when the billing period began */ @JsonProperty("statement_start_date") @ExcludeMissing - fun _statementStartDate() = statementStartDate + fun _statementStartDate(): JsonField = statementStartDate - @JsonProperty("statement_type") @ExcludeMissing fun _statementType() = statementType + @JsonProperty("statement_type") + @ExcludeMissing + fun _statementType(): JsonField = statementType /** Timestamp of when the statement was updated */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated - @JsonProperty("ytd_totals") @ExcludeMissing fun _ytdTotals() = ytdTotals + @JsonProperty("ytd_totals") + @ExcludeMissing + fun _ytdTotals(): JsonField = ytdTotals - @JsonProperty("interest_details") @ExcludeMissing fun _interestDetails() = interestDetails + @JsonProperty("interest_details") + @ExcludeMissing + fun _interestDetails(): JsonField = interestDetails /** Date when the next payment is due */ @JsonProperty("next_payment_due_date") @ExcludeMissing - fun _nextPaymentDueDate() = nextPaymentDueDate + fun _nextPaymentDueDate(): JsonField = nextPaymentDueDate /** Date when the next billing period will end */ @JsonProperty("next_statement_end_date") @ExcludeMissing - fun _nextStatementEndDate() = nextStatementEndDate + fun _nextStatementEndDate(): JsonField = nextStatementEndDate @JsonAnyGetter @ExcludeMissing @@ -263,24 +283,24 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountStanding: JsonField = JsonMissing.of() - private var amountDue: JsonField = JsonMissing.of() - private var availableCredit: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var creditLimit: JsonField = JsonMissing.of() - private var creditProductToken: JsonField = JsonMissing.of() - private var daysInBillingCycle: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var financialAccountToken: JsonField = JsonMissing.of() - private var paymentDueDate: JsonField = JsonMissing.of() - private var periodTotals: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() - private var statementEndDate: JsonField = JsonMissing.of() - private var statementStartDate: JsonField = JsonMissing.of() - private var statementType: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() - private var ytdTotals: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var accountStanding: JsonField? = null + private var amountDue: JsonField? = null + private var availableCredit: JsonField? = null + private var created: JsonField? = null + private var creditLimit: JsonField? = null + private var creditProductToken: JsonField? = null + private var daysInBillingCycle: JsonField? = null + private var endingBalance: JsonField? = null + private var financialAccountToken: JsonField? = null + private var paymentDueDate: JsonField? = null + private var periodTotals: JsonField? = null + private var startingBalance: JsonField? = null + private var statementEndDate: JsonField? = null + private var statementStartDate: JsonField? = null + private var statementType: JsonField? = null + private var updated: JsonField? = null + private var ytdTotals: JsonField? = null private var interestDetails: JsonField = JsonMissing.of() private var nextPaymentDueDate: JsonField = JsonMissing.of() private var nextStatementEndDate: JsonField = JsonMissing.of() @@ -445,8 +465,8 @@ private constructor( fun ytdTotals(ytdTotals: JsonField) = apply { this.ytdTotals = ytdTotals } - fun interestDetails(interestDetails: InterestDetails) = - interestDetails(JsonField.of(interestDetails)) + fun interestDetails(interestDetails: InterestDetails?) = + interestDetails(JsonField.ofNullable(interestDetails)) fun interestDetails(interestDetails: JsonField) = apply { this.interestDetails = interestDetails @@ -491,24 +511,32 @@ private constructor( fun build(): Statement = Statement( - token, - accountStanding, - amountDue, - availableCredit, - created, - creditLimit, - creditProductToken, - daysInBillingCycle, - endingBalance, - financialAccountToken, - paymentDueDate, - periodTotals, - startingBalance, - statementEndDate, - statementStartDate, - statementType, - updated, - ytdTotals, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountStanding) { "`accountStanding` is required but was not set" }, + checkNotNull(amountDue) { "`amountDue` is required but was not set" }, + checkNotNull(availableCredit) { "`availableCredit` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(creditLimit) { "`creditLimit` is required but was not set" }, + checkNotNull(creditProductToken) { + "`creditProductToken` is required but was not set" + }, + checkNotNull(daysInBillingCycle) { + "`daysInBillingCycle` is required but was not set" + }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + checkNotNull(paymentDueDate) { "`paymentDueDate` is required but was not set" }, + checkNotNull(periodTotals) { "`periodTotals` is required but was not set" }, + checkNotNull(startingBalance) { "`startingBalance` is required but was not set" }, + checkNotNull(statementEndDate) { "`statementEndDate` is required but was not set" }, + checkNotNull(statementStartDate) { + "`statementStartDate` is required but was not set" + }, + checkNotNull(statementType) { "`statementType` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, + checkNotNull(ytdTotals) { "`ytdTotals` is required but was not set" }, interestDetails, nextPaymentDueDate, nextStatementEndDate, @@ -571,28 +599,34 @@ private constructor( /** Number of consecutive full payments made */ @JsonProperty("consecutive_full_payments_made") @ExcludeMissing - fun _consecutiveFullPaymentsMade() = consecutiveFullPaymentsMade + fun _consecutiveFullPaymentsMade(): JsonField = consecutiveFullPaymentsMade /** Number of consecutive minimum payments made */ @JsonProperty("consecutive_minimum_payments_made") @ExcludeMissing - fun _consecutiveMinimumPaymentsMade() = consecutiveMinimumPaymentsMade + fun _consecutiveMinimumPaymentsMade(): JsonField = consecutiveMinimumPaymentsMade /** Number of consecutive minimum payments missed */ @JsonProperty("consecutive_minimum_payments_missed") @ExcludeMissing - fun _consecutiveMinimumPaymentsMissed() = consecutiveMinimumPaymentsMissed + fun _consecutiveMinimumPaymentsMissed(): JsonField = consecutiveMinimumPaymentsMissed /** Number of days past due */ - @JsonProperty("days_past_due") @ExcludeMissing fun _daysPastDue() = daysPastDue + @JsonProperty("days_past_due") + @ExcludeMissing + fun _daysPastDue(): JsonField = daysPastDue /** Whether the account currently has grace or not */ - @JsonProperty("has_grace") @ExcludeMissing fun _hasGrace() = hasGrace + @JsonProperty("has_grace") @ExcludeMissing fun _hasGrace(): JsonField = hasGrace /** Current overall period number */ - @JsonProperty("period_number") @ExcludeMissing fun _periodNumber() = periodNumber + @JsonProperty("period_number") + @ExcludeMissing + fun _periodNumber(): JsonField = periodNumber - @JsonProperty("period_state") @ExcludeMissing fun _periodState() = periodState + @JsonProperty("period_state") + @ExcludeMissing + fun _periodState(): JsonField = periodState @JsonAnyGetter @ExcludeMissing @@ -622,13 +656,13 @@ private constructor( class Builder { - private var consecutiveFullPaymentsMade: JsonField = JsonMissing.of() - private var consecutiveMinimumPaymentsMade: JsonField = JsonMissing.of() - private var consecutiveMinimumPaymentsMissed: JsonField = JsonMissing.of() - private var daysPastDue: JsonField = JsonMissing.of() - private var hasGrace: JsonField = JsonMissing.of() - private var periodNumber: JsonField = JsonMissing.of() - private var periodState: JsonField = JsonMissing.of() + private var consecutiveFullPaymentsMade: JsonField? = null + private var consecutiveMinimumPaymentsMade: JsonField? = null + private var consecutiveMinimumPaymentsMissed: JsonField? = null + private var daysPastDue: JsonField? = null + private var hasGrace: JsonField? = null + private var periodNumber: JsonField? = null + private var periodState: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(accountStanding: AccountStanding) = apply { @@ -717,13 +751,19 @@ private constructor( fun build(): AccountStanding = AccountStanding( - consecutiveFullPaymentsMade, - consecutiveMinimumPaymentsMade, - consecutiveMinimumPaymentsMissed, - daysPastDue, - hasGrace, - periodNumber, - periodState, + checkNotNull(consecutiveFullPaymentsMade) { + "`consecutiveFullPaymentsMade` is required but was not set" + }, + checkNotNull(consecutiveMinimumPaymentsMade) { + "`consecutiveMinimumPaymentsMade` is required but was not set" + }, + checkNotNull(consecutiveMinimumPaymentsMissed) { + "`consecutiveMinimumPaymentsMissed` is required but was not set" + }, + checkNotNull(daysPastDue) { "`daysPastDue` is required but was not set" }, + checkNotNull(hasGrace) { "`hasGrace` is required but was not set" }, + checkNotNull(periodNumber) { "`periodNumber` is required but was not set" }, + checkNotNull(periodState) { "`periodState` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -840,10 +880,10 @@ private constructor( * auto-collections are enabled this is the amount that will be requested on the payment due * date */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** Amount past due for statement in cents */ - @JsonProperty("past_due") @ExcludeMissing fun _pastDue() = pastDue + @JsonProperty("past_due") @ExcludeMissing fun _pastDue(): JsonField = pastDue @JsonAnyGetter @ExcludeMissing @@ -868,8 +908,8 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var pastDue: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var pastDue: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(amountDue: AmountDue) = apply { @@ -921,8 +961,8 @@ private constructor( fun build(): AmountDue = AmountDue( - amount, - pastDue, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(pastDue) { "`pastDue` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -998,27 +1038,29 @@ private constructor( /** Opening balance transferred from previous account in cents */ @JsonProperty("balance_transfers") @ExcludeMissing - fun _balanceTransfers() = balanceTransfers + fun _balanceTransfers(): JsonField = balanceTransfers /** ATM and cashback transactions in cents */ - @JsonProperty("cash_advances") @ExcludeMissing fun _cashAdvances() = cashAdvances + @JsonProperty("cash_advances") + @ExcludeMissing + fun _cashAdvances(): JsonField = cashAdvances /** * Volume of credit management operation transactions less any balance transfers in cents */ - @JsonProperty("credits") @ExcludeMissing fun _credits() = credits + @JsonProperty("credits") @ExcludeMissing fun _credits(): JsonField = credits /** Volume of debit management operation transactions less any interest in cents */ - @JsonProperty("fees") @ExcludeMissing fun _fees() = fees + @JsonProperty("fees") @ExcludeMissing fun _fees(): JsonField = fees /** Interest accrued in cents */ - @JsonProperty("interest") @ExcludeMissing fun _interest() = interest + @JsonProperty("interest") @ExcludeMissing fun _interest(): JsonField = interest /** Any funds transfers which affective the balance in cents */ - @JsonProperty("payments") @ExcludeMissing fun _payments() = payments + @JsonProperty("payments") @ExcludeMissing fun _payments(): JsonField = payments /** Net card transaction volume less any cash advances in cents */ - @JsonProperty("purchases") @ExcludeMissing fun _purchases() = purchases + @JsonProperty("purchases") @ExcludeMissing fun _purchases(): JsonField = purchases @JsonAnyGetter @ExcludeMissing @@ -1048,13 +1090,13 @@ private constructor( class Builder { - private var balanceTransfers: JsonField = JsonMissing.of() - private var cashAdvances: JsonField = JsonMissing.of() - private var credits: JsonField = JsonMissing.of() - private var fees: JsonField = JsonMissing.of() - private var interest: JsonField = JsonMissing.of() - private var payments: JsonField = JsonMissing.of() - private var purchases: JsonField = JsonMissing.of() + private var balanceTransfers: JsonField? = null + private var cashAdvances: JsonField? = null + private var credits: JsonField? = null + private var fees: JsonField? = null + private var interest: JsonField? = null + private var payments: JsonField? = null + private var purchases: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(statementTotals: StatementTotals) = apply { @@ -1142,13 +1184,15 @@ private constructor( fun build(): StatementTotals = StatementTotals( - balanceTransfers, - cashAdvances, - credits, - fees, - interest, - payments, - purchases, + checkNotNull(balanceTransfers) { + "`balanceTransfers` is required but was not set" + }, + checkNotNull(cashAdvances) { "`cashAdvances` is required but was not set" }, + checkNotNull(credits) { "`credits` is required but was not set" }, + checkNotNull(fees) { "`fees` is required but was not set" }, + checkNotNull(interest) { "`interest` is required but was not set" }, + checkNotNull(payments) { "`payments` is required but was not set" }, + checkNotNull(purchases) { "`purchases` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1279,27 +1323,30 @@ private constructor( @JsonProperty("actual_interest_charged") @ExcludeMissing - fun _actualInterestCharged() = actualInterestCharged + fun _actualInterestCharged(): JsonField = actualInterestCharged @JsonProperty("daily_balance_amounts") @ExcludeMissing - fun _dailyBalanceAmounts() = dailyBalanceAmounts + fun _dailyBalanceAmounts(): JsonField = dailyBalanceAmounts - @JsonProperty("effective_apr") @ExcludeMissing fun _effectiveApr() = effectiveApr + @JsonProperty("effective_apr") + @ExcludeMissing + fun _effectiveApr(): JsonField = effectiveApr @JsonProperty("interest_calculation_method") @ExcludeMissing - fun _interestCalculationMethod() = interestCalculationMethod + fun _interestCalculationMethod(): JsonField = + interestCalculationMethod @JsonProperty("interest_for_period") @ExcludeMissing - fun _interestForPeriod() = interestForPeriod + fun _interestForPeriod(): JsonField = interestForPeriod - @JsonProperty("prime_rate") @ExcludeMissing fun _primeRate() = primeRate + @JsonProperty("prime_rate") @ExcludeMissing fun _primeRate(): JsonField = primeRate @JsonProperty("minimum_interest_charged") @ExcludeMissing - fun _minimumInterestCharged() = minimumInterestCharged + fun _minimumInterestCharged(): JsonField = minimumInterestCharged @JsonAnyGetter @ExcludeMissing @@ -1329,13 +1376,12 @@ private constructor( class Builder { - private var actualInterestCharged: JsonField = JsonMissing.of() - private var dailyBalanceAmounts: JsonField = JsonMissing.of() - private var effectiveApr: JsonField = JsonMissing.of() - private var interestCalculationMethod: JsonField = - JsonMissing.of() - private var interestForPeriod: JsonField = JsonMissing.of() - private var primeRate: JsonField = JsonMissing.of() + private var actualInterestCharged: JsonField? = null + private var dailyBalanceAmounts: JsonField? = null + private var effectiveApr: JsonField? = null + private var interestCalculationMethod: JsonField? = null + private var interestForPeriod: JsonField? = null + private var primeRate: JsonField? = null private var minimumInterestCharged: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1350,8 +1396,11 @@ private constructor( additionalProperties = interestDetails.additionalProperties.toMutableMap() } + fun actualInterestCharged(actualInterestCharged: Long?) = + actualInterestCharged(JsonField.ofNullable(actualInterestCharged)) + fun actualInterestCharged(actualInterestCharged: Long) = - actualInterestCharged(JsonField.of(actualInterestCharged)) + actualInterestCharged(actualInterestCharged as Long?) fun actualInterestCharged(actualInterestCharged: JsonField) = apply { this.actualInterestCharged = actualInterestCharged @@ -1385,12 +1434,15 @@ private constructor( this.interestForPeriod = interestForPeriod } - fun primeRate(primeRate: String) = primeRate(JsonField.of(primeRate)) + fun primeRate(primeRate: String?) = primeRate(JsonField.ofNullable(primeRate)) fun primeRate(primeRate: JsonField) = apply { this.primeRate = primeRate } + fun minimumInterestCharged(minimumInterestCharged: Long?) = + minimumInterestCharged(JsonField.ofNullable(minimumInterestCharged)) + fun minimumInterestCharged(minimumInterestCharged: Long) = - minimumInterestCharged(JsonField.of(minimumInterestCharged)) + minimumInterestCharged(minimumInterestCharged as Long?) fun minimumInterestCharged(minimumInterestCharged: JsonField) = apply { this.minimumInterestCharged = minimumInterestCharged @@ -1417,12 +1469,20 @@ private constructor( fun build(): InterestDetails = InterestDetails( - actualInterestCharged, - dailyBalanceAmounts, - effectiveApr, - interestCalculationMethod, - interestForPeriod, - primeRate, + checkNotNull(actualInterestCharged) { + "`actualInterestCharged` is required but was not set" + }, + checkNotNull(dailyBalanceAmounts) { + "`dailyBalanceAmounts` is required but was not set" + }, + checkNotNull(effectiveApr) { "`effectiveApr` is required but was not set" }, + checkNotNull(interestCalculationMethod) { + "`interestCalculationMethod` is required but was not set" + }, + checkNotNull(interestForPeriod) { + "`interestForPeriod` is required but was not set" + }, + checkNotNull(primeRate) { "`primeRate` is required but was not set" }, minimumInterestCharged, additionalProperties.toImmutable(), ) @@ -1453,11 +1513,15 @@ private constructor( @JsonProperty("balance_transfers") @ExcludeMissing - fun _balanceTransfers() = balanceTransfers + fun _balanceTransfers(): JsonField = balanceTransfers - @JsonProperty("cash_advances") @ExcludeMissing fun _cashAdvances() = cashAdvances + @JsonProperty("cash_advances") + @ExcludeMissing + fun _cashAdvances(): JsonField = cashAdvances - @JsonProperty("purchases") @ExcludeMissing fun _purchases() = purchases + @JsonProperty("purchases") + @ExcludeMissing + fun _purchases(): JsonField = purchases @JsonAnyGetter @ExcludeMissing @@ -1483,9 +1547,9 @@ private constructor( class Builder { - private var balanceTransfers: JsonField = JsonMissing.of() - private var cashAdvances: JsonField = JsonMissing.of() - private var purchases: JsonField = JsonMissing.of() + private var balanceTransfers: JsonField? = null + private var cashAdvances: JsonField? = null + private var purchases: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(categoryDetails: CategoryDetails) = apply { @@ -1536,9 +1600,11 @@ private constructor( fun build(): CategoryDetails = CategoryDetails( - balanceTransfers, - cashAdvances, - purchases, + checkNotNull(balanceTransfers) { + "`balanceTransfers` is required but was not set" + }, + checkNotNull(cashAdvances) { "`cashAdvances` is required but was not set" }, + checkNotNull(purchases) { "`purchases` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/StatementLineItems.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/StatementLineItems.kt index 5ca0d90d..9cb7c94d 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/StatementLineItems.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/StatementLineItems.kt @@ -36,9 +36,11 @@ private constructor( fun hasMore(): Boolean = hasMore.getRequired("has_more") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField> = data - @JsonProperty("has_more") @ExcludeMissing fun _hasMore() = hasMore + @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore @JsonAnyGetter @ExcludeMissing @@ -63,19 +65,32 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() - private var hasMore: JsonField = JsonMissing.of() + private var data: JsonField>? = null + private var hasMore: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(statementLineItems: StatementLineItems) = apply { - data = statementLineItems.data + data = statementLineItems.data.map { it.toMutableList() } hasMore = statementLineItems.hasMore additionalProperties = statementLineItems.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: StatementLineItemResponse) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(data) + } + } fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) @@ -102,8 +117,9 @@ private constructor( fun build(): StatementLineItems = StatementLineItems( - data.map { it.toImmutable() }, - hasMore, + checkNotNull(data) { "`data` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(hasMore) { "`hasMore` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -189,43 +205,51 @@ private constructor( fun descriptor(): String? = descriptor.getNullable("descriptor") /** Globally unique identifier for a Statement Line Item */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Transaction amount in cents */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("category") @ExcludeMissing fun _category() = category + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category /** Timestamp of when the line item was generated */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** 3-digit alphabetic ISO 4217 code for the settling currency of the transaction */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** Date that the transaction effected the account balance */ - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("event_type") @ExcludeMissing fun _eventType() = eventType + @JsonProperty("event_type") + @ExcludeMissing + fun _eventType(): JsonField = eventType /** Globally unique identifier for a financial account */ @JsonProperty("financial_account_token") @ExcludeMissing - fun _financialAccountToken() = financialAccountToken + fun _financialAccountToken(): JsonField = financialAccountToken /** Globally unique identifier for a financial transaction event */ @JsonProperty("financial_transaction_event_token") @ExcludeMissing - fun _financialTransactionEventToken() = financialTransactionEventToken + fun _financialTransactionEventToken(): JsonField = financialTransactionEventToken /** Globally unique identifier for a financial transaction */ @JsonProperty("financial_transaction_token") @ExcludeMissing - fun _financialTransactionToken() = financialTransactionToken + fun _financialTransactionToken(): JsonField = financialTransactionToken /** Globally unique identifier for a card */ - @JsonProperty("card_token") @ExcludeMissing fun _cardToken() = cardToken + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken - @JsonProperty("descriptor") @ExcludeMissing fun _descriptor() = descriptor + @JsonProperty("descriptor") + @ExcludeMissing + fun _descriptor(): JsonField = descriptor @JsonAnyGetter @ExcludeMissing @@ -260,16 +284,16 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var category: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var effectiveDate: JsonField = JsonMissing.of() - private var eventType: JsonField = JsonMissing.of() - private var financialAccountToken: JsonField = JsonMissing.of() - private var financialTransactionEventToken: JsonField = JsonMissing.of() - private var financialTransactionToken: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var amount: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var effectiveDate: JsonField? = null + private var eventType: JsonField? = null + private var financialAccountToken: JsonField? = null + private var financialTransactionEventToken: JsonField? = null + private var financialTransactionToken: JsonField? = null private var cardToken: JsonField = JsonMissing.of() private var descriptor: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -394,16 +418,22 @@ private constructor( fun build(): StatementLineItemResponse = StatementLineItemResponse( - token, - amount, - category, - created, - currency, - effectiveDate, - eventType, - financialAccountToken, - financialTransactionEventToken, - financialTransactionToken, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(category) { "`category` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + checkNotNull(eventType) { "`eventType` is required but was not set" }, + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + checkNotNull(financialTransactionEventToken) { + "`financialTransactionEventToken` is required but was not set" + }, + checkNotNull(financialTransactionToken) { + "`financialTransactionToken` is required but was not set" + }, cardToken, descriptor, additionalProperties.toImmutable(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Statements.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Statements.kt index 6e5db4e4..0dac475f 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Statements.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Statements.kt @@ -32,9 +32,9 @@ private constructor( fun hasMore(): Boolean = hasMore.getRequired("has_more") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data - @JsonProperty("has_more") @ExcludeMissing fun _hasMore() = hasMore + @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore @JsonAnyGetter @ExcludeMissing @@ -59,19 +59,32 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() - private var hasMore: JsonField = JsonMissing.of() + private var data: JsonField>? = null + private var hasMore: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(statements: Statements) = apply { - data = statements.data + data = statements.data.map { it.toMutableList() } hasMore = statements.hasMore additionalProperties = statements.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: Statement) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(data) + } + } fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) @@ -98,8 +111,9 @@ private constructor( fun build(): Statements = Statements( - data.map { it.toImmutable() }, - hasMore, + checkNotNull(data) { "`data` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(hasMore) { "`hasMore` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SubscriptionRetrieveSecretResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SubscriptionRetrieveSecretResponse.kt index ba47d2c1..83c17e2f 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SubscriptionRetrieveSecretResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SubscriptionRetrieveSecretResponse.kt @@ -29,7 +29,7 @@ private constructor( fun secret(): String? = secret.getNullable("secret") /** The secret for the event subscription. */ - @JsonProperty("secret") @ExcludeMissing fun _secret() = secret + @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationSimulateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationSimulateParams.kt index ce7e043a..a8288a28 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationSimulateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationSimulateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -43,12 +44,25 @@ constructor( */ fun cardExpiryCheck(): CardExpiryCheck? = body.cardExpiryCheck() - fun _additionalHeaders(): Headers = additionalHeaders + fun _merchant(): JsonField = body._merchant() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Sixteen digit card number. */ + fun _pan(): JsonField = body._pan() + + fun _transaction(): JsonField = body._transaction() + + /** + * When set will use the following values as part of the Simulated Authentication. When not set + * defaults to MATCH + */ + fun _cardExpiryCheck(): JsonField = body._cardExpiryCheck() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): ThreeDSAuthenticationSimulateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -59,31 +73,66 @@ constructor( class ThreeDSAuthenticationSimulateBody @JsonCreator internal constructor( - @JsonProperty("merchant") private val merchant: Merchant, - @JsonProperty("pan") private val pan: String, - @JsonProperty("transaction") private val transaction: Transaction, - @JsonProperty("card_expiry_check") private val cardExpiryCheck: CardExpiryCheck?, + @JsonProperty("merchant") + @ExcludeMissing + private val merchant: JsonField = JsonMissing.of(), + @JsonProperty("pan") @ExcludeMissing private val pan: JsonField = JsonMissing.of(), + @JsonProperty("transaction") + @ExcludeMissing + private val transaction: JsonField = JsonMissing.of(), + @JsonProperty("card_expiry_check") + @ExcludeMissing + private val cardExpiryCheck: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("merchant") fun merchant(): Merchant = merchant + fun merchant(): Merchant = merchant.getRequired("merchant") /** Sixteen digit card number. */ - @JsonProperty("pan") fun pan(): String = pan + fun pan(): String = pan.getRequired("pan") - @JsonProperty("transaction") fun transaction(): Transaction = transaction + fun transaction(): Transaction = transaction.getRequired("transaction") /** * When set will use the following values as part of the Simulated Authentication. When not * set defaults to MATCH */ - @JsonProperty("card_expiry_check") fun cardExpiryCheck(): CardExpiryCheck? = cardExpiryCheck + fun cardExpiryCheck(): CardExpiryCheck? = cardExpiryCheck.getNullable("card_expiry_check") + + @JsonProperty("merchant") @ExcludeMissing fun _merchant(): JsonField = merchant + + /** Sixteen digit card number. */ + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan + + @JsonProperty("transaction") + @ExcludeMissing + fun _transaction(): JsonField = transaction + + /** + * When set will use the following values as part of the Simulated Authentication. When not + * set defaults to MATCH + */ + @JsonProperty("card_expiry_check") + @ExcludeMissing + fun _cardExpiryCheck(): JsonField = cardExpiryCheck @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ThreeDSAuthenticationSimulateBody = apply { + if (!validated) { + merchant().validate() + pan() + transaction().validate() + cardExpiryCheck() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -93,10 +142,10 @@ constructor( class Builder { - private var merchant: Merchant? = null - private var pan: String? = null - private var transaction: Transaction? = null - private var cardExpiryCheck: CardExpiryCheck? = null + private var merchant: JsonField? = null + private var pan: JsonField? = null + private var transaction: JsonField? = null + private var cardExpiryCheck: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -110,18 +159,34 @@ constructor( threeDSAuthenticationSimulateBody.additionalProperties.toMutableMap() } - fun merchant(merchant: Merchant) = apply { this.merchant = merchant } + fun merchant(merchant: Merchant) = merchant(JsonField.of(merchant)) + + fun merchant(merchant: JsonField) = apply { this.merchant = merchant } /** Sixteen digit card number. */ - fun pan(pan: String) = apply { this.pan = pan } + fun pan(pan: String) = pan(JsonField.of(pan)) - fun transaction(transaction: Transaction) = apply { this.transaction = transaction } + /** Sixteen digit card number. */ + fun pan(pan: JsonField) = apply { this.pan = pan } + + fun transaction(transaction: Transaction) = transaction(JsonField.of(transaction)) + + fun transaction(transaction: JsonField) = apply { + this.transaction = transaction + } /** * When set will use the following values as part of the Simulated Authentication. When * not set defaults to MATCH */ - fun cardExpiryCheck(cardExpiryCheck: CardExpiryCheck?) = apply { + fun cardExpiryCheck(cardExpiryCheck: CardExpiryCheck) = + cardExpiryCheck(JsonField.of(cardExpiryCheck)) + + /** + * When set will use the following values as part of the Simulated Authentication. When + * not set defaults to MATCH + */ + fun cardExpiryCheck(cardExpiryCheck: JsonField) = apply { this.cardExpiryCheck = cardExpiryCheck } @@ -198,19 +263,55 @@ constructor( fun merchant(merchant: Merchant) = apply { body.merchant(merchant) } + fun merchant(merchant: JsonField) = apply { body.merchant(merchant) } + /** Sixteen digit card number. */ fun pan(pan: String) = apply { body.pan(pan) } + /** Sixteen digit card number. */ + fun pan(pan: JsonField) = apply { body.pan(pan) } + fun transaction(transaction: Transaction) = apply { body.transaction(transaction) } + fun transaction(transaction: JsonField) = apply { + body.transaction(transaction) + } + /** * When set will use the following values as part of the Simulated Authentication. When not * set defaults to MATCH */ - fun cardExpiryCheck(cardExpiryCheck: CardExpiryCheck?) = apply { + fun cardExpiryCheck(cardExpiryCheck: CardExpiryCheck) = apply { body.cardExpiryCheck(cardExpiryCheck) } + /** + * When set will use the following values as part of the Simulated Authentication. When not + * set defaults to MATCH + */ + fun cardExpiryCheck(cardExpiryCheck: JsonField) = apply { + body.cardExpiryCheck(cardExpiryCheck) + } + + 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) @@ -309,25 +410,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ThreeDSAuthenticationSimulateParams = ThreeDSAuthenticationSimulateParams( body.build(), @@ -340,10 +422,14 @@ constructor( class Merchant @JsonCreator private constructor( - @JsonProperty("id") private val id: String, - @JsonProperty("country") private val country: String, - @JsonProperty("mcc") private val mcc: String, - @JsonProperty("name") private val name: String, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("mcc") @ExcludeMissing private val mcc: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -352,27 +438,60 @@ constructor( * Unique identifier to identify the payment card acceptor. Corresponds to * `merchant_acceptor_id` in authorization. */ - @JsonProperty("id") fun id(): String = id + fun id(): String = id.getRequired("id") + + /** + * Country of the address provided by the cardholder in ISO 3166-1 alpha-3 format (e.g. USA) + */ + fun country(): String = country.getRequired("country") + + /** + * Merchant category code for the transaction to be simulated. A four-digit number listed in + * ISO 18245. Supported merchant category codes can be found + * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). + */ + fun mcc(): String = mcc.getRequired("mcc") + + /** Merchant descriptor, corresponds to `descriptor` in authorization. */ + fun name(): String = name.getRequired("name") + + /** + * Unique identifier to identify the payment card acceptor. Corresponds to + * `merchant_acceptor_id` in authorization. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Country of the address provided by the cardholder in ISO 3166-1 alpha-3 format (e.g. USA) */ - @JsonProperty("country") fun country(): String = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** * Merchant category code for the transaction to be simulated. A four-digit number listed in * ISO 18245. Supported merchant category codes can be found * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). */ - @JsonProperty("mcc") fun mcc(): String = mcc + @JsonProperty("mcc") @ExcludeMissing fun _mcc(): JsonField = mcc /** Merchant descriptor, corresponds to `descriptor` in authorization. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Merchant = apply { + if (!validated) { + id() + country() + mcc() + name() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -382,10 +501,10 @@ constructor( class Builder { - private var id: String? = null - private var country: String? = null - private var mcc: String? = null - private var name: String? = null + private var id: JsonField? = null + private var country: JsonField? = null + private var mcc: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(merchant: Merchant) = apply { @@ -400,23 +519,45 @@ constructor( * Unique identifier to identify the payment card acceptor. Corresponds to * `merchant_acceptor_id` in authorization. */ - fun id(id: String) = apply { this.id = id } + fun id(id: String) = id(JsonField.of(id)) + + /** + * Unique identifier to identify the payment card acceptor. Corresponds to + * `merchant_acceptor_id` in authorization. + */ + fun id(id: JsonField) = apply { this.id = id } /** * Country of the address provided by the cardholder in ISO 3166-1 alpha-3 format (e.g. * USA) */ - fun country(country: String) = apply { this.country = country } + fun country(country: String) = country(JsonField.of(country)) + + /** + * Country of the address provided by the cardholder in ISO 3166-1 alpha-3 format (e.g. + * USA) + */ + fun country(country: JsonField) = apply { this.country = country } + + /** + * Merchant category code for the transaction to be simulated. A four-digit number + * listed in ISO 18245. Supported merchant category codes can be found + * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). + */ + fun mcc(mcc: String) = mcc(JsonField.of(mcc)) /** * Merchant category code for the transaction to be simulated. A four-digit number * listed in ISO 18245. Supported merchant category codes can be found * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). */ - fun mcc(mcc: String) = apply { this.mcc = mcc } + fun mcc(mcc: JsonField) = apply { this.mcc = mcc } /** Merchant descriptor, corresponds to `descriptor` in authorization. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** Merchant descriptor, corresponds to `descriptor` in authorization. */ + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -469,22 +610,42 @@ constructor( class Transaction @JsonCreator private constructor( - @JsonProperty("amount") private val amount: Long, - @JsonProperty("currency") private val currency: String, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Amount (in cents) to authenticate. */ - @JsonProperty("amount") fun amount(): Long = amount + fun amount(): Long = amount.getRequired("amount") + + /** 3-digit alphabetic ISO 4217 currency code. */ + fun currency(): String = currency.getRequired("currency") + + /** Amount (in cents) to authenticate. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** 3-digit alphabetic ISO 4217 currency code. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Transaction = apply { + if (!validated) { + amount() + currency() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -494,8 +655,8 @@ constructor( class Builder { - private var amount: Long? = null - private var currency: String? = null + private var amount: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(transaction: Transaction) = apply { @@ -505,10 +666,16 @@ constructor( } /** Amount (in cents) to authenticate. */ - fun amount(amount: Long) = apply { this.amount = amount } + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** Amount (in cents) to authenticate. */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** 3-digit alphabetic ISO 4217 currency code. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** 3-digit alphabetic ISO 4217 currency code. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSDecisioningChallengeResponseParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSDecisioningChallengeResponseParams.kt index 8179c581..c7635569 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSDecisioningChallengeResponseParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSDecisioningChallengeResponseParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -33,12 +35,22 @@ constructor( /** Whether the Cardholder has Approved or Declined the issued Challenge */ fun challengeResponse(): ChallengeResult = body.challengeResponse() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * Globally unique identifier for the 3DS authentication. This token is sent as part of the + * initial 3DS Decisioning Request and as part of the 3DS Challenge Event in the + * [ThreeDSAuthentication](#/components/schemas/ThreeDSAuthentication) object + */ + fun _token(): JsonField = body._token() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Whether the Cardholder has Approved or Declined the issued Challenge */ + fun _challengeResponse(): JsonField = body._challengeResponse() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): ThreeDSDecisioningChallengeResponseBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -49,8 +61,12 @@ constructor( class ThreeDSDecisioningChallengeResponseBody @JsonCreator internal constructor( - @JsonProperty("token") private val token: String, - @JsonProperty("challenge_response") private val challengeResponse: ChallengeResult, + @JsonProperty("token") + @ExcludeMissing + private val token: JsonField = JsonMissing.of(), + @JsonProperty("challenge_response") + @ExcludeMissing + private val challengeResponse: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -60,16 +76,38 @@ constructor( * initial 3DS Decisioning Request and as part of the 3DS Challenge Event in the * [ThreeDSAuthentication](#/components/schemas/ThreeDSAuthentication) object */ - @JsonProperty("token") fun token(): String = token + fun token(): String = token.getRequired("token") + + /** Whether the Cardholder has Approved or Declined the issued Challenge */ + fun challengeResponse(): ChallengeResult = + challengeResponse.getRequired("challenge_response") + + /** + * Globally unique identifier for the 3DS authentication. This token is sent as part of the + * initial 3DS Decisioning Request and as part of the 3DS Challenge Event in the + * [ThreeDSAuthentication](#/components/schemas/ThreeDSAuthentication) object + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Whether the Cardholder has Approved or Declined the issued Challenge */ @JsonProperty("challenge_response") - fun challengeResponse(): ChallengeResult = challengeResponse + @ExcludeMissing + fun _challengeResponse(): JsonField = challengeResponse @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ThreeDSDecisioningChallengeResponseBody = apply { + if (!validated) { + token() + challengeResponse() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -79,8 +117,8 @@ constructor( class Builder { - private var token: String? = null - private var challengeResponse: ChallengeResult? = null + private var token: JsonField? = null + private var challengeResponse: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -97,10 +135,21 @@ constructor( * the initial 3DS Decisioning Request and as part of the 3DS Challenge Event in the * [ThreeDSAuthentication](#/components/schemas/ThreeDSAuthentication) object */ - fun token(token: String) = apply { this.token = token } + fun token(token: String) = token(JsonField.of(token)) + + /** + * Globally unique identifier for the 3DS authentication. This token is sent as part of + * the initial 3DS Decisioning Request and as part of the 3DS Challenge Event in the + * [ThreeDSAuthentication](#/components/schemas/ThreeDSAuthentication) object + */ + fun token(token: JsonField) = apply { this.token = token } /** Whether the Cardholder has Approved or Declined the issued Challenge */ - fun challengeResponse(challengeResponse: ChallengeResult) = apply { + fun challengeResponse(challengeResponse: ChallengeResult) = + challengeResponse(JsonField.of(challengeResponse)) + + /** Whether the Cardholder has Approved or Declined the issued Challenge */ + fun challengeResponse(challengeResponse: JsonField) = apply { this.challengeResponse = challengeResponse } @@ -183,11 +232,42 @@ constructor( */ fun token(token: String) = apply { body.token(token) } + /** + * Globally unique identifier for the 3DS authentication. This token is sent as part of the + * initial 3DS Decisioning Request and as part of the 3DS Challenge Event in the + * [ThreeDSAuthentication](#/components/schemas/ThreeDSAuthentication) object + */ + fun token(token: JsonField) = apply { body.token(token) } + /** Whether the Cardholder has Approved or Declined the issued Challenge */ fun challengeResponse(challengeResponse: ChallengeResult) = apply { body.challengeResponse(challengeResponse) } + /** Whether the Cardholder has Approved or Declined the issued Challenge */ + fun challengeResponse(challengeResponse: JsonField) = apply { + body.challengeResponse(challengeResponse) + } + + 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) @@ -286,25 +366,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ThreeDSDecisioningChallengeResponseParams = ThreeDSDecisioningChallengeResponseParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSDecisioningSimulateChallengeParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSDecisioningSimulateChallengeParams.kt index 4c339ab6..60ea93ea 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSDecisioningSimulateChallengeParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSDecisioningSimulateChallengeParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -33,12 +35,18 @@ constructor( */ fun token(): String? = body.token() + /** + * A unique token returned as part of a /v1/three_ds_authentication/simulate call that responded + * with a CHALLENGE_REQUESTED status. + */ + fun _token(): JsonField = body._token() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): ThreeDSDecisioningSimulateChallengeBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -49,7 +57,9 @@ constructor( class ThreeDSDecisioningSimulateChallengeBody @JsonCreator internal constructor( - @JsonProperty("token") private val token: String?, + @JsonProperty("token") + @ExcludeMissing + private val token: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -58,12 +68,27 @@ constructor( * A unique token returned as part of a /v1/three_ds_authentication/simulate call that * responded with a CHALLENGE_REQUESTED status. */ - @JsonProperty("token") fun token(): String? = token + fun token(): String? = token.getNullable("token") + + /** + * A unique token returned as part of a /v1/three_ds_authentication/simulate call that + * responded with a CHALLENGE_REQUESTED status. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ThreeDSDecisioningSimulateChallengeBody = apply { + if (!validated) { + token() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -73,7 +98,7 @@ constructor( class Builder { - private var token: String? = null + private var token: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -88,7 +113,13 @@ constructor( * A unique token returned as part of a /v1/three_ds_authentication/simulate call that * responded with a CHALLENGE_REQUESTED status. */ - fun token(token: String?) = apply { this.token = token } + fun token(token: String) = token(JsonField.of(token)) + + /** + * A unique token returned as part of a /v1/three_ds_authentication/simulate call that + * responded with a CHALLENGE_REQUESTED status. + */ + fun token(token: JsonField) = apply { this.token = token } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -160,7 +191,32 @@ constructor( * A unique token returned as part of a /v1/three_ds_authentication/simulate call that * responded with a CHALLENGE_REQUESTED status. */ - fun token(token: String?) = apply { body.token(token) } + fun token(token: String) = apply { body.token(token) } + + /** + * A unique token returned as part of a /v1/three_ds_authentication/simulate call that + * responded with a CHALLENGE_REQUESTED status. + */ + fun token(token: JsonField) = apply { body.token(token) } + + 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() @@ -260,25 +316,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ThreeDSDecisioningSimulateChallengeParams = ThreeDSDecisioningSimulateChallengeParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSDecisioningSimulateChallengeResponseParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSDecisioningSimulateChallengeResponseParams.kt index b0130ccd..f467f8ac 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSDecisioningSimulateChallengeResponseParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ThreeDSDecisioningSimulateChallengeResponseParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -36,12 +38,22 @@ constructor( /** Whether the Cardholder has Approved or Declined the issued Challenge */ fun challengeResponse(): ChallengeResult = body.challengeResponse() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * Globally unique identifier for the 3DS authentication. This token is sent as part of the + * initial 3DS Decisioning Request and as part of the 3DS Challenge Event in the + * [ThreeDSAuthentication](#/components/schemas/ThreeDSAuthentication) object + */ + fun _token(): JsonField = body._token() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Whether the Cardholder has Approved or Declined the issued Challenge */ + fun _challengeResponse(): JsonField = body._challengeResponse() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): ThreeDSDecisioningSimulateChallengeResponseBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -52,8 +64,12 @@ constructor( class ThreeDSDecisioningSimulateChallengeResponseBody @JsonCreator internal constructor( - @JsonProperty("token") private val token: String, - @JsonProperty("challenge_response") private val challengeResponse: ChallengeResult, + @JsonProperty("token") + @ExcludeMissing + private val token: JsonField = JsonMissing.of(), + @JsonProperty("challenge_response") + @ExcludeMissing + private val challengeResponse: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -63,16 +79,38 @@ constructor( * initial 3DS Decisioning Request and as part of the 3DS Challenge Event in the * [ThreeDSAuthentication](#/components/schemas/ThreeDSAuthentication) object */ - @JsonProperty("token") fun token(): String = token + fun token(): String = token.getRequired("token") + + /** Whether the Cardholder has Approved or Declined the issued Challenge */ + fun challengeResponse(): ChallengeResult = + challengeResponse.getRequired("challenge_response") + + /** + * Globally unique identifier for the 3DS authentication. This token is sent as part of the + * initial 3DS Decisioning Request and as part of the 3DS Challenge Event in the + * [ThreeDSAuthentication](#/components/schemas/ThreeDSAuthentication) object + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Whether the Cardholder has Approved or Declined the issued Challenge */ @JsonProperty("challenge_response") - fun challengeResponse(): ChallengeResult = challengeResponse + @ExcludeMissing + fun _challengeResponse(): JsonField = challengeResponse @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ThreeDSDecisioningSimulateChallengeResponseBody = apply { + if (!validated) { + token() + challengeResponse() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -82,8 +120,8 @@ constructor( class Builder { - private var token: String? = null - private var challengeResponse: ChallengeResult? = null + private var token: JsonField? = null + private var challengeResponse: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -103,10 +141,21 @@ constructor( * the initial 3DS Decisioning Request and as part of the 3DS Challenge Event in the * [ThreeDSAuthentication](#/components/schemas/ThreeDSAuthentication) object */ - fun token(token: String) = apply { this.token = token } + fun token(token: String) = token(JsonField.of(token)) + + /** + * Globally unique identifier for the 3DS authentication. This token is sent as part of + * the initial 3DS Decisioning Request and as part of the 3DS Challenge Event in the + * [ThreeDSAuthentication](#/components/schemas/ThreeDSAuthentication) object + */ + fun token(token: JsonField) = apply { this.token = token } /** Whether the Cardholder has Approved or Declined the issued Challenge */ - fun challengeResponse(challengeResponse: ChallengeResult) = apply { + fun challengeResponse(challengeResponse: ChallengeResult) = + challengeResponse(JsonField.of(challengeResponse)) + + /** Whether the Cardholder has Approved or Declined the issued Challenge */ + fun challengeResponse(challengeResponse: JsonField) = apply { this.challengeResponse = challengeResponse } @@ -190,11 +239,42 @@ constructor( */ fun token(token: String) = apply { body.token(token) } + /** + * Globally unique identifier for the 3DS authentication. This token is sent as part of the + * initial 3DS Decisioning Request and as part of the 3DS Challenge Event in the + * [ThreeDSAuthentication](#/components/schemas/ThreeDSAuthentication) object + */ + fun token(token: JsonField) = apply { body.token(token) } + /** Whether the Cardholder has Approved or Declined the issued Challenge */ fun challengeResponse(challengeResponse: ChallengeResult) = apply { body.challengeResponse(challengeResponse) } + /** Whether the Cardholder has Approved or Declined the issued Challenge */ + fun challengeResponse(challengeResponse: JsonField) = apply { + body.challengeResponse(challengeResponse) + } + + 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) @@ -293,25 +373,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): ThreeDSDecisioningSimulateChallengeResponseParams = ThreeDSDecisioningSimulateChallengeResponseParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Tokenization.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Tokenization.kt index d2c1074d..6c59a665 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Tokenization.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Tokenization.kt @@ -96,37 +96,43 @@ private constructor( fun events(): List? = events.getNullable("events") /** Globally unique identifier for a Tokenization */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** The account token associated with the card being tokenized. */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** The card token associated with the card being tokenized. */ - @JsonProperty("card_token") @ExcludeMissing fun _cardToken() = cardToken + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken /** Date and time when the tokenization first occurred. UTC time zone. */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** The status of the tokenization request */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** The entity that requested the tokenization. Represents a Digital Wallet or merchant. */ @JsonProperty("token_requestor_name") @ExcludeMissing - fun _tokenRequestorName() = tokenRequestorName + fun _tokenRequestorName(): JsonField = tokenRequestorName /** The network's unique reference for the tokenization. */ @JsonProperty("token_unique_reference") @ExcludeMissing - fun _tokenUniqueReference() = tokenUniqueReference + fun _tokenUniqueReference(): JsonField = tokenUniqueReference /** The channel through which the tokenization was made. */ @JsonProperty("tokenization_channel") @ExcludeMissing - fun _tokenizationChannel() = tokenizationChannel + fun _tokenizationChannel(): JsonField = tokenizationChannel /** Latest date and time when the tokenization was updated. UTC time zone. */ - @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt() = updatedAt + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt /** * Specifies the digital card art displayed in the user’s digital wallet after tokenization. @@ -135,10 +141,12 @@ private constructor( */ @JsonProperty("digital_card_art_token") @ExcludeMissing - fun _digitalCardArtToken() = digitalCardArtToken + fun _digitalCardArtToken(): JsonField = digitalCardArtToken /** A list of events related to the tokenization. */ - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events @JsonAnyGetter @ExcludeMissing @@ -172,17 +180,17 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountToken: JsonField = JsonMissing.of() - private var cardToken: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var tokenRequestorName: JsonField = JsonMissing.of() - private var tokenUniqueReference: JsonField = JsonMissing.of() - private var tokenizationChannel: JsonField = JsonMissing.of() - private var updatedAt: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var accountToken: JsonField? = null + private var cardToken: JsonField? = null + private var createdAt: JsonField? = null + private var status: JsonField? = null + private var tokenRequestorName: JsonField? = null + private var tokenUniqueReference: JsonField? = null + private var tokenizationChannel: JsonField? = null + private var updatedAt: JsonField? = null private var digitalCardArtToken: JsonField = JsonMissing.of() - private var events: JsonField> = JsonMissing.of() + private var events: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tokenization: Tokenization) = apply { @@ -196,7 +204,7 @@ private constructor( tokenizationChannel = tokenization.tokenizationChannel updatedAt = tokenization.updatedAt digitalCardArtToken = tokenization.digitalCardArtToken - events = tokenization.events + events = tokenization.events.map { it.toMutableList() } additionalProperties = tokenization.additionalProperties.toMutableMap() } @@ -288,7 +296,21 @@ private constructor( fun events(events: List) = events(JsonField.of(events)) /** A list of events related to the tokenization. */ - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** A list of events related to the tokenization. */ + fun addEvent(event: TokenizationEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(event) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -311,17 +333,23 @@ private constructor( fun build(): Tokenization = Tokenization( - token, - accountToken, - cardToken, - createdAt, - status, - tokenRequestorName, - tokenUniqueReference, - tokenizationChannel, - updatedAt, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountToken) { "`accountToken` is required but was not set" }, + checkNotNull(cardToken) { "`cardToken` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(tokenRequestorName) { + "`tokenRequestorName` is required but was not set" + }, + checkNotNull(tokenUniqueReference) { + "`tokenUniqueReference` is required but was not set" + }, + checkNotNull(tokenizationChannel) { + "`tokenizationChannel` is required but was not set" + }, + checkNotNull(updatedAt) { "`updatedAt` is required but was not set" }, digitalCardArtToken, - events.map { it.toImmutable() }, + (events ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -612,16 +640,18 @@ private constructor( fun type(): Type? = type.getNullable("type") /** Globally unique identifier for a Tokenization Event */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Date and time when the tokenization event first occurred. UTC time zone. */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** Enum representing the result of the tokenization event */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** Enum representing the type of tokenization event that occurred */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationDecisioningRotateSecretResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationDecisioningRotateSecretResponse.kt index 92404f9a..466b70ba 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationDecisioningRotateSecretResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationDecisioningRotateSecretResponse.kt @@ -29,7 +29,7 @@ private constructor( fun secret(): String? = secret.getNullable("secret") /** The new Tokenization Decisioning HMAC secret */ - @JsonProperty("secret") @ExcludeMissing fun _secret() = secret + @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationResendActivationCodeParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationResendActivationCodeParams.kt index 575fd201..99703140 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationResendActivationCodeParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationResendActivationCodeParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -45,12 +46,19 @@ constructor( */ fun activationMethodType(): ActivationMethodType? = body.activationMethodType() + /** + * The communication method that the user has selected to use to receive the authentication + * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" + */ + fun _activationMethodType(): JsonField = body._activationMethodType() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): TokenizationResendActivationCodeBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -69,23 +77,42 @@ constructor( @JsonCreator internal constructor( @JsonProperty("activation_method_type") - private val activationMethodType: ActivationMethodType?, + @ExcludeMissing + private val activationMethodType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * The communication method that the user has selected to use to receive the authentication + * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" + */ + fun activationMethodType(): ActivationMethodType? = + activationMethodType.getNullable("activation_method_type") + /** * The communication method that the user has selected to use to receive the authentication * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = * "EMAIL_TO_CARDHOLDER_ADDRESS" */ @JsonProperty("activation_method_type") - fun activationMethodType(): ActivationMethodType? = activationMethodType + @ExcludeMissing + fun _activationMethodType(): JsonField = activationMethodType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TokenizationResendActivationCodeBody = apply { + if (!validated) { + activationMethodType() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -95,7 +122,7 @@ constructor( class Builder { - private var activationMethodType: ActivationMethodType? = null + private var activationMethodType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -111,9 +138,18 @@ constructor( * authentication code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = * "EMAIL_TO_CARDHOLDER_ADDRESS" */ - fun activationMethodType(activationMethodType: ActivationMethodType?) = apply { - this.activationMethodType = activationMethodType - } + fun activationMethodType(activationMethodType: ActivationMethodType) = + activationMethodType(JsonField.of(activationMethodType)) + + /** + * The communication method that the user has selected to use to receive the + * authentication code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" + */ + fun activationMethodType(activationMethodType: JsonField) = + apply { + this.activationMethodType = activationMethodType + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -194,10 +230,38 @@ constructor( * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = * "EMAIL_TO_CARDHOLDER_ADDRESS" */ - fun activationMethodType(activationMethodType: ActivationMethodType?) = apply { + fun activationMethodType(activationMethodType: ActivationMethodType) = apply { body.activationMethodType(activationMethodType) } + /** + * The communication method that the user has selected to use to receive the authentication + * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" + */ + fun activationMethodType(activationMethodType: JsonField) = apply { + body.activationMethodType(activationMethodType) + } + + 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) @@ -296,25 +360,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): TokenizationResendActivationCodeParams = TokenizationResendActivationCodeParams( checkNotNull(tokenizationToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationRetrieveResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationRetrieveResponse.kt index 9c66a00b..6c330d6a 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationRetrieveResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationRetrieveResponse.kt @@ -27,7 +27,7 @@ private constructor( fun data(): Tokenization? = data.getNullable("data") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationSecret.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationSecret.kt index 9a2124f4..da04f4a3 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationSecret.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationSecret.kt @@ -29,7 +29,7 @@ private constructor( fun secret(): String? = secret.getNullable("secret") /** The Tokenization Decisioning HMAC secret */ - @JsonProperty("secret") @ExcludeMissing fun _secret() = secret + @JsonProperty("secret") @ExcludeMissing fun _secret(): JsonField = secret @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationSimulateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationSimulateParams.kt index fc5cbb2f..ddd81323 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationSimulateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationSimulateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -62,12 +63,46 @@ constructor( /** The decision that the Digital Wallet's recommend */ fun walletRecommendedDecision(): WalletRecommendedDecision? = body.walletRecommendedDecision() - fun _additionalHeaders(): Headers = additionalHeaders + /** The three digit cvv for the card. */ + fun _cvv(): JsonField = body._cvv() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The expiration date of the card in 'MM/YY' format. */ + fun _expirationDate(): JsonField = body._expirationDate() + + /** The sixteen digit card number. */ + fun _pan(): JsonField = body._pan() + + /** The source of the tokenization request. */ + fun _tokenizationSource(): JsonField = body._tokenizationSource() + + /** + * The account score (1-5) that represents how the Digital Wallet's view on how reputable an end + * user's account is. + */ + fun _accountScore(): JsonField = body._accountScore() + + /** + * The device score (1-5) that represents how the Digital Wallet's view on how reputable an end + * user's device is. + */ + fun _deviceScore(): JsonField = body._deviceScore() + + /** + * Optional field to specify the token requestor name for a merchant token simulation. Ignored + * when tokenization_source is not MERCHANT. + */ + fun _entity(): JsonField = body._entity() + + /** The decision that the Digital Wallet's recommend */ + fun _walletRecommendedDecision(): JsonField = + body._walletRecommendedDecision() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): TokenizationSimulateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -78,58 +113,130 @@ constructor( class TokenizationSimulateBody @JsonCreator internal constructor( - @JsonProperty("cvv") private val cvv: String, - @JsonProperty("expiration_date") private val expirationDate: String, - @JsonProperty("pan") private val pan: String, - @JsonProperty("tokenization_source") private val tokenizationSource: TokenizationSource, - @JsonProperty("account_score") private val accountScore: Long?, - @JsonProperty("device_score") private val deviceScore: Long?, - @JsonProperty("entity") private val entity: String?, + @JsonProperty("cvv") @ExcludeMissing private val cvv: JsonField = JsonMissing.of(), + @JsonProperty("expiration_date") + @ExcludeMissing + private val expirationDate: JsonField = JsonMissing.of(), + @JsonProperty("pan") @ExcludeMissing private val pan: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_source") + @ExcludeMissing + private val tokenizationSource: JsonField = JsonMissing.of(), + @JsonProperty("account_score") + @ExcludeMissing + private val accountScore: JsonField = JsonMissing.of(), + @JsonProperty("device_score") + @ExcludeMissing + private val deviceScore: JsonField = JsonMissing.of(), + @JsonProperty("entity") + @ExcludeMissing + private val entity: JsonField = JsonMissing.of(), @JsonProperty("wallet_recommended_decision") - private val walletRecommendedDecision: WalletRecommendedDecision?, + @ExcludeMissing + private val walletRecommendedDecision: JsonField = + JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The three digit cvv for the card. */ - @JsonProperty("cvv") fun cvv(): String = cvv + fun cvv(): String = cvv.getRequired("cvv") /** The expiration date of the card in 'MM/YY' format. */ - @JsonProperty("expiration_date") fun expirationDate(): String = expirationDate + fun expirationDate(): String = expirationDate.getRequired("expiration_date") /** The sixteen digit card number. */ - @JsonProperty("pan") fun pan(): String = pan + fun pan(): String = pan.getRequired("pan") + + /** The source of the tokenization request. */ + fun tokenizationSource(): TokenizationSource = + tokenizationSource.getRequired("tokenization_source") + + /** + * The account score (1-5) that represents how the Digital Wallet's view on how reputable an + * end user's account is. + */ + fun accountScore(): Long? = accountScore.getNullable("account_score") + + /** + * The device score (1-5) that represents how the Digital Wallet's view on how reputable an + * end user's device is. + */ + fun deviceScore(): Long? = deviceScore.getNullable("device_score") + + /** + * Optional field to specify the token requestor name for a merchant token simulation. + * Ignored when tokenization_source is not MERCHANT. + */ + fun entity(): String? = entity.getNullable("entity") + + /** The decision that the Digital Wallet's recommend */ + fun walletRecommendedDecision(): WalletRecommendedDecision? = + walletRecommendedDecision.getNullable("wallet_recommended_decision") + + /** The three digit cvv for the card. */ + @JsonProperty("cvv") @ExcludeMissing fun _cvv(): JsonField = cvv + + /** The expiration date of the card in 'MM/YY' format. */ + @JsonProperty("expiration_date") + @ExcludeMissing + fun _expirationDate(): JsonField = expirationDate + + /** The sixteen digit card number. */ + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan /** The source of the tokenization request. */ @JsonProperty("tokenization_source") - fun tokenizationSource(): TokenizationSource = tokenizationSource + @ExcludeMissing + fun _tokenizationSource(): JsonField = tokenizationSource /** * The account score (1-5) that represents how the Digital Wallet's view on how reputable an * end user's account is. */ - @JsonProperty("account_score") fun accountScore(): Long? = accountScore + @JsonProperty("account_score") + @ExcludeMissing + fun _accountScore(): JsonField = accountScore /** * The device score (1-5) that represents how the Digital Wallet's view on how reputable an * end user's device is. */ - @JsonProperty("device_score") fun deviceScore(): Long? = deviceScore + @JsonProperty("device_score") + @ExcludeMissing + fun _deviceScore(): JsonField = deviceScore /** * Optional field to specify the token requestor name for a merchant token simulation. * Ignored when tokenization_source is not MERCHANT. */ - @JsonProperty("entity") fun entity(): String? = entity + @JsonProperty("entity") @ExcludeMissing fun _entity(): JsonField = entity /** The decision that the Digital Wallet's recommend */ @JsonProperty("wallet_recommended_decision") - fun walletRecommendedDecision(): WalletRecommendedDecision? = walletRecommendedDecision + @ExcludeMissing + fun _walletRecommendedDecision(): JsonField = + walletRecommendedDecision @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TokenizationSimulateBody = apply { + if (!validated) { + cvv() + expirationDate() + pan() + tokenizationSource() + accountScore() + deviceScore() + entity() + walletRecommendedDecision() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -139,14 +246,15 @@ constructor( class Builder { - private var cvv: String? = null - private var expirationDate: String? = null - private var pan: String? = null - private var tokenizationSource: TokenizationSource? = null - private var accountScore: Long? = null - private var deviceScore: Long? = null - private var entity: String? = null - private var walletRecommendedDecision: WalletRecommendedDecision? = null + private var cvv: JsonField? = null + private var expirationDate: JsonField? = null + private var pan: JsonField? = null + private var tokenizationSource: JsonField? = null + private var accountScore: JsonField = JsonMissing.of() + private var deviceScore: JsonField = JsonMissing.of() + private var entity: JsonField = JsonMissing.of() + private var walletRecommendedDecision: JsonField = + JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tokenizationSimulateBody: TokenizationSimulateBody) = apply { @@ -162,18 +270,32 @@ constructor( } /** The three digit cvv for the card. */ - fun cvv(cvv: String) = apply { this.cvv = cvv } + fun cvv(cvv: String) = cvv(JsonField.of(cvv)) + + /** The three digit cvv for the card. */ + fun cvv(cvv: JsonField) = apply { this.cvv = cvv } /** The expiration date of the card in 'MM/YY' format. */ - fun expirationDate(expirationDate: String) = apply { + fun expirationDate(expirationDate: String) = + expirationDate(JsonField.of(expirationDate)) + + /** The expiration date of the card in 'MM/YY' format. */ + fun expirationDate(expirationDate: JsonField) = apply { this.expirationDate = expirationDate } /** The sixteen digit card number. */ - fun pan(pan: String) = apply { this.pan = pan } + fun pan(pan: String) = pan(JsonField.of(pan)) + + /** The sixteen digit card number. */ + fun pan(pan: JsonField) = apply { this.pan = pan } /** The source of the tokenization request. */ - fun tokenizationSource(tokenizationSource: TokenizationSource) = apply { + fun tokenizationSource(tokenizationSource: TokenizationSource) = + tokenizationSource(JsonField.of(tokenizationSource)) + + /** The source of the tokenization request. */ + fun tokenizationSource(tokenizationSource: JsonField) = apply { this.tokenizationSource = tokenizationSource } @@ -181,37 +303,48 @@ constructor( * The account score (1-5) that represents how the Digital Wallet's view on how * reputable an end user's account is. */ - fun accountScore(accountScore: Long?) = apply { this.accountScore = accountScore } + fun accountScore(accountScore: Long) = accountScore(JsonField.of(accountScore)) /** * The account score (1-5) that represents how the Digital Wallet's view on how * reputable an end user's account is. */ - fun accountScore(accountScore: Long) = accountScore(accountScore as Long?) + fun accountScore(accountScore: JsonField) = apply { + this.accountScore = accountScore + } /** * The device score (1-5) that represents how the Digital Wallet's view on how reputable * an end user's device is. */ - fun deviceScore(deviceScore: Long?) = apply { this.deviceScore = deviceScore } + fun deviceScore(deviceScore: Long) = deviceScore(JsonField.of(deviceScore)) /** * The device score (1-5) that represents how the Digital Wallet's view on how reputable * an end user's device is. */ - fun deviceScore(deviceScore: Long) = deviceScore(deviceScore as Long?) + fun deviceScore(deviceScore: JsonField) = apply { this.deviceScore = deviceScore } + + /** + * Optional field to specify the token requestor name for a merchant token simulation. + * Ignored when tokenization_source is not MERCHANT. + */ + fun entity(entity: String) = entity(JsonField.of(entity)) /** * Optional field to specify the token requestor name for a merchant token simulation. * Ignored when tokenization_source is not MERCHANT. */ - fun entity(entity: String?) = apply { this.entity = entity } + fun entity(entity: JsonField) = apply { this.entity = entity } + + /** The decision that the Digital Wallet's recommend */ + fun walletRecommendedDecision(walletRecommendedDecision: WalletRecommendedDecision) = + walletRecommendedDecision(JsonField.of(walletRecommendedDecision)) /** The decision that the Digital Wallet's recommend */ - fun walletRecommendedDecision(walletRecommendedDecision: WalletRecommendedDecision?) = - apply { - this.walletRecommendedDecision = walletRecommendedDecision - } + fun walletRecommendedDecision( + walletRecommendedDecision: JsonField + ) = apply { this.walletRecommendedDecision = walletRecommendedDecision } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -289,53 +422,99 @@ constructor( /** The three digit cvv for the card. */ fun cvv(cvv: String) = apply { body.cvv(cvv) } + /** The three digit cvv for the card. */ + fun cvv(cvv: JsonField) = apply { body.cvv(cvv) } + /** The expiration date of the card in 'MM/YY' format. */ fun expirationDate(expirationDate: String) = apply { body.expirationDate(expirationDate) } + /** The expiration date of the card in 'MM/YY' format. */ + fun expirationDate(expirationDate: JsonField) = apply { + body.expirationDate(expirationDate) + } + /** The sixteen digit card number. */ fun pan(pan: String) = apply { body.pan(pan) } + /** The sixteen digit card number. */ + fun pan(pan: JsonField) = apply { body.pan(pan) } + /** The source of the tokenization request. */ fun tokenizationSource(tokenizationSource: TokenizationSource) = apply { body.tokenizationSource(tokenizationSource) } + /** The source of the tokenization request. */ + fun tokenizationSource(tokenizationSource: JsonField) = apply { + body.tokenizationSource(tokenizationSource) + } + /** * The account score (1-5) that represents how the Digital Wallet's view on how reputable an * end user's account is. */ - fun accountScore(accountScore: Long?) = apply { body.accountScore(accountScore) } + fun accountScore(accountScore: Long) = apply { body.accountScore(accountScore) } /** * The account score (1-5) that represents how the Digital Wallet's view on how reputable an * end user's account is. */ - fun accountScore(accountScore: Long) = accountScore(accountScore as Long?) + fun accountScore(accountScore: JsonField) = apply { body.accountScore(accountScore) } /** * The device score (1-5) that represents how the Digital Wallet's view on how reputable an * end user's device is. */ - fun deviceScore(deviceScore: Long?) = apply { body.deviceScore(deviceScore) } + fun deviceScore(deviceScore: Long) = apply { body.deviceScore(deviceScore) } /** * The device score (1-5) that represents how the Digital Wallet's view on how reputable an * end user's device is. */ - fun deviceScore(deviceScore: Long) = deviceScore(deviceScore as Long?) + fun deviceScore(deviceScore: JsonField) = apply { body.deviceScore(deviceScore) } /** * Optional field to specify the token requestor name for a merchant token simulation. * Ignored when tokenization_source is not MERCHANT. */ - fun entity(entity: String?) = apply { body.entity(entity) } + fun entity(entity: String) = apply { body.entity(entity) } + + /** + * Optional field to specify the token requestor name for a merchant token simulation. + * Ignored when tokenization_source is not MERCHANT. + */ + fun entity(entity: JsonField) = apply { body.entity(entity) } /** The decision that the Digital Wallet's recommend */ - fun walletRecommendedDecision(walletRecommendedDecision: WalletRecommendedDecision?) = + fun walletRecommendedDecision(walletRecommendedDecision: WalletRecommendedDecision) = apply { body.walletRecommendedDecision(walletRecommendedDecision) } + /** The decision that the Digital Wallet's recommend */ + fun walletRecommendedDecision( + walletRecommendedDecision: JsonField + ) = apply { body.walletRecommendedDecision(walletRecommendedDecision) } + + 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) @@ -434,25 +613,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): TokenizationSimulateParams = TokenizationSimulateParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationSimulateResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationSimulateResponse.kt index 56061a85..385ac4b5 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationSimulateResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationSimulateResponse.kt @@ -27,7 +27,7 @@ private constructor( fun data(): List? = data.getNullable("data") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonAnyGetter @ExcludeMissing @@ -51,17 +51,30 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tokenizationSimulateResponse: TokenizationSimulateResponse) = apply { - data = tokenizationSimulateResponse.data + data = tokenizationSimulateResponse.data.map { it.toMutableList() } additionalProperties = tokenizationSimulateResponse.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: Tokenization) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(data) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -84,7 +97,7 @@ private constructor( fun build(): TokenizationSimulateResponse = TokenizationSimulateResponse( - data.map { it.toImmutable() }, + (data ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable() ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtParams.kt index b4c29ec5..05774cd7 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -42,12 +44,20 @@ constructor( */ fun digitalCardArtToken(): String? = body.digitalCardArtToken() + /** + * Specifies the digital card art to be displayed in the user’s digital wallet for a + * tokenization. This artwork must be approved by the network and configured by Lithic to use. + * See + * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). + */ + fun _digitalCardArtToken(): JsonField = body._digitalCardArtToken() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): TokenizationUpdateDigitalCardArtBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -65,11 +75,22 @@ constructor( class TokenizationUpdateDigitalCardArtBody @JsonCreator internal constructor( - @JsonProperty("digital_card_art_token") private val digitalCardArtToken: String?, + @JsonProperty("digital_card_art_token") + @ExcludeMissing + private val digitalCardArtToken: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * Specifies the digital card art to be displayed in the user’s digital wallet for a + * tokenization. This artwork must be approved by the network and configured by Lithic to + * use. See + * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). + */ + fun digitalCardArtToken(): String? = + digitalCardArtToken.getNullable("digital_card_art_token") + /** * Specifies the digital card art to be displayed in the user’s digital wallet for a * tokenization. This artwork must be approved by the network and configured by Lithic to @@ -77,12 +98,22 @@ constructor( * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). */ @JsonProperty("digital_card_art_token") - fun digitalCardArtToken(): String? = digitalCardArtToken + @ExcludeMissing + fun _digitalCardArtToken(): JsonField = digitalCardArtToken @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TokenizationUpdateDigitalCardArtBody = apply { + if (!validated) { + digitalCardArtToken() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -92,7 +123,7 @@ constructor( class Builder { - private var digitalCardArtToken: String? = null + private var digitalCardArtToken: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -109,7 +140,16 @@ constructor( * to use. See * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). */ - fun digitalCardArtToken(digitalCardArtToken: String?) = apply { + fun digitalCardArtToken(digitalCardArtToken: String) = + digitalCardArtToken(JsonField.of(digitalCardArtToken)) + + /** + * Specifies the digital card art to be displayed in the user’s digital wallet for a + * tokenization. This artwork must be approved by the network and configured by Lithic + * to use. See + * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). + */ + fun digitalCardArtToken(digitalCardArtToken: JsonField) = apply { this.digitalCardArtToken = digitalCardArtToken } @@ -193,10 +233,39 @@ constructor( * use. See * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). */ - fun digitalCardArtToken(digitalCardArtToken: String?) = apply { + fun digitalCardArtToken(digitalCardArtToken: String) = apply { body.digitalCardArtToken(digitalCardArtToken) } + /** + * Specifies the digital card art to be displayed in the user’s digital wallet for a + * tokenization. This artwork must be approved by the network and configured by Lithic to + * use. See + * [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art). + */ + fun digitalCardArtToken(digitalCardArtToken: JsonField) = apply { + body.digitalCardArtToken(digitalCardArtToken) + } + + 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) @@ -295,25 +364,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): TokenizationUpdateDigitalCardArtParams = TokenizationUpdateDigitalCardArtParams( checkNotNull(tokenizationToken) { diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtResponse.kt index bedbfe93..e28a4064 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtResponse.kt @@ -27,7 +27,7 @@ private constructor( fun data(): Tokenization? = data.getNullable("data") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Transaction.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Transaction.kt index 3143c6b6..4f983a23 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Transaction.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Transaction.kt @@ -186,17 +186,19 @@ private constructor( fun events(): List? = events.getNullable("events") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** The token for the account associated with this transaction. */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken /** * Fee assessed by the merchant and paid for by the cardholder in the smallest unit of the * currency. Will be zero if no fee is assessed. Rebates may be transmitted as a negative value * to indicate credited fees. */ - @JsonProperty("acquirer_fee") @ExcludeMissing fun _acquirerFee() = acquirerFee + @JsonProperty("acquirer_fee") @ExcludeMissing fun _acquirerFee(): JsonField = acquirerFee /** * Unique identifier assigned to a transaction by the acquirer that can be used in dispute and @@ -204,59 +206,65 @@ private constructor( */ @JsonProperty("acquirer_reference_number") @ExcludeMissing - fun _acquirerReferenceNumber() = acquirerReferenceNumber + fun _acquirerReferenceNumber(): JsonField = acquirerReferenceNumber /** * When the transaction is pending, this represents the authorization amount of the transaction * in the anticipated settlement currency. Once the transaction has settled, this field * represents the settled amount in the settlement currency. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("amounts") @ExcludeMissing fun _amounts() = amounts + @JsonProperty("amounts") @ExcludeMissing fun _amounts(): JsonField = amounts /** The authorization amount of the transaction in the anticipated settlement currency. */ @JsonProperty("authorization_amount") @ExcludeMissing - fun _authorizationAmount() = authorizationAmount + fun _authorizationAmount(): JsonField = authorizationAmount /** * A fixed-width 6-digit numeric identifier that can be used to identify a transaction with * networks. */ - @JsonProperty("authorization_code") @ExcludeMissing fun _authorizationCode() = authorizationCode + @JsonProperty("authorization_code") + @ExcludeMissing + fun _authorizationCode(): JsonField = authorizationCode - @JsonProperty("avs") @ExcludeMissing fun _avs() = avs + @JsonProperty("avs") @ExcludeMissing fun _avs(): JsonField = avs /** Token for the card used in this transaction. */ - @JsonProperty("card_token") @ExcludeMissing fun _cardToken() = cardToken + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken @JsonProperty("cardholder_authentication") @ExcludeMissing - fun _cardholderAuthentication() = cardholderAuthentication + fun _cardholderAuthentication(): JsonField = cardholderAuthentication /** Date and time when the transaction first occurred. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - @JsonProperty("merchant") @ExcludeMissing fun _merchant() = merchant + @JsonProperty("merchant") @ExcludeMissing fun _merchant(): JsonField = merchant /** Analogous to the 'amount', but in the merchant currency. */ - @JsonProperty("merchant_amount") @ExcludeMissing fun _merchantAmount() = merchantAmount + @JsonProperty("merchant_amount") + @ExcludeMissing + fun _merchantAmount(): JsonField = merchantAmount /** Analogous to the 'authorization_amount', but in the merchant currency. */ @JsonProperty("merchant_authorization_amount") @ExcludeMissing - fun _merchantAuthorizationAmount() = merchantAuthorizationAmount + fun _merchantAuthorizationAmount(): JsonField = merchantAuthorizationAmount /** 3-digit alphabetic ISO 4217 code for the local currency of the transaction. */ - @JsonProperty("merchant_currency") @ExcludeMissing fun _merchantCurrency() = merchantCurrency + @JsonProperty("merchant_currency") + @ExcludeMissing + fun _merchantCurrency(): JsonField = merchantCurrency /** * Card network of the authorization. Can be `INTERLINK`, `MAESTRO`, `MASTERCARD`, `VISA`, or * `UNKNOWN`. Value is `UNKNOWN` when Lithic cannot determine the network code from the upstream * provider. */ - @JsonProperty("network") @ExcludeMissing fun _network() = network + @JsonProperty("network") @ExcludeMissing fun _network(): JsonField = network /** * Network-provided score assessing risk level associated with a given authorization. Scores are @@ -264,24 +272,30 @@ private constructor( * risk. For Visa transactions, where the raw score has a range of 0-99, Lithic will normalize * the score by multiplying the raw score by 10x. */ - @JsonProperty("network_risk_score") @ExcludeMissing fun _networkRiskScore() = networkRiskScore + @JsonProperty("network_risk_score") + @ExcludeMissing + fun _networkRiskScore(): JsonField = networkRiskScore - @JsonProperty("pos") @ExcludeMissing fun _pos() = pos + @JsonProperty("pos") @ExcludeMissing fun _pos(): JsonField = pos - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** The settled amount of the transaction in the settlement currency. */ - @JsonProperty("settled_amount") @ExcludeMissing fun _settledAmount() = settledAmount + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount /** Status of the transaction. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("token_info") @ExcludeMissing fun _tokenInfo() = tokenInfo + @JsonProperty("token_info") @ExcludeMissing fun _tokenInfo(): JsonField = tokenInfo /** Date and time when the transaction last updated. UTC time zone. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events @JsonAnyGetter @ExcludeMissing @@ -329,31 +343,31 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountToken: JsonField = JsonMissing.of() - private var acquirerFee: JsonField = JsonMissing.of() - private var acquirerReferenceNumber: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var amounts: JsonField = JsonMissing.of() - private var authorizationAmount: JsonField = JsonMissing.of() - private var authorizationCode: JsonField = JsonMissing.of() - private var avs: JsonField = JsonMissing.of() - private var cardToken: JsonField = JsonMissing.of() - private var cardholderAuthentication: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var merchant: JsonField = JsonMissing.of() - private var merchantAmount: JsonField = JsonMissing.of() - private var merchantAuthorizationAmount: JsonField = JsonMissing.of() - private var merchantCurrency: JsonField = JsonMissing.of() - private var network: JsonField = JsonMissing.of() - private var networkRiskScore: JsonField = JsonMissing.of() - private var pos: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var settledAmount: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var tokenInfo: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() - private var events: JsonField> = JsonMissing.of() + private var token: JsonField? = null + private var accountToken: JsonField? = null + private var acquirerFee: JsonField? = null + private var acquirerReferenceNumber: JsonField? = null + private var amount: JsonField? = null + private var amounts: JsonField? = null + private var authorizationAmount: JsonField? = null + private var authorizationCode: JsonField? = null + private var avs: JsonField? = null + private var cardToken: JsonField? = null + private var cardholderAuthentication: JsonField? = null + private var created: JsonField? = null + private var merchant: JsonField? = null + private var merchantAmount: JsonField? = null + private var merchantAuthorizationAmount: JsonField? = null + private var merchantCurrency: JsonField? = null + private var network: JsonField? = null + private var networkRiskScore: JsonField? = null + private var pos: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var tokenInfo: JsonField? = null + private var updated: JsonField? = null + private var events: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(transaction: Transaction) = apply { @@ -381,7 +395,7 @@ private constructor( status = transaction.status tokenInfo = transaction.tokenInfo updated = transaction.updated - events = transaction.events + events = transaction.events.map { it.toMutableList() } additionalProperties = transaction.additionalProperties.toMutableMap() } @@ -404,7 +418,14 @@ private constructor( * currency. Will be zero if no fee is assessed. Rebates may be transmitted as a negative * value to indicate credited fees. */ - fun acquirerFee(acquirerFee: Long) = acquirerFee(JsonField.of(acquirerFee)) + fun acquirerFee(acquirerFee: Long?) = acquirerFee(JsonField.ofNullable(acquirerFee)) + + /** + * Fee assessed by the merchant and paid for by the cardholder in the smallest unit of the + * currency. Will be zero if no fee is assessed. Rebates may be transmitted as a negative + * value to indicate credited fees. + */ + fun acquirerFee(acquirerFee: Long) = acquirerFee(acquirerFee as Long?) /** * Fee assessed by the merchant and paid for by the cardholder in the smallest unit of the @@ -417,8 +438,8 @@ private constructor( * Unique identifier assigned to a transaction by the acquirer that can be used in dispute * and chargeback filing. */ - fun acquirerReferenceNumber(acquirerReferenceNumber: String) = - acquirerReferenceNumber(JsonField.of(acquirerReferenceNumber)) + fun acquirerReferenceNumber(acquirerReferenceNumber: String?) = + acquirerReferenceNumber(JsonField.ofNullable(acquirerReferenceNumber)) /** * Unique identifier assigned to a transaction by the acquirer that can be used in dispute @@ -446,9 +467,13 @@ private constructor( fun amounts(amounts: JsonField) = apply { this.amounts = amounts } + /** The authorization amount of the transaction in the anticipated settlement currency. */ + fun authorizationAmount(authorizationAmount: Long?) = + authorizationAmount(JsonField.ofNullable(authorizationAmount)) + /** The authorization amount of the transaction in the anticipated settlement currency. */ fun authorizationAmount(authorizationAmount: Long) = - authorizationAmount(JsonField.of(authorizationAmount)) + authorizationAmount(authorizationAmount as Long?) /** The authorization amount of the transaction in the anticipated settlement currency. */ fun authorizationAmount(authorizationAmount: JsonField) = apply { @@ -459,8 +484,8 @@ private constructor( * A fixed-width 6-digit numeric identifier that can be used to identify a transaction with * networks. */ - fun authorizationCode(authorizationCode: String) = - authorizationCode(JsonField.of(authorizationCode)) + fun authorizationCode(authorizationCode: String?) = + authorizationCode(JsonField.ofNullable(authorizationCode)) /** * A fixed-width 6-digit numeric identifier that can be used to identify a transaction with @@ -470,7 +495,7 @@ private constructor( this.authorizationCode = authorizationCode } - fun avs(avs: Avs) = avs(JsonField.of(avs)) + fun avs(avs: Avs?) = avs(JsonField.ofNullable(avs)) fun avs(avs: JsonField) = apply { this.avs = avs } @@ -480,8 +505,8 @@ private constructor( /** Token for the card used in this transaction. */ fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } - fun cardholderAuthentication(cardholderAuthentication: CardholderAuthentication) = - cardholderAuthentication(JsonField.of(cardholderAuthentication)) + fun cardholderAuthentication(cardholderAuthentication: CardholderAuthentication?) = + cardholderAuthentication(JsonField.ofNullable(cardholderAuthentication)) fun cardholderAuthentication( cardholderAuthentication: JsonField @@ -498,16 +523,24 @@ private constructor( fun merchant(merchant: JsonField) = apply { this.merchant = merchant } /** Analogous to the 'amount', but in the merchant currency. */ - fun merchantAmount(merchantAmount: Long) = merchantAmount(JsonField.of(merchantAmount)) + fun merchantAmount(merchantAmount: Long?) = + merchantAmount(JsonField.ofNullable(merchantAmount)) + + /** Analogous to the 'amount', but in the merchant currency. */ + fun merchantAmount(merchantAmount: Long) = merchantAmount(merchantAmount as Long?) /** Analogous to the 'amount', but in the merchant currency. */ fun merchantAmount(merchantAmount: JsonField) = apply { this.merchantAmount = merchantAmount } + /** Analogous to the 'authorization_amount', but in the merchant currency. */ + fun merchantAuthorizationAmount(merchantAuthorizationAmount: Long?) = + merchantAuthorizationAmount(JsonField.ofNullable(merchantAuthorizationAmount)) + /** Analogous to the 'authorization_amount', but in the merchant currency. */ fun merchantAuthorizationAmount(merchantAuthorizationAmount: Long) = - merchantAuthorizationAmount(JsonField.of(merchantAuthorizationAmount)) + merchantAuthorizationAmount(merchantAuthorizationAmount as Long?) /** Analogous to the 'authorization_amount', but in the merchant currency. */ fun merchantAuthorizationAmount(merchantAuthorizationAmount: JsonField) = apply { @@ -528,7 +561,7 @@ private constructor( * or `UNKNOWN`. Value is `UNKNOWN` when Lithic cannot determine the network code from the * upstream provider. */ - fun network(network: Network) = network(JsonField.of(network)) + fun network(network: Network?) = network(JsonField.ofNullable(network)) /** * Card network of the authorization. Can be `INTERLINK`, `MAESTRO`, `MASTERCARD`, `VISA`, @@ -543,8 +576,16 @@ private constructor( * highest risk. For Visa transactions, where the raw score has a range of 0-99, Lithic will * normalize the score by multiplying the raw score by 10x. */ - fun networkRiskScore(networkRiskScore: Long) = - networkRiskScore(JsonField.of(networkRiskScore)) + fun networkRiskScore(networkRiskScore: Long?) = + networkRiskScore(JsonField.ofNullable(networkRiskScore)) + + /** + * Network-provided score assessing risk level associated with a given authorization. Scores + * are on a range of 0-999, with 0 representing the lowest risk and 999 representing the + * highest risk. For Visa transactions, where the raw score has a range of 0-99, Lithic will + * normalize the score by multiplying the raw score by 10x. + */ + fun networkRiskScore(networkRiskScore: Long) = networkRiskScore(networkRiskScore as Long?) /** * Network-provided score assessing risk level associated with a given authorization. Scores @@ -578,7 +619,7 @@ private constructor( /** Status of the transaction. */ fun status(status: JsonField) = apply { this.status = status } - fun tokenInfo(tokenInfo: TokenInfo) = tokenInfo(JsonField.of(tokenInfo)) + fun tokenInfo(tokenInfo: TokenInfo?) = tokenInfo(JsonField.ofNullable(tokenInfo)) fun tokenInfo(tokenInfo: JsonField) = apply { this.tokenInfo = tokenInfo } @@ -590,7 +631,20 @@ private constructor( fun events(events: List) = events(JsonField.of(events)) - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + fun addEvent(event: TransactionEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(event) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -613,31 +667,41 @@ private constructor( fun build(): Transaction = Transaction( - token, - accountToken, - acquirerFee, - acquirerReferenceNumber, - amount, - amounts, - authorizationAmount, - authorizationCode, - avs, - cardToken, - cardholderAuthentication, - created, - merchant, - merchantAmount, - merchantAuthorizationAmount, - merchantCurrency, - network, - networkRiskScore, - pos, - result, - settledAmount, - status, - tokenInfo, - updated, - events.map { it.toImmutable() }, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountToken) { "`accountToken` is required but was not set" }, + checkNotNull(acquirerFee) { "`acquirerFee` is required but was not set" }, + checkNotNull(acquirerReferenceNumber) { + "`acquirerReferenceNumber` is required but was not set" + }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(amounts) { "`amounts` is required but was not set" }, + checkNotNull(authorizationAmount) { + "`authorizationAmount` is required but was not set" + }, + checkNotNull(authorizationCode) { + "`authorizationCode` is required but was not set" + }, + checkNotNull(avs) { "`avs` is required but was not set" }, + checkNotNull(cardToken) { "`cardToken` is required but was not set" }, + checkNotNull(cardholderAuthentication) { + "`cardholderAuthentication` is required but was not set" + }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(merchant) { "`merchant` is required but was not set" }, + checkNotNull(merchantAmount) { "`merchantAmount` is required but was not set" }, + checkNotNull(merchantAuthorizationAmount) { + "`merchantAuthorizationAmount` is required but was not set" + }, + checkNotNull(merchantCurrency) { "`merchantCurrency` is required but was not set" }, + checkNotNull(network) { "`network` is required but was not set" }, + checkNotNull(networkRiskScore) { "`networkRiskScore` is required but was not set" }, + checkNotNull(pos) { "`pos` is required but was not set" }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(settledAmount) { "`settledAmount` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(tokenInfo) { "`tokenInfo` is required but was not set" }, + checkNotNull(updated) { "`updated` is required but was not set" }, + (events ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -668,13 +732,17 @@ private constructor( fun settlement(): Settlement = settlement.getRequired("settlement") - @JsonProperty("cardholder") @ExcludeMissing fun _cardholder() = cardholder + @JsonProperty("cardholder") + @ExcludeMissing + fun _cardholder(): JsonField = cardholder - @JsonProperty("hold") @ExcludeMissing fun _hold() = hold + @JsonProperty("hold") @ExcludeMissing fun _hold(): JsonField = hold - @JsonProperty("merchant") @ExcludeMissing fun _merchant() = merchant + @JsonProperty("merchant") @ExcludeMissing fun _merchant(): JsonField = merchant - @JsonProperty("settlement") @ExcludeMissing fun _settlement() = settlement + @JsonProperty("settlement") + @ExcludeMissing + fun _settlement(): JsonField = settlement @JsonAnyGetter @ExcludeMissing @@ -701,10 +769,10 @@ private constructor( class Builder { - private var cardholder: JsonField = JsonMissing.of() - private var hold: JsonField = JsonMissing.of() - private var merchant: JsonField = JsonMissing.of() - private var settlement: JsonField = JsonMissing.of() + private var cardholder: JsonField? = null + private var hold: JsonField? = null + private var merchant: JsonField? = null + private var settlement: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(transactionAmounts: TransactionAmounts) = apply { @@ -756,10 +824,10 @@ private constructor( fun build(): TransactionAmounts = TransactionAmounts( - cardholder, - hold, - merchant, - settlement, + checkNotNull(cardholder) { "`cardholder` is required but was not set" }, + checkNotNull(hold) { "`hold` is required but was not set" }, + checkNotNull(merchant) { "`merchant` is required but was not set" }, + checkNotNull(settlement) { "`settlement` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -802,20 +870,24 @@ private constructor( /** * The estimated settled amount of the transaction in the cardholder billing currency. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * The exchange rate used to convert the merchant amount to the cardholder billing * amount. */ - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * ISO 4217 currency. Its enumerants are ISO 4217 currencies except for some special * currencies like `XXX`. Enumerants names are lowercase currency code e.g. `EUR`, * `USD`. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -841,9 +913,9 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var conversionRate: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cardholder: Cardholder) = apply { @@ -918,9 +990,11 @@ private constructor( fun build(): Cardholder = Cardholder( - amount, - conversionRate, - currency, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(conversionRate) { + "`conversionRate` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -968,14 +1042,16 @@ private constructor( fun currency(): Currency = currency.getRequired("currency") /** The pending amount of the transaction in the anticipated settlement currency. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * ISO 4217 currency. Its enumerants are ISO 4217 currencies except for some special * currencies like `XXX`. Enumerants names are lowercase currency code e.g. `EUR`, * `USD`. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -1000,8 +1076,8 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(hold: Hold) = apply { @@ -1054,8 +1130,8 @@ private constructor( fun build(): Hold = Hold( - amount, - currency, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1103,14 +1179,16 @@ private constructor( fun currency(): Currency = currency.getRequired("currency") /** The settled amount of the transaction in the merchant currency. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * ISO 4217 currency. Its enumerants are ISO 4217 currencies except for some special * currencies like `XXX`. Enumerants names are lowercase currency code e.g. `EUR`, * `USD`. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -1135,8 +1213,8 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(merchant: Merchant) = apply { @@ -1189,8 +1267,8 @@ private constructor( fun build(): Merchant = Merchant( - amount, - currency, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1238,14 +1316,16 @@ private constructor( fun currency(): Currency = currency.getRequired("currency") /** The settled amount of the transaction in the settlement currency. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * ISO 4217 currency. Its enumerants are ISO 4217 currencies except for some special * currencies like `XXX`. Enumerants names are lowercase currency code e.g. `EUR`, * `USD`. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -1270,8 +1350,8 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(settlement: Settlement) = apply { @@ -1324,8 +1404,8 @@ private constructor( fun build(): Settlement = Settlement( - amount, - currency, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1387,10 +1467,10 @@ private constructor( fun zipcode(): String = zipcode.getRequired("zipcode") /** Cardholder address */ - @JsonProperty("address") @ExcludeMissing fun _address() = address + @JsonProperty("address") @ExcludeMissing fun _address(): JsonField = address /** Cardholder ZIP code */ - @JsonProperty("zipcode") @ExcludeMissing fun _zipcode() = zipcode + @JsonProperty("zipcode") @ExcludeMissing fun _zipcode(): JsonField = zipcode @JsonAnyGetter @ExcludeMissing @@ -1415,8 +1495,8 @@ private constructor( class Builder { - private var address: JsonField = JsonMissing.of() - private var zipcode: JsonField = JsonMissing.of() + private var address: JsonField? = null + private var zipcode: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(avs: Avs) = apply { @@ -1458,8 +1538,8 @@ private constructor( fun build(): Avs = Avs( - address, - zipcode, + checkNotNull(address) { "`address` is required but was not set" }, + checkNotNull(zipcode) { "`zipcode` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1564,20 +1644,24 @@ private constructor( verificationResult.getRequired("verification_result") /** The 3DS version used for the authentication */ - @JsonProperty("3ds_version") @ExcludeMissing fun __3dsVersion() = _3dsVersion + @JsonProperty("3ds_version") + @ExcludeMissing + fun __3dsVersion(): JsonField = _3dsVersion /** Whether an acquirer exemption applied to the transaction. */ @JsonProperty("acquirer_exemption") @ExcludeMissing - fun _acquirerExemption() = acquirerExemption + fun _acquirerExemption(): JsonField = acquirerExemption /** Indicates what the outcome of the 3DS authentication process is. */ @JsonProperty("authentication_result") @ExcludeMissing - fun _authenticationResult() = authenticationResult + fun _authenticationResult(): JsonField = authenticationResult /** Indicates which party made the 3DS authentication decision. */ - @JsonProperty("decision_made_by") @ExcludeMissing fun _decisionMadeBy() = decisionMadeBy + @JsonProperty("decision_made_by") + @ExcludeMissing + fun _decisionMadeBy(): JsonField = decisionMadeBy /** * Indicates whether chargeback liability shift applies to the transaction. Possible enum @@ -1589,7 +1673,9 @@ private constructor( * - `TOKEN_AUTHENTICATED`: The transaction was a tokenized payment with validated * cryptography, possibly recurring. Chargeback liability shift to the issuer applies. */ - @JsonProperty("liability_shift") @ExcludeMissing fun _liabilityShift() = liabilityShift + @JsonProperty("liability_shift") + @ExcludeMissing + fun _liabilityShift(): JsonField = liabilityShift /** * Unique identifier you can use to match a given 3DS authentication (available via the @@ -1599,7 +1685,7 @@ private constructor( */ @JsonProperty("three_ds_authentication_token") @ExcludeMissing - fun _threeDSAuthenticationToken() = threeDSAuthenticationToken + fun _threeDSAuthenticationToken(): JsonField = threeDSAuthenticationToken /** * Indicates whether a 3DS challenge flow was used, and if so, what the verification method @@ -1607,7 +1693,7 @@ private constructor( */ @JsonProperty("verification_attempted") @ExcludeMissing - fun _verificationAttempted() = verificationAttempted + fun _verificationAttempted(): JsonField = verificationAttempted /** * Indicates whether a transaction is considered 3DS authenticated. (deprecated, use @@ -1615,7 +1701,7 @@ private constructor( */ @JsonProperty("verification_result") @ExcludeMissing - fun _verificationResult() = verificationResult + fun _verificationResult(): JsonField = verificationResult @JsonAnyGetter @ExcludeMissing @@ -1646,14 +1732,14 @@ private constructor( class Builder { - private var _3dsVersion: JsonField = JsonMissing.of() - private var acquirerExemption: JsonField = JsonMissing.of() - private var authenticationResult: JsonField = JsonMissing.of() - private var decisionMadeBy: JsonField = JsonMissing.of() - private var liabilityShift: JsonField = JsonMissing.of() - private var threeDSAuthenticationToken: JsonField = JsonMissing.of() - private var verificationAttempted: JsonField = JsonMissing.of() - private var verificationResult: JsonField = JsonMissing.of() + private var _3dsVersion: JsonField? = null + private var acquirerExemption: JsonField? = null + private var authenticationResult: JsonField? = null + private var decisionMadeBy: JsonField? = null + private var liabilityShift: JsonField? = null + private var threeDSAuthenticationToken: JsonField? = null + private var verificationAttempted: JsonField? = null + private var verificationResult: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cardholderAuthentication: CardholderAuthentication) = apply { @@ -1669,7 +1755,7 @@ private constructor( } /** The 3DS version used for the authentication */ - fun _3dsVersion(_3dsVersion: String) = _3dsVersion(JsonField.of(_3dsVersion)) + fun _3dsVersion(_3dsVersion: String?) = _3dsVersion(JsonField.ofNullable(_3dsVersion)) /** The 3DS version used for the authentication */ fun _3dsVersion(_3dsVersion: JsonField) = apply { @@ -1737,8 +1823,8 @@ private constructor( * cases where liability shift does not occur, this token is matched to the transaction * on a best-effort basis. */ - fun threeDSAuthenticationToken(threeDSAuthenticationToken: String) = - threeDSAuthenticationToken(JsonField.of(threeDSAuthenticationToken)) + fun threeDSAuthenticationToken(threeDSAuthenticationToken: String?) = + threeDSAuthenticationToken(JsonField.ofNullable(threeDSAuthenticationToken)) /** * Unique identifier you can use to match a given 3DS authentication (available via the @@ -1802,14 +1888,24 @@ private constructor( fun build(): CardholderAuthentication = CardholderAuthentication( - _3dsVersion, - acquirerExemption, - authenticationResult, - decisionMadeBy, - liabilityShift, - threeDSAuthenticationToken, - verificationAttempted, - verificationResult, + checkNotNull(_3dsVersion) { "`_3dsVersion` is required but was not set" }, + checkNotNull(acquirerExemption) { + "`acquirerExemption` is required but was not set" + }, + checkNotNull(authenticationResult) { + "`authenticationResult` is required but was not set" + }, + checkNotNull(decisionMadeBy) { "`decisionMadeBy` is required but was not set" }, + checkNotNull(liabilityShift) { "`liabilityShift` is required but was not set" }, + checkNotNull(threeDSAuthenticationToken) { + "`threeDSAuthenticationToken` is required but was not set" + }, + checkNotNull(verificationAttempted) { + "`verificationAttempted` is required but was not set" + }, + checkNotNull(verificationResult) { + "`verificationResult` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2339,36 +2435,40 @@ private constructor( fun state(): String = state.getRequired("state") /** Unique alphanumeric identifier for the payment card acceptor (merchant). */ - @JsonProperty("acceptor_id") @ExcludeMissing fun _acceptorId() = acceptorId + @JsonProperty("acceptor_id") + @ExcludeMissing + fun _acceptorId(): JsonField = acceptorId /** Unique numeric identifier of the acquiring institution. */ @JsonProperty("acquiring_institution_id") @ExcludeMissing - fun _acquiringInstitutionId() = acquiringInstitutionId + fun _acquiringInstitutionId(): JsonField = acquiringInstitutionId /** * City of card acceptor. Note that in many cases, particularly in card-not-present * transactions, merchants may send through a phone number or URL in this field. */ - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city /** * Country or entity of card acceptor. Possible values are: (1) all ISO 3166-1 alpha-3 * country codes, (2) QZZ for Kosovo, and (3) ANT for Netherlands Antilles. */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** Short description of card acceptor. */ - @JsonProperty("descriptor") @ExcludeMissing fun _descriptor() = descriptor + @JsonProperty("descriptor") + @ExcludeMissing + fun _descriptor(): JsonField = descriptor /** * Merchant category code (MCC). A four-digit number listed in ISO 18245. An MCC is used to * classify a business by the types of goods or services it provides. */ - @JsonProperty("mcc") @ExcludeMissing fun _mcc() = mcc + @JsonProperty("mcc") @ExcludeMissing fun _mcc(): JsonField = mcc /** Geographic state of card acceptor. */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing @@ -2398,13 +2498,13 @@ private constructor( class Builder { - private var acceptorId: JsonField = JsonMissing.of() - private var acquiringInstitutionId: JsonField = JsonMissing.of() - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var descriptor: JsonField = JsonMissing.of() - private var mcc: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() + private var acceptorId: JsonField? = null + private var acquiringInstitutionId: JsonField? = null + private var city: JsonField? = null + private var country: JsonField? = null + private var descriptor: JsonField? = null + private var mcc: JsonField? = null + private var state: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(merchant: Merchant) = apply { @@ -2502,13 +2602,15 @@ private constructor( fun build(): Merchant = Merchant( - acceptorId, - acquiringInstitutionId, - city, - country, - descriptor, - mcc, - state, + checkNotNull(acceptorId) { "`acceptorId` is required but was not set" }, + checkNotNull(acquiringInstitutionId) { + "`acquiringInstitutionId` is required but was not set" + }, + checkNotNull(city) { "`city` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(descriptor) { "`descriptor` is required but was not set" }, + checkNotNull(mcc) { "`mcc` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2624,9 +2726,11 @@ private constructor( fun terminal(): PosTerminal = terminal.getRequired("terminal") - @JsonProperty("entry_mode") @ExcludeMissing fun _entryMode() = entryMode + @JsonProperty("entry_mode") + @ExcludeMissing + fun _entryMode(): JsonField = entryMode - @JsonProperty("terminal") @ExcludeMissing fun _terminal() = terminal + @JsonProperty("terminal") @ExcludeMissing fun _terminal(): JsonField = terminal @JsonAnyGetter @ExcludeMissing @@ -2651,8 +2755,8 @@ private constructor( class Builder { - private var entryMode: JsonField = JsonMissing.of() - private var terminal: JsonField = JsonMissing.of() + private var entryMode: JsonField? = null + private var terminal: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(pos: Pos) = apply { @@ -2690,8 +2794,8 @@ private constructor( fun build(): Pos = Pos( - entryMode, - terminal, + checkNotNull(entryMode) { "`entryMode` is required but was not set" }, + checkNotNull(terminal) { "`terminal` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2727,16 +2831,20 @@ private constructor( fun pinEntered(): Boolean = pinEntered.getRequired("pin_entered") /** Card presence indicator */ - @JsonProperty("card") @ExcludeMissing fun _card() = card + @JsonProperty("card") @ExcludeMissing fun _card(): JsonField = card /** Cardholder presence indicator */ - @JsonProperty("cardholder") @ExcludeMissing fun _cardholder() = cardholder + @JsonProperty("cardholder") + @ExcludeMissing + fun _cardholder(): JsonField = cardholder /** Method of entry for the PAN */ - @JsonProperty("pan") @ExcludeMissing fun _pan() = pan + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan /** Indicates whether the cardholder entered the PIN. True if the PIN was entered. */ - @JsonProperty("pin_entered") @ExcludeMissing fun _pinEntered() = pinEntered + @JsonProperty("pin_entered") + @ExcludeMissing + fun _pinEntered(): JsonField = pinEntered @JsonAnyGetter @ExcludeMissing @@ -2763,10 +2871,10 @@ private constructor( class Builder { - private var card: JsonField = JsonMissing.of() - private var cardholder: JsonField = JsonMissing.of() - private var pan: JsonField = JsonMissing.of() - private var pinEntered: JsonField = JsonMissing.of() + private var card: JsonField? = null + private var cardholder: JsonField? = null + private var pan: JsonField? = null + private var pinEntered: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(posEntryMode: PosEntryMode) = apply { @@ -2833,10 +2941,10 @@ private constructor( fun build(): PosEntryMode = PosEntryMode( - card, - cardholder, - pan, - pinEntered, + checkNotNull(card) { "`card` is required but was not set" }, + checkNotNull(cardholder) { "`cardholder` is required but was not set" }, + checkNotNull(pan) { "`pan` is required but was not set" }, + checkNotNull(pinEntered) { "`pinEntered` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3227,18 +3335,22 @@ private constructor( fun type(): Type = type.getRequired("type") /** True if a clerk is present at the sale. */ - @JsonProperty("attended") @ExcludeMissing fun _attended() = attended + @JsonProperty("attended") @ExcludeMissing fun _attended(): JsonField = attended /** True if the terminal is capable of retaining the card. */ @JsonProperty("card_retention_capable") @ExcludeMissing - fun _cardRetentionCapable() = cardRetentionCapable + fun _cardRetentionCapable(): JsonField = cardRetentionCapable /** True if the sale was made at the place of business (vs. mobile). */ - @JsonProperty("on_premise") @ExcludeMissing fun _onPremise() = onPremise + @JsonProperty("on_premise") + @ExcludeMissing + fun _onPremise(): JsonField = onPremise /** The person that is designated to swipe the card */ - @JsonProperty("operator") @ExcludeMissing fun _operator() = operator + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator /** * True if the terminal is capable of partial approval. Partial approval is when part of @@ -3249,13 +3361,15 @@ private constructor( */ @JsonProperty("partial_approval_capable") @ExcludeMissing - fun _partialApprovalCapable() = partialApprovalCapable + fun _partialApprovalCapable(): JsonField = partialApprovalCapable /** Status of whether the POS is able to accept PINs */ - @JsonProperty("pin_capability") @ExcludeMissing fun _pinCapability() = pinCapability + @JsonProperty("pin_capability") + @ExcludeMissing + fun _pinCapability(): JsonField = pinCapability /** POS Type */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -3285,13 +3399,13 @@ private constructor( class Builder { - private var attended: JsonField = JsonMissing.of() - private var cardRetentionCapable: JsonField = JsonMissing.of() - private var onPremise: JsonField = JsonMissing.of() - private var operator: JsonField = JsonMissing.of() - private var partialApprovalCapable: JsonField = JsonMissing.of() - private var pinCapability: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var attended: JsonField? = null + private var cardRetentionCapable: JsonField? = null + private var onPremise: JsonField? = null + private var operator: JsonField? = null + private var partialApprovalCapable: JsonField? = null + private var pinCapability: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(posTerminal: PosTerminal) = apply { @@ -3392,13 +3506,19 @@ private constructor( fun build(): PosTerminal = PosTerminal( - attended, - cardRetentionCapable, - onPremise, - operator, - partialApprovalCapable, - pinCapability, - type, + checkNotNull(attended) { "`attended` is required but was not set" }, + checkNotNull(cardRetentionCapable) { + "`cardRetentionCapable` is required but was not set" + }, + checkNotNull(onPremise) { "`onPremise` is required but was not set" }, + checkNotNull(operator) { "`operator` is required but was not set" }, + checkNotNull(partialApprovalCapable) { + "`partialApprovalCapable` is required but was not set" + }, + checkNotNull(pinCapability) { + "`pinCapability` is required but was not set" + }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4049,7 +4169,9 @@ private constructor( * “other” sources like in-flight commerce. Masterpass is not currently supported and is * included for future use. */ - @JsonProperty("wallet_type") @ExcludeMissing fun _walletType() = walletType + @JsonProperty("wallet_type") + @ExcludeMissing + fun _walletType(): JsonField = walletType @JsonAnyGetter @ExcludeMissing @@ -4073,7 +4195,7 @@ private constructor( class Builder { - private var walletType: JsonField = JsonMissing.of() + private var walletType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(tokenInfo: TokenInfo) = apply { @@ -4118,7 +4240,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): TokenInfo = TokenInfo(walletType, additionalProperties.toImmutable()) + fun build(): TokenInfo = + TokenInfo( + checkNotNull(walletType) { "`walletType` is required but was not set" }, + additionalProperties.toImmutable() + ) } class WalletType @@ -4292,22 +4418,26 @@ private constructor( fun type(): Type = type.getRequired("type") /** Transaction event identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Amount of the event in the settlement currency. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("amounts") @ExcludeMissing fun _amounts() = amounts + @JsonProperty("amounts") + @ExcludeMissing + fun _amounts(): JsonField = amounts /** RFC 3339 date and time this event entered the system. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - @JsonProperty("detailed_results") @ExcludeMissing fun _detailedResults() = detailedResults + @JsonProperty("detailed_results") + @ExcludeMissing + fun _detailedResults(): JsonField> = detailedResults /** Indicates whether the transaction event is a credit or debit to the account. */ @JsonProperty("effective_polarity") @ExcludeMissing - fun _effectivePolarity() = effectivePolarity + fun _effectivePolarity(): JsonField = effectivePolarity /** * Information provided by the card network in each event. This includes common identifiers @@ -4317,14 +4447,18 @@ private constructor( * fields are available in all events, and the presence of these fields is dependent on the * card network and the event type. */ - @JsonProperty("network_info") @ExcludeMissing fun _networkInfo() = networkInfo + @JsonProperty("network_info") + @ExcludeMissing + fun _networkInfo(): JsonField = networkInfo - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result - @JsonProperty("rule_results") @ExcludeMissing fun _ruleResults() = ruleResults + @JsonProperty("rule_results") + @ExcludeMissing + fun _ruleResults(): JsonField> = ruleResults /** Type of transaction event */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -4357,16 +4491,16 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var amounts: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var detailedResults: JsonField> = JsonMissing.of() - private var effectivePolarity: JsonField = JsonMissing.of() - private var networkInfo: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() - private var ruleResults: JsonField> = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var token: JsonField? = null + private var amount: JsonField? = null + private var amounts: JsonField? = null + private var created: JsonField? = null + private var detailedResults: JsonField>? = null + private var effectivePolarity: JsonField? = null + private var networkInfo: JsonField? = null + private var result: JsonField? = null + private var ruleResults: JsonField>? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(transactionEvent: TransactionEvent) = apply { @@ -4374,11 +4508,11 @@ private constructor( amount = transactionEvent.amount amounts = transactionEvent.amounts created = transactionEvent.created - detailedResults = transactionEvent.detailedResults + detailedResults = transactionEvent.detailedResults.map { it.toMutableList() } effectivePolarity = transactionEvent.effectivePolarity networkInfo = transactionEvent.networkInfo result = transactionEvent.result - ruleResults = transactionEvent.ruleResults + ruleResults = transactionEvent.ruleResults.map { it.toMutableList() } type = transactionEvent.type additionalProperties = transactionEvent.additionalProperties.toMutableMap() } @@ -4411,7 +4545,18 @@ private constructor( detailedResults(JsonField.of(detailedResults)) fun detailedResults(detailedResults: JsonField>) = apply { - this.detailedResults = detailedResults + this.detailedResults = detailedResults.map { it.toMutableList() } + } + + fun addDetailedResult(detailedResult: DetailedResult) = apply { + detailedResults = + (detailedResults ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(detailedResult) + } } /** Indicates whether the transaction event is a credit or debit to the account. */ @@ -4431,7 +4576,8 @@ private constructor( * processing of disputes. Not all fields are available in all events, and the presence * of these fields is dependent on the card network and the event type. */ - fun networkInfo(networkInfo: NetworkInfo) = networkInfo(JsonField.of(networkInfo)) + fun networkInfo(networkInfo: NetworkInfo?) = + networkInfo(JsonField.ofNullable(networkInfo)) /** * Information provided by the card network in each event. This includes common @@ -4452,7 +4598,18 @@ private constructor( fun ruleResults(ruleResults: List) = ruleResults(JsonField.of(ruleResults)) fun ruleResults(ruleResults: JsonField>) = apply { - this.ruleResults = ruleResults + this.ruleResults = ruleResults.map { it.toMutableList() } + } + + fun addRuleResult(ruleResult: RuleResult) = apply { + ruleResults = + (ruleResults ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(ruleResult) + } } /** Type of transaction event */ @@ -4482,16 +4639,22 @@ private constructor( fun build(): TransactionEvent = TransactionEvent( - token, - amount, - amounts, - created, - detailedResults.map { it.toImmutable() }, - effectivePolarity, - networkInfo, - result, - ruleResults.map { it.toImmutable() }, - type, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(amounts) { "`amounts` is required but was not set" }, + checkNotNull(created) { "`created` is required but was not set" }, + checkNotNull(detailedResults) { + "`detailedResults` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(effectivePolarity) { + "`effectivePolarity` is required but was not set" + }, + checkNotNull(networkInfo) { "`networkInfo` is required but was not set" }, + checkNotNull(result) { "`result` is required but was not set" }, + checkNotNull(ruleResults) { "`ruleResults` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4519,11 +4682,17 @@ private constructor( fun settlement(): Settlement? = settlement.getNullable("settlement") - @JsonProperty("cardholder") @ExcludeMissing fun _cardholder() = cardholder + @JsonProperty("cardholder") + @ExcludeMissing + fun _cardholder(): JsonField = cardholder - @JsonProperty("merchant") @ExcludeMissing fun _merchant() = merchant + @JsonProperty("merchant") + @ExcludeMissing + fun _merchant(): JsonField = merchant - @JsonProperty("settlement") @ExcludeMissing fun _settlement() = settlement + @JsonProperty("settlement") + @ExcludeMissing + fun _settlement(): JsonField = settlement @JsonAnyGetter @ExcludeMissing @@ -4549,9 +4718,9 @@ private constructor( class Builder { - private var cardholder: JsonField = JsonMissing.of() - private var merchant: JsonField = JsonMissing.of() - private var settlement: JsonField = JsonMissing.of() + private var cardholder: JsonField? = null + private var merchant: JsonField? = null + private var settlement: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(transactionEventAmounts: TransactionEventAmounts) = apply { @@ -4572,7 +4741,8 @@ private constructor( fun merchant(merchant: JsonField) = apply { this.merchant = merchant } - fun settlement(settlement: Settlement) = settlement(JsonField.of(settlement)) + fun settlement(settlement: Settlement?) = + settlement(JsonField.ofNullable(settlement)) fun settlement(settlement: JsonField) = apply { this.settlement = settlement @@ -4602,9 +4772,9 @@ private constructor( fun build(): TransactionEventAmounts = TransactionEventAmounts( - cardholder, - merchant, - settlement, + checkNotNull(cardholder) { "`cardholder` is required but was not set" }, + checkNotNull(merchant) { "`merchant` is required but was not set" }, + checkNotNull(settlement) { "`settlement` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4643,7 +4813,7 @@ private constructor( fun currency(): Currency = currency.getRequired("currency") /** Amount of the event in the cardholder billing currency. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * Exchange rate used to convert the merchant amount to the cardholder billing @@ -4651,14 +4821,16 @@ private constructor( */ @JsonProperty("conversion_rate") @ExcludeMissing - fun _conversionRate() = conversionRate + fun _conversionRate(): JsonField = conversionRate /** * ISO 4217 currency. Its enumerants are ISO 4217 currencies except for some special * currencies like `XXX`. Enumerants names are lowercase currency code e.g. `EUR`, * `USD`. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -4684,9 +4856,9 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var conversionRate: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(cardholder: Cardholder) = apply { @@ -4755,9 +4927,11 @@ private constructor( fun build(): Cardholder = Cardholder( - amount, - conversionRate, - currency, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(conversionRate) { + "`conversionRate` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4805,14 +4979,16 @@ private constructor( fun currency(): Currency = currency.getRequired("currency") /** Amount of the event in the merchant currency. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * ISO 4217 currency. Its enumerants are ISO 4217 currencies except for some special * currencies like `XXX`. Enumerants names are lowercase currency code e.g. `EUR`, * `USD`. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -4837,8 +5013,8 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(merchant: Merchant) = apply { @@ -4891,8 +5067,8 @@ private constructor( fun build(): Merchant = Merchant( - amount, - currency, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4952,19 +5128,21 @@ private constructor( * Amount of the event, if it is financial, in the settlement currency. * Non-financial events do not contain this amount because they do not move funds. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** Exchange rate used to convert the merchant amount to the settlement amount. */ @JsonProperty("conversion_rate") @ExcludeMissing - fun _conversionRate() = conversionRate + fun _conversionRate(): JsonField = conversionRate /** * ISO 4217 currency. Its enumerants are ISO 4217 currencies except for some special * currencies like `XXX`. Enumerants names are lowercase currency code e.g. `EUR`, * `USD`. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -4990,9 +5168,9 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var conversionRate: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(settlement: Settlement) = apply { @@ -5067,9 +5245,11 @@ private constructor( fun build(): Settlement = Settlement( - amount, - conversionRate, - currency, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(conversionRate) { + "`conversionRate` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5570,11 +5750,15 @@ private constructor( fun visa(): Visa? = visa.getNullable("visa") - @JsonProperty("acquirer") @ExcludeMissing fun _acquirer() = acquirer + @JsonProperty("acquirer") + @ExcludeMissing + fun _acquirer(): JsonField = acquirer - @JsonProperty("mastercard") @ExcludeMissing fun _mastercard() = mastercard + @JsonProperty("mastercard") + @ExcludeMissing + fun _mastercard(): JsonField = mastercard - @JsonProperty("visa") @ExcludeMissing fun _visa() = visa + @JsonProperty("visa") @ExcludeMissing fun _visa(): JsonField = visa @JsonAnyGetter @ExcludeMissing @@ -5600,9 +5784,9 @@ private constructor( class Builder { - private var acquirer: JsonField = JsonMissing.of() - private var mastercard: JsonField = JsonMissing.of() - private var visa: JsonField = JsonMissing.of() + private var acquirer: JsonField? = null + private var mastercard: JsonField? = null + private var visa: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(networkInfo: NetworkInfo) = apply { @@ -5612,17 +5796,18 @@ private constructor( additionalProperties = networkInfo.additionalProperties.toMutableMap() } - fun acquirer(acquirer: Acquirer) = acquirer(JsonField.of(acquirer)) + fun acquirer(acquirer: Acquirer?) = acquirer(JsonField.ofNullable(acquirer)) fun acquirer(acquirer: JsonField) = apply { this.acquirer = acquirer } - fun mastercard(mastercard: Mastercard) = mastercard(JsonField.of(mastercard)) + fun mastercard(mastercard: Mastercard?) = + mastercard(JsonField.ofNullable(mastercard)) fun mastercard(mastercard: JsonField) = apply { this.mastercard = mastercard } - fun visa(visa: Visa) = visa(JsonField.of(visa)) + fun visa(visa: Visa?) = visa(JsonField.ofNullable(visa)) fun visa(visa: JsonField) = apply { this.visa = visa } @@ -5650,9 +5835,9 @@ private constructor( fun build(): NetworkInfo = NetworkInfo( - acquirer, - mastercard, - visa, + checkNotNull(acquirer) { "`acquirer` is required but was not set" }, + checkNotNull(mastercard) { "`mastercard` is required but was not set" }, + checkNotNull(visa) { "`visa` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5694,12 +5879,12 @@ private constructor( */ @JsonProperty("acquirer_reference_number") @ExcludeMissing - fun _acquirerReferenceNumber() = acquirerReferenceNumber + fun _acquirerReferenceNumber(): JsonField = acquirerReferenceNumber /** Identifier assigned by the acquirer. */ @JsonProperty("retrieval_reference_number") @ExcludeMissing - fun _retrievalReferenceNumber() = retrievalReferenceNumber + fun _retrievalReferenceNumber(): JsonField = retrievalReferenceNumber @JsonAnyGetter @ExcludeMissing @@ -5724,8 +5909,8 @@ private constructor( class Builder { - private var acquirerReferenceNumber: JsonField = JsonMissing.of() - private var retrievalReferenceNumber: JsonField = JsonMissing.of() + private var acquirerReferenceNumber: JsonField? = null + private var retrievalReferenceNumber: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(acquirer: Acquirer) = apply { @@ -5741,8 +5926,8 @@ private constructor( * (such as automated fuel dispenser transactions). A single transaction can * contain multiple ARNs if the merchant sends multiple clearings. */ - fun acquirerReferenceNumber(acquirerReferenceNumber: String) = - acquirerReferenceNumber(JsonField.of(acquirerReferenceNumber)) + fun acquirerReferenceNumber(acquirerReferenceNumber: String?) = + acquirerReferenceNumber(JsonField.ofNullable(acquirerReferenceNumber)) /** * Identifier assigned by the acquirer, applicable to dual-message transactions @@ -5757,8 +5942,8 @@ private constructor( } /** Identifier assigned by the acquirer. */ - fun retrievalReferenceNumber(retrievalReferenceNumber: String) = - retrievalReferenceNumber(JsonField.of(retrievalReferenceNumber)) + fun retrievalReferenceNumber(retrievalReferenceNumber: String?) = + retrievalReferenceNumber(JsonField.ofNullable(retrievalReferenceNumber)) /** Identifier assigned by the acquirer. */ fun retrievalReferenceNumber(retrievalReferenceNumber: JsonField) = @@ -5790,8 +5975,12 @@ private constructor( fun build(): Acquirer = Acquirer( - acquirerReferenceNumber, - retrievalReferenceNumber, + checkNotNull(acquirerReferenceNumber) { + "`acquirerReferenceNumber` is required but was not set" + }, + checkNotNull(retrievalReferenceNumber) { + "`retrievalReferenceNumber` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5842,7 +6031,7 @@ private constructor( /** Identifier assigned by Mastercard. */ @JsonProperty("banknet_reference_number") @ExcludeMissing - fun _banknetReferenceNumber() = banknetReferenceNumber + fun _banknetReferenceNumber(): JsonField = banknetReferenceNumber /** * Identifier assigned by Mastercard, applicable to single-message transactions @@ -5850,7 +6039,7 @@ private constructor( */ @JsonProperty("switch_serial_number") @ExcludeMissing - fun _switchSerialNumber() = switchSerialNumber + fun _switchSerialNumber(): JsonField = switchSerialNumber @JsonAnyGetter @ExcludeMissing @@ -5875,8 +6064,8 @@ private constructor( class Builder { - private var banknetReferenceNumber: JsonField = JsonMissing.of() - private var switchSerialNumber: JsonField = JsonMissing.of() + private var banknetReferenceNumber: JsonField? = null + private var switchSerialNumber: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(mastercard: Mastercard) = apply { @@ -5886,8 +6075,8 @@ private constructor( } /** Identifier assigned by Mastercard. */ - fun banknetReferenceNumber(banknetReferenceNumber: String) = - banknetReferenceNumber(JsonField.of(banknetReferenceNumber)) + fun banknetReferenceNumber(banknetReferenceNumber: String?) = + banknetReferenceNumber(JsonField.ofNullable(banknetReferenceNumber)) /** Identifier assigned by Mastercard. */ fun banknetReferenceNumber(banknetReferenceNumber: JsonField) = apply { @@ -5898,8 +6087,8 @@ private constructor( * Identifier assigned by Mastercard, applicable to single-message transactions * only. */ - fun switchSerialNumber(switchSerialNumber: String) = - switchSerialNumber(JsonField.of(switchSerialNumber)) + fun switchSerialNumber(switchSerialNumber: String?) = + switchSerialNumber(JsonField.ofNullable(switchSerialNumber)) /** * Identifier assigned by Mastercard, applicable to single-message transactions @@ -5933,8 +6122,12 @@ private constructor( fun build(): Mastercard = Mastercard( - banknetReferenceNumber, - switchSerialNumber, + checkNotNull(banknetReferenceNumber) { + "`banknetReferenceNumber` is required but was not set" + }, + checkNotNull(switchSerialNumber) { + "`switchSerialNumber` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5972,7 +6165,9 @@ private constructor( fun transactionId(): String? = transactionId.getNullable("transaction_id") /** Identifier assigned by Visa. */ - @JsonProperty("transaction_id") @ExcludeMissing fun _transactionId() = transactionId + @JsonProperty("transaction_id") + @ExcludeMissing + fun _transactionId(): JsonField = transactionId @JsonAnyGetter @ExcludeMissing @@ -5996,7 +6191,7 @@ private constructor( class Builder { - private var transactionId: JsonField = JsonMissing.of() + private var transactionId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(visa: Visa) = apply { @@ -6005,8 +6200,8 @@ private constructor( } /** Identifier assigned by Visa. */ - fun transactionId(transactionId: String) = - transactionId(JsonField.of(transactionId)) + fun transactionId(transactionId: String?) = + transactionId(JsonField.ofNullable(transactionId)) /** Identifier assigned by Visa. */ fun transactionId(transactionId: JsonField) = apply { @@ -6035,7 +6230,13 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Visa = Visa(transactionId, additionalProperties.toImmutable()) + fun build(): Visa = + Visa( + checkNotNull(transactionId) { + "`transactionId` is required but was not set" + }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -6300,16 +6501,22 @@ private constructor( * Auth Rule. This may happen in cases where a transaction is declined due to a * Lithic-configured security or compliance rule, for example. */ - @JsonProperty("auth_rule_token") @ExcludeMissing fun _authRuleToken() = authRuleToken + @JsonProperty("auth_rule_token") + @ExcludeMissing + fun _authRuleToken(): JsonField = authRuleToken /** A human-readable explanation outlining the motivation for the rule's decline. */ - @JsonProperty("explanation") @ExcludeMissing fun _explanation() = explanation + @JsonProperty("explanation") + @ExcludeMissing + fun _explanation(): JsonField = explanation /** The name for the rule, if any was configured. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The detailed_result associated with this rule's decline. */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField = result @JsonAnyGetter @ExcludeMissing @@ -6336,10 +6543,10 @@ private constructor( class Builder { - private var authRuleToken: JsonField = JsonMissing.of() - private var explanation: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var result: JsonField = JsonMissing.of() + private var authRuleToken: JsonField? = null + private var explanation: JsonField? = null + private var name: JsonField? = null + private var result: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(ruleResult: RuleResult) = apply { @@ -6356,8 +6563,8 @@ private constructor( * customer-configured Auth Rule. This may happen in cases where a transaction is * declined due to a Lithic-configured security or compliance rule, for example. */ - fun authRuleToken(authRuleToken: String) = - authRuleToken(JsonField.of(authRuleToken)) + fun authRuleToken(authRuleToken: String?) = + authRuleToken(JsonField.ofNullable(authRuleToken)) /** * The Auth Rule Token associated with the rule from which the decline originated. @@ -6370,7 +6577,8 @@ private constructor( } /** A human-readable explanation outlining the motivation for the rule's decline. */ - fun explanation(explanation: String) = explanation(JsonField.of(explanation)) + fun explanation(explanation: String?) = + explanation(JsonField.ofNullable(explanation)) /** A human-readable explanation outlining the motivation for the rule's decline. */ fun explanation(explanation: JsonField) = apply { @@ -6378,7 +6586,7 @@ private constructor( } /** The name for the rule, if any was configured. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) /** The name for the rule, if any was configured. */ fun name(name: JsonField) = apply { this.name = name } @@ -6413,10 +6621,12 @@ private constructor( fun build(): RuleResult = RuleResult( - authRuleToken, - explanation, - name, - result, + checkNotNull(authRuleToken) { + "`authRuleToken` is required but was not set" + }, + checkNotNull(explanation) { "`explanation` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(result) { "`result` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationAdviceParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationAdviceParams.kt index e5fcc44e..94e8333d 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationAdviceParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationAdviceParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -35,12 +37,21 @@ constructor( */ fun amount(): Long = body.amount() - fun _additionalHeaders(): Headers = additionalHeaders + /** The transaction token returned from the /v1/simulate/authorize. response. */ + fun _token(): JsonField = body._token() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Amount (in cents) to authorize. This amount will override the transaction's amount that was + * originally set by /v1/simulate/authorize. + */ + fun _amount(): JsonField = body._amount() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): TransactionSimulateAuthorizationAdviceBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -51,25 +62,48 @@ constructor( class TransactionSimulateAuthorizationAdviceBody @JsonCreator internal constructor( - @JsonProperty("token") private val token: String, - @JsonProperty("amount") private val amount: Long, + @JsonProperty("token") + @ExcludeMissing + private val token: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The transaction token returned from the /v1/simulate/authorize. response. */ - @JsonProperty("token") fun token(): String = token + fun token(): String = token.getRequired("token") + + /** + * Amount (in cents) to authorize. This amount will override the transaction's amount that + * was originally set by /v1/simulate/authorize. + */ + fun amount(): Long = amount.getRequired("amount") + + /** The transaction token returned from the /v1/simulate/authorize. response. */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * Amount (in cents) to authorize. This amount will override the transaction's amount that * was originally set by /v1/simulate/authorize. */ - @JsonProperty("amount") fun amount(): Long = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TransactionSimulateAuthorizationAdviceBody = apply { + if (!validated) { + token() + amount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -79,8 +113,8 @@ constructor( class Builder { - private var token: String? = null - private var amount: Long? = null + private var token: JsonField? = null + private var amount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -94,13 +128,22 @@ constructor( } /** The transaction token returned from the /v1/simulate/authorize. response. */ - fun token(token: String) = apply { this.token = token } + fun token(token: String) = token(JsonField.of(token)) + + /** The transaction token returned from the /v1/simulate/authorize. response. */ + fun token(token: JsonField) = apply { this.token = token } /** * Amount (in cents) to authorize. This amount will override the transaction's amount * that was originally set by /v1/simulate/authorize. */ - fun amount(amount: Long) = apply { this.amount = amount } + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Amount (in cents) to authorize. This amount will override the transaction's amount + * that was originally set by /v1/simulate/authorize. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -176,12 +219,40 @@ constructor( /** The transaction token returned from the /v1/simulate/authorize. response. */ fun token(token: String) = apply { body.token(token) } + /** The transaction token returned from the /v1/simulate/authorize. response. */ + fun token(token: JsonField) = apply { body.token(token) } + /** * Amount (in cents) to authorize. This amount will override the transaction's amount that * was originally set by /v1/simulate/authorize. */ fun amount(amount: Long) = apply { body.amount(amount) } + /** + * Amount (in cents) to authorize. This amount will override the transaction's amount that + * was originally set by /v1/simulate/authorize. + */ + fun amount(amount: JsonField) = apply { body.amount(amount) } + + 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) @@ -280,25 +351,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): TransactionSimulateAuthorizationAdviceParams = TransactionSimulateAuthorizationAdviceParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationAdviceResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationAdviceResponse.kt index 56c4d63b..b83e35c1 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationAdviceResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationAdviceResponse.kt @@ -33,12 +33,12 @@ private constructor( fun debuggingRequestId(): String? = debuggingRequestId.getNullable("debugging_request_id") /** A unique token to reference this transaction. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Debugging request ID to share with Lithic Support team. */ @JsonProperty("debugging_request_id") @ExcludeMissing - fun _debuggingRequestId() = debuggingRequestId + fun _debuggingRequestId(): JsonField = debuggingRequestId @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationParams.kt index 63c8d724..484e38fa 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -94,12 +95,73 @@ constructor( */ fun status(): Status? = body.status() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * Amount (in cents) to authorize. For credit authorizations and financial credit + * authorizations, any value entered will be converted into a negative amount in the simulated + * transaction. For example, entering 100 in this field will result in a -100 amount in the + * transaction. For balance inquiries, this field must be set to 0. + */ + fun _amount(): JsonField = body._amount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Merchant descriptor. */ + fun _descriptor(): JsonField = body._descriptor() + + /** Sixteen digit card number. */ + fun _pan(): JsonField = body._pan() + + /** + * Merchant category code for the transaction to be simulated. A four-digit number listed in + * ISO 18245. Supported merchant category codes can be found + * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). + */ + fun _mcc(): JsonField = body._mcc() + + /** Unique identifier to identify the payment card acceptor. */ + fun _merchantAcceptorId(): JsonField = body._merchantAcceptorId() + + /** + * Amount of the transaction to be simulated in currency specified in merchant_currency, + * including any acquirer fees. + */ + fun _merchantAmount(): JsonField = body._merchantAmount() + + /** + * 3-digit alphabetic ISO 4217 currency code. Note: Simulator only accepts USD, GBP, EUR and + * defaults to GBP if another ISO 4217 code is provided + */ + fun _merchantCurrency(): JsonField = body._merchantCurrency() + + /** + * Set to true if the terminal is capable of partial approval otherwise false. Partial approval + * is when part of a transaction is approved and another payment must be used for the remainder. + */ + fun _partialApprovalCapable(): JsonField = body._partialApprovalCapable() + + /** Simulate entering a PIN. If omitted, PIN check will not be performed. */ + fun _pin(): JsonField = body._pin() + + /** + * Type of event to simulate. + * - `AUTHORIZATION` is a dual message purchase authorization, meaning a subsequent clearing + * step is required to settle the transaction. + * - `BALANCE_INQUIRY` is a $0 authorization requesting the balance held on the card, and is + * most often observed when a cardholder requests to view a card's balance at an ATM. + * - `CREDIT_AUTHORIZATION` is a dual message request from a merchant to authorize a refund, + * meaning a subsequent clearing step is required to settle the transaction. + * - `FINANCIAL_AUTHORIZATION` is a single message request from a merchant to debit funds + * immediately (such as an ATM withdrawal), and no subsequent clearing is required to settle + * the transaction. + * - `FINANCIAL_CREDIT_AUTHORIZATION` is a single message request from a merchant to credit + * funds immediately, and no subsequent clearing is required to settle the transaction. + */ + fun _status(): JsonField = body._status() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): TransactionSimulateAuthorizationBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -110,16 +172,30 @@ constructor( class TransactionSimulateAuthorizationBody @JsonCreator internal constructor( - @JsonProperty("amount") private val amount: Long, - @JsonProperty("descriptor") private val descriptor: String, - @JsonProperty("pan") private val pan: String, - @JsonProperty("mcc") private val mcc: String?, - @JsonProperty("merchant_acceptor_id") private val merchantAcceptorId: String?, - @JsonProperty("merchant_amount") private val merchantAmount: Long?, - @JsonProperty("merchant_currency") private val merchantCurrency: String?, - @JsonProperty("partial_approval_capable") private val partialApprovalCapable: Boolean?, - @JsonProperty("pin") private val pin: String?, - @JsonProperty("status") private val status: Status?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("descriptor") + @ExcludeMissing + private val descriptor: JsonField = JsonMissing.of(), + @JsonProperty("pan") @ExcludeMissing private val pan: JsonField = JsonMissing.of(), + @JsonProperty("mcc") @ExcludeMissing private val mcc: JsonField = JsonMissing.of(), + @JsonProperty("merchant_acceptor_id") + @ExcludeMissing + private val merchantAcceptorId: JsonField = JsonMissing.of(), + @JsonProperty("merchant_amount") + @ExcludeMissing + private val merchantAmount: JsonField = JsonMissing.of(), + @JsonProperty("merchant_currency") + @ExcludeMissing + private val merchantCurrency: JsonField = JsonMissing.of(), + @JsonProperty("partial_approval_capable") + @ExcludeMissing + private val partialApprovalCapable: JsonField = JsonMissing.of(), + @JsonProperty("pin") @ExcludeMissing private val pin: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -130,35 +206,106 @@ constructor( * simulated transaction. For example, entering 100 in this field will result in a -100 * amount in the transaction. For balance inquiries, this field must be set to 0. */ - @JsonProperty("amount") fun amount(): Long = amount + fun amount(): Long = amount.getRequired("amount") /** Merchant descriptor. */ - @JsonProperty("descriptor") fun descriptor(): String = descriptor + fun descriptor(): String = descriptor.getRequired("descriptor") /** Sixteen digit card number. */ - @JsonProperty("pan") fun pan(): String = pan + fun pan(): String = pan.getRequired("pan") /** * Merchant category code for the transaction to be simulated. A four-digit number listed in * ISO 18245. Supported merchant category codes can be found * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). */ - @JsonProperty("mcc") fun mcc(): String? = mcc + fun mcc(): String? = mcc.getNullable("mcc") /** Unique identifier to identify the payment card acceptor. */ - @JsonProperty("merchant_acceptor_id") fun merchantAcceptorId(): String? = merchantAcceptorId + fun merchantAcceptorId(): String? = merchantAcceptorId.getNullable("merchant_acceptor_id") /** * Amount of the transaction to be simulated in currency specified in merchant_currency, * including any acquirer fees. */ - @JsonProperty("merchant_amount") fun merchantAmount(): Long? = merchantAmount + fun merchantAmount(): Long? = merchantAmount.getNullable("merchant_amount") /** * 3-digit alphabetic ISO 4217 currency code. Note: Simulator only accepts USD, GBP, EUR and * defaults to GBP if another ISO 4217 code is provided */ - @JsonProperty("merchant_currency") fun merchantCurrency(): String? = merchantCurrency + fun merchantCurrency(): String? = merchantCurrency.getNullable("merchant_currency") + + /** + * Set to true if the terminal is capable of partial approval otherwise false. Partial + * approval is when part of a transaction is approved and another payment must be used for + * the remainder. + */ + fun partialApprovalCapable(): Boolean? = + partialApprovalCapable.getNullable("partial_approval_capable") + + /** Simulate entering a PIN. If omitted, PIN check will not be performed. */ + fun pin(): String? = pin.getNullable("pin") + + /** + * Type of event to simulate. + * - `AUTHORIZATION` is a dual message purchase authorization, meaning a subsequent clearing + * step is required to settle the transaction. + * - `BALANCE_INQUIRY` is a $0 authorization requesting the balance held on the card, and is + * most often observed when a cardholder requests to view a card's balance at an ATM. + * - `CREDIT_AUTHORIZATION` is a dual message request from a merchant to authorize a refund, + * meaning a subsequent clearing step is required to settle the transaction. + * - `FINANCIAL_AUTHORIZATION` is a single message request from a merchant to debit funds + * immediately (such as an ATM withdrawal), and no subsequent clearing is required to + * settle the transaction. + * - `FINANCIAL_CREDIT_AUTHORIZATION` is a single message request from a merchant to credit + * funds immediately, and no subsequent clearing is required to settle the transaction. + */ + fun status(): Status? = status.getNullable("status") + + /** + * Amount (in cents) to authorize. For credit authorizations and financial credit + * authorizations, any value entered will be converted into a negative amount in the + * simulated transaction. For example, entering 100 in this field will result in a -100 + * amount in the transaction. For balance inquiries, this field must be set to 0. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** Merchant descriptor. */ + @JsonProperty("descriptor") + @ExcludeMissing + fun _descriptor(): JsonField = descriptor + + /** Sixteen digit card number. */ + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan + + /** + * Merchant category code for the transaction to be simulated. A four-digit number listed in + * ISO 18245. Supported merchant category codes can be found + * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). + */ + @JsonProperty("mcc") @ExcludeMissing fun _mcc(): JsonField = mcc + + /** Unique identifier to identify the payment card acceptor. */ + @JsonProperty("merchant_acceptor_id") + @ExcludeMissing + fun _merchantAcceptorId(): JsonField = merchantAcceptorId + + /** + * Amount of the transaction to be simulated in currency specified in merchant_currency, + * including any acquirer fees. + */ + @JsonProperty("merchant_amount") + @ExcludeMissing + fun _merchantAmount(): JsonField = merchantAmount + + /** + * 3-digit alphabetic ISO 4217 currency code. Note: Simulator only accepts USD, GBP, EUR and + * defaults to GBP if another ISO 4217 code is provided + */ + @JsonProperty("merchant_currency") + @ExcludeMissing + fun _merchantCurrency(): JsonField = merchantCurrency /** * Set to true if the terminal is capable of partial approval otherwise false. Partial @@ -166,10 +313,11 @@ constructor( * the remainder. */ @JsonProperty("partial_approval_capable") - fun partialApprovalCapable(): Boolean? = partialApprovalCapable + @ExcludeMissing + fun _partialApprovalCapable(): JsonField = partialApprovalCapable /** Simulate entering a PIN. If omitted, PIN check will not be performed. */ - @JsonProperty("pin") fun pin(): String? = pin + @JsonProperty("pin") @ExcludeMissing fun _pin(): JsonField = pin /** * Type of event to simulate. @@ -185,12 +333,30 @@ constructor( * - `FINANCIAL_CREDIT_AUTHORIZATION` is a single message request from a merchant to credit * funds immediately, and no subsequent clearing is required to settle the transaction. */ - @JsonProperty("status") fun status(): Status? = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TransactionSimulateAuthorizationBody = apply { + if (!validated) { + amount() + descriptor() + pan() + mcc() + merchantAcceptorId() + merchantAmount() + merchantCurrency() + partialApprovalCapable() + pin() + status() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -200,16 +366,16 @@ constructor( class Builder { - private var amount: Long? = null - private var descriptor: String? = null - private var pan: String? = null - private var mcc: String? = null - private var merchantAcceptorId: String? = null - private var merchantAmount: Long? = null - private var merchantCurrency: String? = null - private var partialApprovalCapable: Boolean? = null - private var pin: String? = null - private var status: Status? = null + private var amount: JsonField? = null + private var descriptor: JsonField? = null + private var pan: JsonField? = null + private var mcc: JsonField = JsonMissing.of() + private var merchantAcceptorId: JsonField = JsonMissing.of() + private var merchantAmount: JsonField = JsonMissing.of() + private var merchantCurrency: JsonField = JsonMissing.of() + private var partialApprovalCapable: JsonField = JsonMissing.of() + private var pin: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -235,23 +401,48 @@ constructor( * simulated transaction. For example, entering 100 in this field will result in a -100 * amount in the transaction. For balance inquiries, this field must be set to 0. */ - fun amount(amount: Long) = apply { this.amount = amount } + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Amount (in cents) to authorize. For credit authorizations and financial credit + * authorizations, any value entered will be converted into a negative amount in the + * simulated transaction. For example, entering 100 in this field will result in a -100 + * amount in the transaction. For balance inquiries, this field must be set to 0. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Merchant descriptor. */ + fun descriptor(descriptor: String) = descriptor(JsonField.of(descriptor)) /** Merchant descriptor. */ - fun descriptor(descriptor: String) = apply { this.descriptor = descriptor } + fun descriptor(descriptor: JsonField) = apply { this.descriptor = descriptor } + + /** Sixteen digit card number. */ + fun pan(pan: String) = pan(JsonField.of(pan)) /** Sixteen digit card number. */ - fun pan(pan: String) = apply { this.pan = pan } + fun pan(pan: JsonField) = apply { this.pan = pan } + + /** + * Merchant category code for the transaction to be simulated. A four-digit number + * listed in ISO 18245. Supported merchant category codes can be found + * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). + */ + fun mcc(mcc: String) = mcc(JsonField.of(mcc)) /** * Merchant category code for the transaction to be simulated. A four-digit number * listed in ISO 18245. Supported merchant category codes can be found * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). */ - fun mcc(mcc: String?) = apply { this.mcc = mcc } + fun mcc(mcc: JsonField) = apply { this.mcc = mcc } /** Unique identifier to identify the payment card acceptor. */ - fun merchantAcceptorId(merchantAcceptorId: String?) = apply { + fun merchantAcceptorId(merchantAcceptorId: String) = + merchantAcceptorId(JsonField.of(merchantAcceptorId)) + + /** Unique identifier to identify the payment card acceptor. */ + fun merchantAcceptorId(merchantAcceptorId: JsonField) = apply { this.merchantAcceptorId = merchantAcceptorId } @@ -259,21 +450,28 @@ constructor( * Amount of the transaction to be simulated in currency specified in merchant_currency, * including any acquirer fees. */ - fun merchantAmount(merchantAmount: Long?) = apply { - this.merchantAmount = merchantAmount - } + fun merchantAmount(merchantAmount: Long) = merchantAmount(JsonField.of(merchantAmount)) /** * Amount of the transaction to be simulated in currency specified in merchant_currency, * including any acquirer fees. */ - fun merchantAmount(merchantAmount: Long) = merchantAmount(merchantAmount as Long?) + fun merchantAmount(merchantAmount: JsonField) = apply { + this.merchantAmount = merchantAmount + } /** * 3-digit alphabetic ISO 4217 currency code. Note: Simulator only accepts USD, GBP, EUR * and defaults to GBP if another ISO 4217 code is provided */ - fun merchantCurrency(merchantCurrency: String?) = apply { + fun merchantCurrency(merchantCurrency: String) = + merchantCurrency(JsonField.of(merchantCurrency)) + + /** + * 3-digit alphabetic ISO 4217 currency code. Note: Simulator only accepts USD, GBP, EUR + * and defaults to GBP if another ISO 4217 code is provided + */ + fun merchantCurrency(merchantCurrency: JsonField) = apply { this.merchantCurrency = merchantCurrency } @@ -282,20 +480,41 @@ constructor( * approval is when part of a transaction is approved and another payment must be used * for the remainder. */ - fun partialApprovalCapable(partialApprovalCapable: Boolean?) = apply { - this.partialApprovalCapable = partialApprovalCapable - } + fun partialApprovalCapable(partialApprovalCapable: Boolean) = + partialApprovalCapable(JsonField.of(partialApprovalCapable)) /** * Set to true if the terminal is capable of partial approval otherwise false. Partial * approval is when part of a transaction is approved and another payment must be used * for the remainder. */ - fun partialApprovalCapable(partialApprovalCapable: Boolean) = - partialApprovalCapable(partialApprovalCapable as Boolean?) + fun partialApprovalCapable(partialApprovalCapable: JsonField) = apply { + this.partialApprovalCapable = partialApprovalCapable + } + + /** Simulate entering a PIN. If omitted, PIN check will not be performed. */ + fun pin(pin: String) = pin(JsonField.of(pin)) /** Simulate entering a PIN. If omitted, PIN check will not be performed. */ - fun pin(pin: String?) = apply { this.pin = pin } + fun pin(pin: JsonField) = apply { this.pin = pin } + + /** + * Type of event to simulate. + * - `AUTHORIZATION` is a dual message purchase authorization, meaning a subsequent + * clearing step is required to settle the transaction. + * - `BALANCE_INQUIRY` is a $0 authorization requesting the balance held on the card, + * and is most often observed when a cardholder requests to view a card's balance at + * an ATM. + * - `CREDIT_AUTHORIZATION` is a dual message request from a merchant to authorize a + * refund, meaning a subsequent clearing step is required to settle the transaction. + * - `FINANCIAL_AUTHORIZATION` is a single message request from a merchant to debit + * funds immediately (such as an ATM withdrawal), and no subsequent clearing is + * required to settle the transaction. + * - `FINANCIAL_CREDIT_AUTHORIZATION` is a single message request from a merchant to + * credit funds immediately, and no subsequent clearing is required to settle the + * transaction. + */ + fun status(status: Status) = status(JsonField.of(status)) /** * Type of event to simulate. @@ -313,7 +532,7 @@ constructor( * credit funds immediately, and no subsequent clearing is required to settle the * transaction. */ - fun status(status: Status?) = apply { this.status = status } + fun status(status: JsonField) = apply { this.status = status } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -400,21 +619,47 @@ constructor( */ fun amount(amount: Long) = apply { body.amount(amount) } + /** + * Amount (in cents) to authorize. For credit authorizations and financial credit + * authorizations, any value entered will be converted into a negative amount in the + * simulated transaction. For example, entering 100 in this field will result in a -100 + * amount in the transaction. For balance inquiries, this field must be set to 0. + */ + fun amount(amount: JsonField) = apply { body.amount(amount) } + /** Merchant descriptor. */ fun descriptor(descriptor: String) = apply { body.descriptor(descriptor) } + /** Merchant descriptor. */ + fun descriptor(descriptor: JsonField) = apply { body.descriptor(descriptor) } + /** Sixteen digit card number. */ fun pan(pan: String) = apply { body.pan(pan) } + /** Sixteen digit card number. */ + fun pan(pan: JsonField) = apply { body.pan(pan) } + + /** + * Merchant category code for the transaction to be simulated. A four-digit number listed in + * ISO 18245. Supported merchant category codes can be found + * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). + */ + fun mcc(mcc: String) = apply { body.mcc(mcc) } + /** * Merchant category code for the transaction to be simulated. A four-digit number listed in * ISO 18245. Supported merchant category codes can be found * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). */ - fun mcc(mcc: String?) = apply { body.mcc(mcc) } + fun mcc(mcc: JsonField) = apply { body.mcc(mcc) } + + /** Unique identifier to identify the payment card acceptor. */ + fun merchantAcceptorId(merchantAcceptorId: String) = apply { + body.merchantAcceptorId(merchantAcceptorId) + } /** Unique identifier to identify the payment card acceptor. */ - fun merchantAcceptorId(merchantAcceptorId: String?) = apply { + fun merchantAcceptorId(merchantAcceptorId: JsonField) = apply { body.merchantAcceptorId(merchantAcceptorId) } @@ -422,19 +667,29 @@ constructor( * Amount of the transaction to be simulated in currency specified in merchant_currency, * including any acquirer fees. */ - fun merchantAmount(merchantAmount: Long?) = apply { body.merchantAmount(merchantAmount) } + fun merchantAmount(merchantAmount: Long) = apply { body.merchantAmount(merchantAmount) } /** * Amount of the transaction to be simulated in currency specified in merchant_currency, * including any acquirer fees. */ - fun merchantAmount(merchantAmount: Long) = merchantAmount(merchantAmount as Long?) + fun merchantAmount(merchantAmount: JsonField) = apply { + body.merchantAmount(merchantAmount) + } /** * 3-digit alphabetic ISO 4217 currency code. Note: Simulator only accepts USD, GBP, EUR and * defaults to GBP if another ISO 4217 code is provided */ - fun merchantCurrency(merchantCurrency: String?) = apply { + fun merchantCurrency(merchantCurrency: String) = apply { + body.merchantCurrency(merchantCurrency) + } + + /** + * 3-digit alphabetic ISO 4217 currency code. Note: Simulator only accepts USD, GBP, EUR and + * defaults to GBP if another ISO 4217 code is provided + */ + fun merchantCurrency(merchantCurrency: JsonField) = apply { body.merchantCurrency(merchantCurrency) } @@ -443,7 +698,7 @@ constructor( * approval is when part of a transaction is approved and another payment must be used for * the remainder. */ - fun partialApprovalCapable(partialApprovalCapable: Boolean?) = apply { + fun partialApprovalCapable(partialApprovalCapable: Boolean) = apply { body.partialApprovalCapable(partialApprovalCapable) } @@ -452,11 +707,15 @@ constructor( * approval is when part of a transaction is approved and another payment must be used for * the remainder. */ - fun partialApprovalCapable(partialApprovalCapable: Boolean) = - partialApprovalCapable(partialApprovalCapable as Boolean?) + fun partialApprovalCapable(partialApprovalCapable: JsonField) = apply { + body.partialApprovalCapable(partialApprovalCapable) + } + + /** Simulate entering a PIN. If omitted, PIN check will not be performed. */ + fun pin(pin: String) = apply { body.pin(pin) } /** Simulate entering a PIN. If omitted, PIN check will not be performed. */ - fun pin(pin: String?) = apply { body.pin(pin) } + fun pin(pin: JsonField) = apply { body.pin(pin) } /** * Type of event to simulate. @@ -472,7 +731,42 @@ constructor( * - `FINANCIAL_CREDIT_AUTHORIZATION` is a single message request from a merchant to credit * funds immediately, and no subsequent clearing is required to settle the transaction. */ - fun status(status: Status?) = apply { body.status(status) } + fun status(status: Status) = apply { body.status(status) } + + /** + * Type of event to simulate. + * - `AUTHORIZATION` is a dual message purchase authorization, meaning a subsequent clearing + * step is required to settle the transaction. + * - `BALANCE_INQUIRY` is a $0 authorization requesting the balance held on the card, and is + * most often observed when a cardholder requests to view a card's balance at an ATM. + * - `CREDIT_AUTHORIZATION` is a dual message request from a merchant to authorize a refund, + * meaning a subsequent clearing step is required to settle the transaction. + * - `FINANCIAL_AUTHORIZATION` is a single message request from a merchant to debit funds + * immediately (such as an ATM withdrawal), and no subsequent clearing is required to + * settle the transaction. + * - `FINANCIAL_CREDIT_AUTHORIZATION` is a single message request from a merchant to credit + * funds immediately, and no subsequent clearing is required to settle the transaction. + */ + fun status(status: JsonField) = apply { body.status(status) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -572,25 +866,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): TransactionSimulateAuthorizationParams = TransactionSimulateAuthorizationParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationResponse.kt index 8f025c72..98abdf29 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateAuthorizationResponse.kt @@ -39,12 +39,12 @@ private constructor( * A unique token to reference this transaction with later calls to void or clear the * authorization. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Debugging request ID to share with Lithic Support team. */ @JsonProperty("debugging_request_id") @ExcludeMissing - fun _debuggingRequestId() = debuggingRequestId + fun _debuggingRequestId(): JsonField = debuggingRequestId @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateClearingParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateClearingParams.kt index 6ab84b03..bd81440a 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateClearingParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateClearingParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -44,12 +46,27 @@ constructor( */ fun amount(): Long? = body.amount() - fun _additionalHeaders(): Headers = additionalHeaders + /** The transaction token returned from the /v1/simulate/authorize response. */ + fun _token(): JsonField = body._token() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Amount (in cents) to clear. Typically this will match the amount in the original + * authorization, but can be higher or lower. The sign of this amount will automatically match + * the sign of the original authorization's amount. For example, entering 100 in this field will + * result in a -100 amount in the transaction, if the original authorization is a credit + * authorization. + * + * If `amount` is not set, the full amount of the transaction will be cleared. Transactions that + * have already cleared, either partially or fully, cannot be cleared again using this endpoint. + */ + fun _amount(): JsonField = body._amount() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): TransactionSimulateClearingBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -60,14 +77,34 @@ constructor( class TransactionSimulateClearingBody @JsonCreator internal constructor( - @JsonProperty("token") private val token: String, - @JsonProperty("amount") private val amount: Long?, + @JsonProperty("token") + @ExcludeMissing + private val token: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The transaction token returned from the /v1/simulate/authorize response. */ - @JsonProperty("token") fun token(): String = token + fun token(): String = token.getRequired("token") + + /** + * Amount (in cents) to clear. Typically this will match the amount in the original + * authorization, but can be higher or lower. The sign of this amount will automatically + * match the sign of the original authorization's amount. For example, entering 100 in this + * field will result in a -100 amount in the transaction, if the original authorization is a + * credit authorization. + * + * If `amount` is not set, the full amount of the transaction will be cleared. Transactions + * that have already cleared, either partially or fully, cannot be cleared again using this + * endpoint. + */ + fun amount(): Long? = amount.getNullable("amount") + + /** The transaction token returned from the /v1/simulate/authorize response. */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * Amount (in cents) to clear. Typically this will match the amount in the original @@ -80,12 +117,22 @@ constructor( * that have already cleared, either partially or fully, cannot be cleared again using this * endpoint. */ - @JsonProperty("amount") fun amount(): Long? = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TransactionSimulateClearingBody = apply { + if (!validated) { + token() + amount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -95,8 +142,8 @@ constructor( class Builder { - private var token: String? = null - private var amount: Long? = null + private var token: JsonField? = null + private var amount: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(transactionSimulateClearingBody: TransactionSimulateClearingBody) = @@ -108,7 +155,10 @@ constructor( } /** The transaction token returned from the /v1/simulate/authorize response. */ - fun token(token: String) = apply { this.token = token } + fun token(token: String) = token(JsonField.of(token)) + + /** The transaction token returned from the /v1/simulate/authorize response. */ + fun token(token: JsonField) = apply { this.token = token } /** * Amount (in cents) to clear. Typically this will match the amount in the original @@ -121,7 +171,7 @@ constructor( * Transactions that have already cleared, either partially or fully, cannot be cleared * again using this endpoint. */ - fun amount(amount: Long?) = apply { this.amount = amount } + fun amount(amount: Long) = amount(JsonField.of(amount)) /** * Amount (in cents) to clear. Typically this will match the amount in the original @@ -134,7 +184,7 @@ constructor( * Transactions that have already cleared, either partially or fully, cannot be cleared * again using this endpoint. */ - fun amount(amount: Long) = amount(amount as Long?) + fun amount(amount: JsonField) = apply { this.amount = amount } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -207,6 +257,9 @@ constructor( /** The transaction token returned from the /v1/simulate/authorize response. */ fun token(token: String) = apply { body.token(token) } + /** The transaction token returned from the /v1/simulate/authorize response. */ + fun token(token: JsonField) = apply { body.token(token) } + /** * Amount (in cents) to clear. Typically this will match the amount in the original * authorization, but can be higher or lower. The sign of this amount will automatically @@ -218,7 +271,7 @@ constructor( * that have already cleared, either partially or fully, cannot be cleared again using this * endpoint. */ - fun amount(amount: Long?) = apply { body.amount(amount) } + fun amount(amount: Long) = apply { body.amount(amount) } /** * Amount (in cents) to clear. Typically this will match the amount in the original @@ -231,7 +284,26 @@ constructor( * that have already cleared, either partially or fully, cannot be cleared again using this * endpoint. */ - fun amount(amount: Long) = amount(amount as Long?) + fun amount(amount: JsonField) = apply { body.amount(amount) } + + 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() @@ -331,25 +403,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): TransactionSimulateClearingParams = TransactionSimulateClearingParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateClearingResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateClearingResponse.kt index 683c7fde..8cfcdf98 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateClearingResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateClearingResponse.kt @@ -31,7 +31,7 @@ private constructor( /** Debugging request ID to share with Lithic Support team. */ @JsonProperty("debugging_request_id") @ExcludeMissing - fun _debuggingRequestId() = debuggingRequestId + fun _debuggingRequestId(): JsonField = debuggingRequestId @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationParams.kt index f6363563..e6165871 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -49,12 +51,35 @@ constructor( /** Unique identifier to identify the payment card acceptor. */ fun merchantAcceptorId(): String? = body.merchantAcceptorId() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * Amount (in cents). Any value entered will be converted into a negative amount in the + * simulated transaction. For example, entering 100 in this field will appear as a -100 amount + * in the transaction. + */ + fun _amount(): JsonField = body._amount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Merchant descriptor. */ + fun _descriptor(): JsonField = body._descriptor() + + /** Sixteen digit card number. */ + fun _pan(): JsonField = body._pan() + + /** + * Merchant category code for the transaction to be simulated. A four-digit number listed in + * ISO 18245. Supported merchant category codes can be found + * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). + */ + fun _mcc(): JsonField = body._mcc() + + /** Unique identifier to identify the payment card acceptor. */ + fun _merchantAcceptorId(): JsonField = body._merchantAcceptorId() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): TransactionSimulateCreditAuthorizationBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -65,11 +90,17 @@ constructor( class TransactionSimulateCreditAuthorizationBody @JsonCreator internal constructor( - @JsonProperty("amount") private val amount: Long, - @JsonProperty("descriptor") private val descriptor: String, - @JsonProperty("pan") private val pan: String, - @JsonProperty("mcc") private val mcc: String?, - @JsonProperty("merchant_acceptor_id") private val merchantAcceptorId: String?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("descriptor") + @ExcludeMissing + private val descriptor: JsonField = JsonMissing.of(), + @JsonProperty("pan") @ExcludeMissing private val pan: JsonField = JsonMissing.of(), + @JsonProperty("mcc") @ExcludeMissing private val mcc: JsonField = JsonMissing.of(), + @JsonProperty("merchant_acceptor_id") + @ExcludeMissing + private val merchantAcceptorId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -79,28 +110,68 @@ constructor( * simulated transaction. For example, entering 100 in this field will appear as a -100 * amount in the transaction. */ - @JsonProperty("amount") fun amount(): Long = amount + fun amount(): Long = amount.getRequired("amount") /** Merchant descriptor. */ - @JsonProperty("descriptor") fun descriptor(): String = descriptor + fun descriptor(): String = descriptor.getRequired("descriptor") /** Sixteen digit card number. */ - @JsonProperty("pan") fun pan(): String = pan + fun pan(): String = pan.getRequired("pan") /** * Merchant category code for the transaction to be simulated. A four-digit number listed in * ISO 18245. Supported merchant category codes can be found * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). */ - @JsonProperty("mcc") fun mcc(): String? = mcc + fun mcc(): String? = mcc.getNullable("mcc") /** Unique identifier to identify the payment card acceptor. */ - @JsonProperty("merchant_acceptor_id") fun merchantAcceptorId(): String? = merchantAcceptorId + fun merchantAcceptorId(): String? = merchantAcceptorId.getNullable("merchant_acceptor_id") + + /** + * Amount (in cents). Any value entered will be converted into a negative amount in the + * simulated transaction. For example, entering 100 in this field will appear as a -100 + * amount in the transaction. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** Merchant descriptor. */ + @JsonProperty("descriptor") + @ExcludeMissing + fun _descriptor(): JsonField = descriptor + + /** Sixteen digit card number. */ + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan + + /** + * Merchant category code for the transaction to be simulated. A four-digit number listed in + * ISO 18245. Supported merchant category codes can be found + * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). + */ + @JsonProperty("mcc") @ExcludeMissing fun _mcc(): JsonField = mcc + + /** Unique identifier to identify the payment card acceptor. */ + @JsonProperty("merchant_acceptor_id") + @ExcludeMissing + fun _merchantAcceptorId(): JsonField = merchantAcceptorId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TransactionSimulateCreditAuthorizationBody = apply { + if (!validated) { + amount() + descriptor() + pan() + mcc() + merchantAcceptorId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -110,11 +181,11 @@ constructor( class Builder { - private var amount: Long? = null - private var descriptor: String? = null - private var pan: String? = null - private var mcc: String? = null - private var merchantAcceptorId: String? = null + private var amount: JsonField? = null + private var descriptor: JsonField? = null + private var pan: JsonField? = null + private var mcc: JsonField = JsonMissing.of() + private var merchantAcceptorId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -135,23 +206,47 @@ constructor( * simulated transaction. For example, entering 100 in this field will appear as a -100 * amount in the transaction. */ - fun amount(amount: Long) = apply { this.amount = amount } + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Amount (in cents). Any value entered will be converted into a negative amount in the + * simulated transaction. For example, entering 100 in this field will appear as a -100 + * amount in the transaction. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } /** Merchant descriptor. */ - fun descriptor(descriptor: String) = apply { this.descriptor = descriptor } + fun descriptor(descriptor: String) = descriptor(JsonField.of(descriptor)) + + /** Merchant descriptor. */ + fun descriptor(descriptor: JsonField) = apply { this.descriptor = descriptor } + + /** Sixteen digit card number. */ + fun pan(pan: String) = pan(JsonField.of(pan)) /** Sixteen digit card number. */ - fun pan(pan: String) = apply { this.pan = pan } + fun pan(pan: JsonField) = apply { this.pan = pan } /** * Merchant category code for the transaction to be simulated. A four-digit number * listed in ISO 18245. Supported merchant category codes can be found * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). */ - fun mcc(mcc: String?) = apply { this.mcc = mcc } + fun mcc(mcc: String) = mcc(JsonField.of(mcc)) + + /** + * Merchant category code for the transaction to be simulated. A four-digit number + * listed in ISO 18245. Supported merchant category codes can be found + * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). + */ + fun mcc(mcc: JsonField) = apply { this.mcc = mcc } + + /** Unique identifier to identify the payment card acceptor. */ + fun merchantAcceptorId(merchantAcceptorId: String) = + merchantAcceptorId(JsonField.of(merchantAcceptorId)) /** Unique identifier to identify the payment card acceptor. */ - fun merchantAcceptorId(merchantAcceptorId: String?) = apply { + fun merchantAcceptorId(merchantAcceptorId: JsonField) = apply { this.merchantAcceptorId = merchantAcceptorId } @@ -236,24 +331,68 @@ constructor( */ fun amount(amount: Long) = apply { body.amount(amount) } + /** + * Amount (in cents). Any value entered will be converted into a negative amount in the + * simulated transaction. For example, entering 100 in this field will appear as a -100 + * amount in the transaction. + */ + fun amount(amount: JsonField) = apply { body.amount(amount) } + /** Merchant descriptor. */ fun descriptor(descriptor: String) = apply { body.descriptor(descriptor) } + /** Merchant descriptor. */ + fun descriptor(descriptor: JsonField) = apply { body.descriptor(descriptor) } + /** Sixteen digit card number. */ fun pan(pan: String) = apply { body.pan(pan) } + /** Sixteen digit card number. */ + fun pan(pan: JsonField) = apply { body.pan(pan) } + /** * Merchant category code for the transaction to be simulated. A four-digit number listed in * ISO 18245. Supported merchant category codes can be found * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). */ - fun mcc(mcc: String?) = apply { body.mcc(mcc) } + fun mcc(mcc: String) = apply { body.mcc(mcc) } + + /** + * Merchant category code for the transaction to be simulated. A four-digit number listed in + * ISO 18245. Supported merchant category codes can be found + * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). + */ + fun mcc(mcc: JsonField) = apply { body.mcc(mcc) } + + /** Unique identifier to identify the payment card acceptor. */ + fun merchantAcceptorId(merchantAcceptorId: String) = apply { + body.merchantAcceptorId(merchantAcceptorId) + } /** Unique identifier to identify the payment card acceptor. */ - fun merchantAcceptorId(merchantAcceptorId: String?) = apply { + fun merchantAcceptorId(merchantAcceptorId: JsonField) = apply { body.merchantAcceptorId(merchantAcceptorId) } + 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) @@ -352,25 +491,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): TransactionSimulateCreditAuthorizationParams = TransactionSimulateCreditAuthorizationParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationResponse.kt index 217e1891..ded48a50 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationResponse.kt @@ -33,12 +33,12 @@ private constructor( fun debuggingRequestId(): String? = debuggingRequestId.getNullable("debugging_request_id") /** A unique token to reference this transaction. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Debugging request ID to share with Lithic Support team. */ @JsonProperty("debugging_request_id") @ExcludeMissing - fun _debuggingRequestId() = debuggingRequestId + fun _debuggingRequestId(): JsonField = debuggingRequestId @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnParams.kt index 872307d9..4b9d0e7f 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -35,12 +37,21 @@ constructor( /** Sixteen digit card number. */ fun pan(): String = body.pan() - fun _additionalHeaders(): Headers = additionalHeaders + /** Amount (in cents) to authorize. */ + fun _amount(): JsonField = body._amount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** Merchant descriptor. */ + fun _descriptor(): JsonField = body._descriptor() + + /** Sixteen digit card number. */ + fun _pan(): JsonField = body._pan() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): TransactionSimulateReturnBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -51,26 +62,52 @@ constructor( class TransactionSimulateReturnBody @JsonCreator internal constructor( - @JsonProperty("amount") private val amount: Long, - @JsonProperty("descriptor") private val descriptor: String, - @JsonProperty("pan") private val pan: String, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("descriptor") + @ExcludeMissing + private val descriptor: JsonField = JsonMissing.of(), + @JsonProperty("pan") @ExcludeMissing private val pan: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Amount (in cents) to authorize. */ - @JsonProperty("amount") fun amount(): Long = amount + fun amount(): Long = amount.getRequired("amount") /** Merchant descriptor. */ - @JsonProperty("descriptor") fun descriptor(): String = descriptor + fun descriptor(): String = descriptor.getRequired("descriptor") + + /** Sixteen digit card number. */ + fun pan(): String = pan.getRequired("pan") + + /** Amount (in cents) to authorize. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** Merchant descriptor. */ + @JsonProperty("descriptor") + @ExcludeMissing + fun _descriptor(): JsonField = descriptor /** Sixteen digit card number. */ - @JsonProperty("pan") fun pan(): String = pan + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TransactionSimulateReturnBody = apply { + if (!validated) { + amount() + descriptor() + pan() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -80,9 +117,9 @@ constructor( class Builder { - private var amount: Long? = null - private var descriptor: String? = null - private var pan: String? = null + private var amount: JsonField? = null + private var descriptor: JsonField? = null + private var pan: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(transactionSimulateReturnBody: TransactionSimulateReturnBody) = @@ -95,13 +132,22 @@ constructor( } /** Amount (in cents) to authorize. */ - fun amount(amount: Long) = apply { this.amount = amount } + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** Amount (in cents) to authorize. */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Merchant descriptor. */ + fun descriptor(descriptor: String) = descriptor(JsonField.of(descriptor)) /** Merchant descriptor. */ - fun descriptor(descriptor: String) = apply { this.descriptor = descriptor } + fun descriptor(descriptor: JsonField) = apply { this.descriptor = descriptor } + + /** Sixteen digit card number. */ + fun pan(pan: String) = pan(JsonField.of(pan)) /** Sixteen digit card number. */ - fun pan(pan: String) = apply { this.pan = pan } + fun pan(pan: JsonField) = apply { this.pan = pan } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -175,12 +221,40 @@ constructor( /** Amount (in cents) to authorize. */ fun amount(amount: Long) = apply { body.amount(amount) } + /** Amount (in cents) to authorize. */ + fun amount(amount: JsonField) = apply { body.amount(amount) } + /** Merchant descriptor. */ fun descriptor(descriptor: String) = apply { body.descriptor(descriptor) } + /** Merchant descriptor. */ + fun descriptor(descriptor: JsonField) = apply { body.descriptor(descriptor) } + /** Sixteen digit card number. */ fun pan(pan: String) = apply { body.pan(pan) } + /** Sixteen digit card number. */ + fun pan(pan: JsonField) = apply { body.pan(pan) } + + 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) @@ -279,25 +353,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): TransactionSimulateReturnParams = TransactionSimulateReturnParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnResponse.kt index 7839b5ed..fd8ea573 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnResponse.kt @@ -33,12 +33,12 @@ private constructor( fun debuggingRequestId(): String? = debuggingRequestId.getNullable("debugging_request_id") /** A unique token to reference this transaction. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Debugging request ID to share with Lithic Support team. */ @JsonProperty("debugging_request_id") @ExcludeMissing - fun _debuggingRequestId() = debuggingRequestId + fun _debuggingRequestId(): JsonField = debuggingRequestId @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnReversalParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnReversalParams.kt index 311f2061..e0cb3bf2 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnReversalParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnReversalParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -29,12 +31,15 @@ constructor( /** The transaction token returned from the /v1/simulate/authorize response. */ fun token(): String = body.token() + /** The transaction token returned from the /v1/simulate/authorize response. */ + fun _token(): JsonField = body._token() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - internal fun getBody(): TransactionSimulateReturnReversalBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -45,18 +50,32 @@ constructor( class TransactionSimulateReturnReversalBody @JsonCreator internal constructor( - @JsonProperty("token") private val token: String, + @JsonProperty("token") + @ExcludeMissing + private val token: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The transaction token returned from the /v1/simulate/authorize response. */ - @JsonProperty("token") fun token(): String = token + fun token(): String = token.getRequired("token") + + /** The transaction token returned from the /v1/simulate/authorize response. */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TransactionSimulateReturnReversalBody = apply { + if (!validated) { + token() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -66,7 +85,7 @@ constructor( class Builder { - private var token: String? = null + private var token: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from( @@ -78,7 +97,10 @@ constructor( } /** The transaction token returned from the /v1/simulate/authorize response. */ - fun token(token: String) = apply { this.token = token } + fun token(token: String) = token(JsonField.of(token)) + + /** The transaction token returned from the /v1/simulate/authorize response. */ + fun token(token: JsonField) = apply { this.token = token } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -152,6 +174,28 @@ constructor( /** The transaction token returned from the /v1/simulate/authorize response. */ fun token(token: String) = apply { body.token(token) } + /** The transaction token returned from the /v1/simulate/authorize response. */ + fun token(token: JsonField) = apply { body.token(token) } + + 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) @@ -250,25 +294,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): TransactionSimulateReturnReversalParams = TransactionSimulateReturnReversalParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnReversalResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnReversalResponse.kt index 5f7024e3..7bab3fd7 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnReversalResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateReturnReversalResponse.kt @@ -31,7 +31,7 @@ private constructor( /** Debugging request ID to share with Lithic Support team. */ @JsonProperty("debugging_request_id") @ExcludeMissing - fun _debuggingRequestId() = debuggingRequestId + fun _debuggingRequestId(): JsonField = debuggingRequestId @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateVoidParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateVoidParams.kt index 51827c07..1ff6649a 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateVoidParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateVoidParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -47,12 +48,28 @@ constructor( */ fun type(): Type? = body.type() - fun _additionalHeaders(): Headers = additionalHeaders + /** The transaction token returned from the /v1/simulate/authorize response. */ + fun _token(): JsonField = body._token() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Amount (in cents) to void. Typically this will match the amount in the original + * authorization, but can be less. + */ + fun _amount(): JsonField = body._amount() + + /** + * Type of event to simulate. Defaults to `AUTHORIZATION_REVERSAL`. + * - `AUTHORIZATION_EXPIRY` indicates authorization has expired and been reversed by Lithic. + * - `AUTHORIZATION_REVERSAL` indicates authorization was reversed by the merchant. + */ + fun _type(): JsonField = body._type() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): TransactionSimulateVoidBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -63,33 +80,64 @@ constructor( class TransactionSimulateVoidBody @JsonCreator internal constructor( - @JsonProperty("token") private val token: String, - @JsonProperty("amount") private val amount: Long?, - @JsonProperty("type") private val type: Type?, + @JsonProperty("token") + @ExcludeMissing + private val token: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The transaction token returned from the /v1/simulate/authorize response. */ - @JsonProperty("token") fun token(): String = token + fun token(): String = token.getRequired("token") + + /** + * Amount (in cents) to void. Typically this will match the amount in the original + * authorization, but can be less. + */ + fun amount(): Long? = amount.getNullable("amount") + + /** + * Type of event to simulate. Defaults to `AUTHORIZATION_REVERSAL`. + * - `AUTHORIZATION_EXPIRY` indicates authorization has expired and been reversed by Lithic. + * - `AUTHORIZATION_REVERSAL` indicates authorization was reversed by the merchant. + */ + fun type(): Type? = type.getNullable("type") + + /** The transaction token returned from the /v1/simulate/authorize response. */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * Amount (in cents) to void. Typically this will match the amount in the original * authorization, but can be less. */ - @JsonProperty("amount") fun amount(): Long? = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * Type of event to simulate. Defaults to `AUTHORIZATION_REVERSAL`. * - `AUTHORIZATION_EXPIRY` indicates authorization has expired and been reversed by Lithic. * - `AUTHORIZATION_REVERSAL` indicates authorization was reversed by the merchant. */ - @JsonProperty("type") fun type(): Type? = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TransactionSimulateVoidBody = apply { + if (!validated) { + token() + amount() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -99,9 +147,9 @@ constructor( class Builder { - private var token: String? = null - private var amount: Long? = null - private var type: Type? = null + private var token: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(transactionSimulateVoidBody: TransactionSimulateVoidBody) = apply { @@ -113,19 +161,22 @@ constructor( } /** The transaction token returned from the /v1/simulate/authorize response. */ - fun token(token: String) = apply { this.token = token } + fun token(token: String) = token(JsonField.of(token)) + + /** The transaction token returned from the /v1/simulate/authorize response. */ + fun token(token: JsonField) = apply { this.token = token } /** * Amount (in cents) to void. Typically this will match the amount in the original * authorization, but can be less. */ - fun amount(amount: Long?) = apply { this.amount = amount } + fun amount(amount: Long) = amount(JsonField.of(amount)) /** * Amount (in cents) to void. Typically this will match the amount in the original * authorization, but can be less. */ - fun amount(amount: Long) = amount(amount as Long?) + fun amount(amount: JsonField) = apply { this.amount = amount } /** * Type of event to simulate. Defaults to `AUTHORIZATION_REVERSAL`. @@ -133,7 +184,15 @@ constructor( * Lithic. * - `AUTHORIZATION_REVERSAL` indicates authorization was reversed by the merchant. */ - fun type(type: Type?) = apply { this.type = type } + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Type of event to simulate. Defaults to `AUTHORIZATION_REVERSAL`. + * - `AUTHORIZATION_EXPIRY` indicates authorization has expired and been reversed by + * Lithic. + * - `AUTHORIZATION_REVERSAL` indicates authorization was reversed by the merchant. + */ + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -205,24 +264,53 @@ constructor( /** The transaction token returned from the /v1/simulate/authorize response. */ fun token(token: String) = apply { body.token(token) } + /** The transaction token returned from the /v1/simulate/authorize response. */ + fun token(token: JsonField) = apply { body.token(token) } + /** * Amount (in cents) to void. Typically this will match the amount in the original * authorization, but can be less. */ - fun amount(amount: Long?) = apply { body.amount(amount) } + fun amount(amount: Long) = apply { body.amount(amount) } /** * Amount (in cents) to void. Typically this will match the amount in the original * authorization, but can be less. */ - fun amount(amount: Long) = amount(amount as Long?) + fun amount(amount: JsonField) = apply { body.amount(amount) } + + /** + * Type of event to simulate. Defaults to `AUTHORIZATION_REVERSAL`. + * - `AUTHORIZATION_EXPIRY` indicates authorization has expired and been reversed by Lithic. + * - `AUTHORIZATION_REVERSAL` indicates authorization was reversed by the merchant. + */ + fun type(type: Type) = apply { body.type(type) } /** * Type of event to simulate. Defaults to `AUTHORIZATION_REVERSAL`. * - `AUTHORIZATION_EXPIRY` indicates authorization has expired and been reversed by Lithic. * - `AUTHORIZATION_REVERSAL` indicates authorization was reversed by the merchant. */ - fun type(type: Type?) = apply { body.type(type) } + fun type(type: JsonField) = apply { body.type(type) } + + 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() @@ -322,25 +410,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): TransactionSimulateVoidParams = TransactionSimulateVoidParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateVoidResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateVoidResponse.kt index b939a26a..dda08f99 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateVoidResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateVoidResponse.kt @@ -31,7 +31,7 @@ private constructor( /** Debugging request ID to share with Lithic Support team. */ @JsonProperty("debugging_request_id") @ExcludeMissing - fun _debuggingRequestId() = debuggingRequestId + fun _debuggingRequestId(): JsonField = debuggingRequestId @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Transfer.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Transfer.kt index 91771628..e4806992 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Transfer.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Transfer.kt @@ -122,47 +122,53 @@ private constructor( fun updated(): OffsetDateTime? = updated.getNullable("updated") /** Globally unique identifier for the transfer event. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * Status types: * - `TRANSFER` - Internal transfer of funds between financial accounts in your program. */ - @JsonProperty("category") @ExcludeMissing fun _category() = category + @JsonProperty("category") @ExcludeMissing fun _category(): JsonField = category /** Date and time when the transfer occurred. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** 3-digit alphabetic ISO 4217 code for the settling currency of the transaction. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** A string that provides a description of the transfer; may be useful to display to users. */ - @JsonProperty("descriptor") @ExcludeMissing fun _descriptor() = descriptor + @JsonProperty("descriptor") @ExcludeMissing fun _descriptor(): JsonField = descriptor /** A list of all financial events that have modified this trasnfer. */ - @JsonProperty("events") @ExcludeMissing fun _events() = events + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events /** The updated balance of the sending financial account. */ - @JsonProperty("from_balance") @ExcludeMissing fun _fromBalance() = fromBalance + @JsonProperty("from_balance") + @ExcludeMissing + fun _fromBalance(): JsonField> = fromBalance /** * Pending amount of the transaction in the currency's smallest unit (e.g., cents), including * any acquirer fees. The value of this field will go to zero over time once the financial * transaction is settled. */ - @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount /** * APPROVED transactions were successful while DECLINED transactions were declined by user, * Lithic, or the network. */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result /** * Amount of the transaction that has been settled in the currency's smallest unit (e.g., * cents). */ - @JsonProperty("settled_amount") @ExcludeMissing fun _settledAmount() = settledAmount + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount /** * Status types: @@ -172,13 +178,15 @@ private constructor( * - `SETTLED` - The transfer is completed. * - `VOIDED` - The transfer was reversed before it settled. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** The updated balance of the receiving financial account. */ - @JsonProperty("to_balance") @ExcludeMissing fun _toBalance() = toBalance + @JsonProperty("to_balance") + @ExcludeMissing + fun _toBalance(): JsonField> = toBalance /** Date and time when the financial transaction was last updated. UTC time zone. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated @JsonAnyGetter @ExcludeMissing @@ -219,13 +227,13 @@ private constructor( private var created: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() private var descriptor: JsonField = JsonMissing.of() - private var events: JsonField> = JsonMissing.of() - private var fromBalance: JsonField> = JsonMissing.of() + private var events: JsonField>? = null + private var fromBalance: JsonField>? = null private var pendingAmount: JsonField = JsonMissing.of() private var result: JsonField = JsonMissing.of() private var settledAmount: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() - private var toBalance: JsonField> = JsonMissing.of() + private var toBalance: JsonField>? = null private var updated: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -235,13 +243,13 @@ private constructor( created = transfer.created currency = transfer.currency descriptor = transfer.descriptor - events = transfer.events - fromBalance = transfer.fromBalance + events = transfer.events.map { it.toMutableList() } + fromBalance = transfer.fromBalance.map { it.toMutableList() } pendingAmount = transfer.pendingAmount result = transfer.result settledAmount = transfer.settledAmount status = transfer.status - toBalance = transfer.toBalance + toBalance = transfer.toBalance.map { it.toMutableList() } updated = transfer.updated additionalProperties = transfer.additionalProperties.toMutableMap() } @@ -290,14 +298,40 @@ private constructor( fun events(events: List) = events(JsonField.of(events)) /** A list of all financial events that have modified this trasnfer. */ - fun events(events: JsonField>) = apply { this.events = events } + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** A list of all financial events that have modified this trasnfer. */ + fun addEvent(event: FinancialEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(event) + } + } /** The updated balance of the sending financial account. */ fun fromBalance(fromBalance: List) = fromBalance(JsonField.of(fromBalance)) /** The updated balance of the sending financial account. */ fun fromBalance(fromBalance: JsonField>) = apply { - this.fromBalance = fromBalance + this.fromBalance = fromBalance.map { it.toMutableList() } + } + + /** The updated balance of the sending financial account. */ + fun addFromBalance(fromBalance: Balance) = apply { + this.fromBalance = + (this.fromBalance ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(fromBalance) + } } /** @@ -366,7 +400,21 @@ private constructor( fun toBalance(toBalance: List) = toBalance(JsonField.of(toBalance)) /** The updated balance of the receiving financial account. */ - fun toBalance(toBalance: JsonField>) = apply { this.toBalance = toBalance } + fun toBalance(toBalance: JsonField>) = apply { + this.toBalance = toBalance.map { it.toMutableList() } + } + + /** The updated balance of the receiving financial account. */ + fun addToBalance(toBalance: Balance) = apply { + this.toBalance = + (this.toBalance ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(toBalance) + } + } /** Date and time when the financial transaction was last updated. UTC time zone. */ fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) @@ -400,13 +448,13 @@ private constructor( created, currency, descriptor, - events.map { it.toImmutable() }, - fromBalance.map { it.toImmutable() }, + (events ?: JsonMissing.of()).map { it.toImmutable() }, + (fromBalance ?: JsonMissing.of()).map { it.toImmutable() }, pendingAmount, result, settledAmount, status, - toBalance.map { it.toImmutable() }, + (toBalance ?: JsonMissing.of()).map { it.toImmutable() }, updated, additionalProperties.toImmutable(), ) @@ -507,24 +555,24 @@ private constructor( fun type(): FinancialEventType? = type.getNullable("type") /** Globally unique identifier. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** * Amount of the financial event that has been settled in the currency's smallest unit * (e.g., cents). */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** Date and time when the financial event occurred. UTC time zone. */ - @JsonProperty("created") @ExcludeMissing fun _created() = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** * APPROVED financial events were successful while DECLINED financial events were declined * by user, Lithic, or the network. */ - @JsonProperty("result") @ExcludeMissing fun _result() = result + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransferCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransferCreateParams.kt index 0af22e26..5c61783b 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransferCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransferCreateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.http.Headers @@ -50,12 +52,39 @@ constructor( /** Optional descriptor for the transfer. */ fun memo(): String? = body.memo() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This should + * always be a positive value. + */ + fun _amount(): JsonField = body._amount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Globally unique identifier for the financial account or card that will send the funds. + * Accepted type dependent on the program's use case. + */ + fun _from(): JsonField = body._from() + + /** + * Globally unique identifier for the financial account or card that will receive the funds. + * Accepted type dependent on the program's use case. + */ + fun _to(): JsonField = body._to() + + /** + * Customer-provided token that will serve as an idempotency token. This token will become the + * transaction token. + */ + fun _token(): JsonField = body._token() + + /** Optional descriptor for the transfer. */ + fun _memo(): JsonField = body._memo() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + internal fun getBody(): TransferCreateBody = body internal fun getHeaders(): Headers = additionalHeaders @@ -66,11 +95,19 @@ constructor( class TransferCreateBody @JsonCreator internal constructor( - @JsonProperty("amount") private val amount: Long, - @JsonProperty("from") private val from: String, - @JsonProperty("to") private val to: String, - @JsonProperty("token") private val token: String?, - @JsonProperty("memo") private val memo: String?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("from") + @ExcludeMissing + private val from: JsonField = JsonMissing.of(), + @JsonProperty("to") @ExcludeMissing private val to: JsonField = JsonMissing.of(), + @JsonProperty("token") + @ExcludeMissing + private val token: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -79,33 +116,73 @@ constructor( * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This * should always be a positive value. */ - @JsonProperty("amount") fun amount(): Long = amount + fun amount(): Long = amount.getRequired("amount") /** * Globally unique identifier for the financial account or card that will send the funds. * Accepted type dependent on the program's use case. */ - @JsonProperty("from") fun from(): String = from + fun from(): String = from.getRequired("from") /** * Globally unique identifier for the financial account or card that will receive the funds. * Accepted type dependent on the program's use case. */ - @JsonProperty("to") fun to(): String = to + fun to(): String = to.getRequired("to") /** * Customer-provided token that will serve as an idempotency token. This token will become * the transaction token. */ - @JsonProperty("token") fun token(): String? = token + fun token(): String? = token.getNullable("token") /** Optional descriptor for the transfer. */ - @JsonProperty("memo") fun memo(): String? = memo + fun memo(): String? = memo.getNullable("memo") + + /** + * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This + * should always be a positive value. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Globally unique identifier for the financial account or card that will send the funds. + * Accepted type dependent on the program's use case. + */ + @JsonProperty("from") @ExcludeMissing fun _from(): JsonField = from + + /** + * Globally unique identifier for the financial account or card that will receive the funds. + * Accepted type dependent on the program's use case. + */ + @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to + + /** + * Customer-provided token that will serve as an idempotency token. This token will become + * the transaction token. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** Optional descriptor for the transfer. */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TransferCreateBody = apply { + if (!validated) { + amount() + from() + to() + token() + memo() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -115,11 +192,11 @@ constructor( class Builder { - private var amount: Long? = null - private var from: String? = null - private var to: String? = null - private var token: String? = null - private var memo: String? = null + private var amount: JsonField? = null + private var from: JsonField? = null + private var to: JsonField? = null + private var token: JsonField = JsonMissing.of() + private var memo: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(transferCreateBody: TransferCreateBody) = apply { @@ -135,28 +212,55 @@ constructor( * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This * should always be a positive value. */ - fun amount(amount: Long) = apply { this.amount = amount } + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This + * should always be a positive value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } /** * Globally unique identifier for the financial account or card that will send the * funds. Accepted type dependent on the program's use case. */ - fun from(from: String) = apply { this.from = from } + fun from(from: String) = from(JsonField.of(from)) + + /** + * Globally unique identifier for the financial account or card that will send the + * funds. Accepted type dependent on the program's use case. + */ + fun from(from: JsonField) = apply { this.from = from } + + /** + * Globally unique identifier for the financial account or card that will receive the + * funds. Accepted type dependent on the program's use case. + */ + fun to(to: String) = to(JsonField.of(to)) /** * Globally unique identifier for the financial account or card that will receive the * funds. Accepted type dependent on the program's use case. */ - fun to(to: String) = apply { this.to = to } + fun to(to: JsonField) = apply { this.to = to } /** * Customer-provided token that will serve as an idempotency token. This token will * become the transaction token. */ - fun token(token: String?) = apply { this.token = token } + fun token(token: String) = token(JsonField.of(token)) + + /** + * Customer-provided token that will serve as an idempotency token. This token will + * become the transaction token. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Optional descriptor for the transfer. */ + fun memo(memo: String) = memo(JsonField.of(memo)) /** Optional descriptor for the transfer. */ - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: JsonField) = apply { this.memo = memo } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -232,26 +336,72 @@ constructor( */ fun amount(amount: Long) = apply { body.amount(amount) } + /** + * Amount to be transferred in the currency’s smallest unit (e.g., cents for USD). This + * should always be a positive value. + */ + fun amount(amount: JsonField) = apply { body.amount(amount) } + /** * Globally unique identifier for the financial account or card that will send the funds. * Accepted type dependent on the program's use case. */ fun from(from: String) = apply { body.from(from) } + /** + * Globally unique identifier for the financial account or card that will send the funds. + * Accepted type dependent on the program's use case. + */ + fun from(from: JsonField) = apply { body.from(from) } + /** * Globally unique identifier for the financial account or card that will receive the funds. * Accepted type dependent on the program's use case. */ fun to(to: String) = apply { body.to(to) } + /** + * Globally unique identifier for the financial account or card that will receive the funds. + * Accepted type dependent on the program's use case. + */ + fun to(to: JsonField) = apply { body.to(to) } + /** * Customer-provided token that will serve as an idempotency token. This token will become * the transaction token. */ - fun token(token: String?) = apply { body.token(token) } + fun token(token: String) = apply { body.token(token) } + + /** + * Customer-provided token that will serve as an idempotency token. This token will become + * the transaction token. + */ + fun token(token: JsonField) = apply { body.token(token) } + + /** Optional descriptor for the transfer. */ + fun memo(memo: String) = apply { body.memo(memo) } /** Optional descriptor for the transfer. */ - fun memo(memo: String?) = apply { body.memo(memo) } + fun memo(memo: JsonField) = apply { body.memo(memo) } + + 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() @@ -351,25 +501,6 @@ constructor( additionalQueryParams.removeAll(keys) } - 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 build(): TransferCreateParams = TransferCreateParams( body.build(), diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2ApplyResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2ApplyResponse.kt index 667ecab5..2569ee6d 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2ApplyResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2ApplyResponse.kt @@ -89,34 +89,44 @@ private constructor( fun excludedCardTokens(): List? = excludedCardTokens.getNullable("excluded_card_tokens") /** Auth Rule Token */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Account tokens to which the Auth Rule applies. */ - @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + @JsonProperty("account_tokens") + @ExcludeMissing + fun _accountTokens(): JsonField> = accountTokens /** Card tokens to which the Auth Rule applies. */ - @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + @JsonProperty("card_tokens") + @ExcludeMissing + fun _cardTokens(): JsonField> = cardTokens - @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + @JsonProperty("current_version") + @ExcludeMissing + fun _currentVersion(): JsonField = currentVersion - @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + @JsonProperty("draft_version") + @ExcludeMissing + fun _draftVersion(): JsonField = draftVersion /** Auth Rule Name */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Whether the Auth Rule applies to all authorizations on the card program. */ - @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + @JsonProperty("program_level") + @ExcludeMissing + fun _programLevel(): JsonField = programLevel /** The state of the Auth Rule */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** The type of Auth Rule */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** Card tokens to which the Auth Rule does not apply. */ @JsonProperty("excluded_card_tokens") @ExcludeMissing - fun _excludedCardTokens() = excludedCardTokens + fun _excludedCardTokens(): JsonField> = excludedCardTokens @JsonAnyGetter @ExcludeMissing @@ -149,29 +159,29 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountTokens: JsonField> = JsonMissing.of() - private var cardTokens: JsonField> = JsonMissing.of() - private var currentVersion: JsonField = JsonMissing.of() - private var draftVersion: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var programLevel: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var excludedCardTokens: JsonField> = JsonMissing.of() + private var token: JsonField? = null + private var accountTokens: JsonField>? = null + private var cardTokens: JsonField>? = null + private var currentVersion: JsonField? = null + private var draftVersion: JsonField? = null + private var name: JsonField? = null + private var programLevel: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var excludedCardTokens: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(v2ApplyResponse: V2ApplyResponse) = apply { token = v2ApplyResponse.token - accountTokens = v2ApplyResponse.accountTokens - cardTokens = v2ApplyResponse.cardTokens + accountTokens = v2ApplyResponse.accountTokens.map { it.toMutableList() } + cardTokens = v2ApplyResponse.cardTokens.map { it.toMutableList() } currentVersion = v2ApplyResponse.currentVersion draftVersion = v2ApplyResponse.draftVersion name = v2ApplyResponse.name programLevel = v2ApplyResponse.programLevel state = v2ApplyResponse.state type = v2ApplyResponse.type - excludedCardTokens = v2ApplyResponse.excludedCardTokens + excludedCardTokens = v2ApplyResponse.excludedCardTokens.map { it.toMutableList() } additionalProperties = v2ApplyResponse.additionalProperties.toMutableMap() } @@ -186,30 +196,57 @@ private constructor( /** Account tokens to which the Auth Rule applies. */ fun accountTokens(accountTokens: JsonField>) = apply { - this.accountTokens = accountTokens + this.accountTokens = accountTokens.map { it.toMutableList() } + } + + /** Account tokens to which the Auth Rule applies. */ + fun addAccountToken(accountToken: String) = apply { + accountTokens = + (accountTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(accountToken) + } } /** Card tokens to which the Auth Rule applies. */ fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + fun cardTokens(cardTokens: JsonField>) = apply { + this.cardTokens = cardTokens.map { it.toMutableList() } + } - fun currentVersion(currentVersion: CurrentVersion) = - currentVersion(JsonField.of(currentVersion)) + /** Card tokens to which the Auth Rule applies. */ + fun addCardToken(cardToken: String) = apply { + cardTokens = + (cardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(cardToken) + } + } + + fun currentVersion(currentVersion: CurrentVersion?) = + currentVersion(JsonField.ofNullable(currentVersion)) fun currentVersion(currentVersion: JsonField) = apply { this.currentVersion = currentVersion } - fun draftVersion(draftVersion: DraftVersion) = draftVersion(JsonField.of(draftVersion)) + fun draftVersion(draftVersion: DraftVersion?) = + draftVersion(JsonField.ofNullable(draftVersion)) fun draftVersion(draftVersion: JsonField) = apply { this.draftVersion = draftVersion } /** Auth Rule Name */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) /** Auth Rule Name */ fun name(name: JsonField) = apply { this.name = name } @@ -240,7 +277,19 @@ private constructor( /** Card tokens to which the Auth Rule does not apply. */ fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { - this.excludedCardTokens = excludedCardTokens + this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } + } + + /** Card tokens to which the Auth Rule does not apply. */ + fun addExcludedCardToken(excludedCardToken: String) = apply { + excludedCardTokens = + (excludedCardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(excludedCardToken) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -264,16 +313,18 @@ private constructor( fun build(): V2ApplyResponse = V2ApplyResponse( - token, - accountTokens.map { it.toImmutable() }, - cardTokens.map { it.toImmutable() }, - currentVersion, - draftVersion, - name, - programLevel, - state, - type, - excludedCardTokens.map { it.toImmutable() }, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountTokens) { "`accountTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(cardTokens) { "`cardTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(currentVersion) { "`currentVersion` is required but was not set" }, + checkNotNull(draftVersion) { "`draftVersion` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(programLevel) { "`programLevel` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -299,10 +350,12 @@ private constructor( fun version(): Long = version.getRequired("version") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -327,8 +380,8 @@ private constructor( class Builder { - private var parameters: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var parameters: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(currentVersion: CurrentVersion) = apply { @@ -345,6 +398,12 @@ private constructor( this.parameters = parameters } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) + + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + /** * The version of the rule, this is incremented whenever the rule's parameters change. */ @@ -376,8 +435,8 @@ private constructor( fun build(): CurrentVersion = CurrentVersion( - parameters, - version, + checkNotNull(parameters) { "`parameters` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -526,7 +585,9 @@ private constructor( fun conditions(): List = conditions.getRequired("conditions") - @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing @@ -550,12 +611,13 @@ private constructor( class Builder { - private var conditions: JsonField> = JsonMissing.of() + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } @@ -564,7 +626,18 @@ private constructor( conditions(JsonField.of(conditions)) fun conditions(conditions: JsonField>) = apply { - this.conditions = conditions + this.conditions = conditions.map { it.toMutableList() } + } + + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -591,7 +664,8 @@ private constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( - conditions.map { it.toImmutable() }, + checkNotNull(conditions) { "`conditions` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -693,13 +767,17 @@ private constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -832,6 +910,15 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun value(value: JsonField) = apply { this.value = value } + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) + + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun value(long: Long) = value(Value.ofLong(long)) + + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1271,10 +1358,12 @@ private constructor( fun version(): Long = version.getRequired("version") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -1299,8 +1388,8 @@ private constructor( class Builder { - private var parameters: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var parameters: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(draftVersion: DraftVersion) = apply { @@ -1317,6 +1406,12 @@ private constructor( this.parameters = parameters } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) + + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + /** * The version of the rule, this is incremented whenever the rule's parameters change. */ @@ -1348,8 +1443,8 @@ private constructor( fun build(): DraftVersion = DraftVersion( - parameters, - version, + checkNotNull(parameters) { "`parameters` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1498,7 +1593,9 @@ private constructor( fun conditions(): List = conditions.getRequired("conditions") - @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing @@ -1522,12 +1619,13 @@ private constructor( class Builder { - private var conditions: JsonField> = JsonMissing.of() + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } @@ -1536,7 +1634,18 @@ private constructor( conditions(JsonField.of(conditions)) fun conditions(conditions: JsonField>) = apply { - this.conditions = conditions + this.conditions = conditions.map { it.toMutableList() } + } + + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -1563,7 +1672,8 @@ private constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( - conditions.map { it.toImmutable() }, + checkNotNull(conditions) { "`conditions` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -1665,13 +1775,17 @@ private constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -1804,6 +1918,15 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun value(value: JsonField) = apply { this.value = value } + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) + + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun value(long: Long) = value(Value.ofLong(long)) + + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2CreateResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2CreateResponse.kt index a1ea898a..dcb591f0 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2CreateResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2CreateResponse.kt @@ -89,34 +89,44 @@ private constructor( fun excludedCardTokens(): List? = excludedCardTokens.getNullable("excluded_card_tokens") /** Auth Rule Token */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Account tokens to which the Auth Rule applies. */ - @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + @JsonProperty("account_tokens") + @ExcludeMissing + fun _accountTokens(): JsonField> = accountTokens /** Card tokens to which the Auth Rule applies. */ - @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + @JsonProperty("card_tokens") + @ExcludeMissing + fun _cardTokens(): JsonField> = cardTokens - @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + @JsonProperty("current_version") + @ExcludeMissing + fun _currentVersion(): JsonField = currentVersion - @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + @JsonProperty("draft_version") + @ExcludeMissing + fun _draftVersion(): JsonField = draftVersion /** Auth Rule Name */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Whether the Auth Rule applies to all authorizations on the card program. */ - @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + @JsonProperty("program_level") + @ExcludeMissing + fun _programLevel(): JsonField = programLevel /** The state of the Auth Rule */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** The type of Auth Rule */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** Card tokens to which the Auth Rule does not apply. */ @JsonProperty("excluded_card_tokens") @ExcludeMissing - fun _excludedCardTokens() = excludedCardTokens + fun _excludedCardTokens(): JsonField> = excludedCardTokens @JsonAnyGetter @ExcludeMissing @@ -149,29 +159,29 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountTokens: JsonField> = JsonMissing.of() - private var cardTokens: JsonField> = JsonMissing.of() - private var currentVersion: JsonField = JsonMissing.of() - private var draftVersion: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var programLevel: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var excludedCardTokens: JsonField> = JsonMissing.of() + private var token: JsonField? = null + private var accountTokens: JsonField>? = null + private var cardTokens: JsonField>? = null + private var currentVersion: JsonField? = null + private var draftVersion: JsonField? = null + private var name: JsonField? = null + private var programLevel: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var excludedCardTokens: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(v2CreateResponse: V2CreateResponse) = apply { token = v2CreateResponse.token - accountTokens = v2CreateResponse.accountTokens - cardTokens = v2CreateResponse.cardTokens + accountTokens = v2CreateResponse.accountTokens.map { it.toMutableList() } + cardTokens = v2CreateResponse.cardTokens.map { it.toMutableList() } currentVersion = v2CreateResponse.currentVersion draftVersion = v2CreateResponse.draftVersion name = v2CreateResponse.name programLevel = v2CreateResponse.programLevel state = v2CreateResponse.state type = v2CreateResponse.type - excludedCardTokens = v2CreateResponse.excludedCardTokens + excludedCardTokens = v2CreateResponse.excludedCardTokens.map { it.toMutableList() } additionalProperties = v2CreateResponse.additionalProperties.toMutableMap() } @@ -186,30 +196,57 @@ private constructor( /** Account tokens to which the Auth Rule applies. */ fun accountTokens(accountTokens: JsonField>) = apply { - this.accountTokens = accountTokens + this.accountTokens = accountTokens.map { it.toMutableList() } + } + + /** Account tokens to which the Auth Rule applies. */ + fun addAccountToken(accountToken: String) = apply { + accountTokens = + (accountTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(accountToken) + } } /** Card tokens to which the Auth Rule applies. */ fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + fun cardTokens(cardTokens: JsonField>) = apply { + this.cardTokens = cardTokens.map { it.toMutableList() } + } - fun currentVersion(currentVersion: CurrentVersion) = - currentVersion(JsonField.of(currentVersion)) + /** Card tokens to which the Auth Rule applies. */ + fun addCardToken(cardToken: String) = apply { + cardTokens = + (cardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(cardToken) + } + } + + fun currentVersion(currentVersion: CurrentVersion?) = + currentVersion(JsonField.ofNullable(currentVersion)) fun currentVersion(currentVersion: JsonField) = apply { this.currentVersion = currentVersion } - fun draftVersion(draftVersion: DraftVersion) = draftVersion(JsonField.of(draftVersion)) + fun draftVersion(draftVersion: DraftVersion?) = + draftVersion(JsonField.ofNullable(draftVersion)) fun draftVersion(draftVersion: JsonField) = apply { this.draftVersion = draftVersion } /** Auth Rule Name */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) /** Auth Rule Name */ fun name(name: JsonField) = apply { this.name = name } @@ -240,7 +277,19 @@ private constructor( /** Card tokens to which the Auth Rule does not apply. */ fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { - this.excludedCardTokens = excludedCardTokens + this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } + } + + /** Card tokens to which the Auth Rule does not apply. */ + fun addExcludedCardToken(excludedCardToken: String) = apply { + excludedCardTokens = + (excludedCardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(excludedCardToken) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -264,16 +313,18 @@ private constructor( fun build(): V2CreateResponse = V2CreateResponse( - token, - accountTokens.map { it.toImmutable() }, - cardTokens.map { it.toImmutable() }, - currentVersion, - draftVersion, - name, - programLevel, - state, - type, - excludedCardTokens.map { it.toImmutable() }, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountTokens) { "`accountTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(cardTokens) { "`cardTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(currentVersion) { "`currentVersion` is required but was not set" }, + checkNotNull(draftVersion) { "`draftVersion` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(programLevel) { "`programLevel` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -299,10 +350,12 @@ private constructor( fun version(): Long = version.getRequired("version") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -327,8 +380,8 @@ private constructor( class Builder { - private var parameters: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var parameters: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(currentVersion: CurrentVersion) = apply { @@ -345,6 +398,12 @@ private constructor( this.parameters = parameters } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) + + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + /** * The version of the rule, this is incremented whenever the rule's parameters change. */ @@ -376,8 +435,8 @@ private constructor( fun build(): CurrentVersion = CurrentVersion( - parameters, - version, + checkNotNull(parameters) { "`parameters` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -526,7 +585,9 @@ private constructor( fun conditions(): List = conditions.getRequired("conditions") - @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing @@ -550,12 +611,13 @@ private constructor( class Builder { - private var conditions: JsonField> = JsonMissing.of() + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } @@ -564,7 +626,18 @@ private constructor( conditions(JsonField.of(conditions)) fun conditions(conditions: JsonField>) = apply { - this.conditions = conditions + this.conditions = conditions.map { it.toMutableList() } + } + + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -591,7 +664,8 @@ private constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( - conditions.map { it.toImmutable() }, + checkNotNull(conditions) { "`conditions` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -693,13 +767,17 @@ private constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -832,6 +910,15 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun value(value: JsonField) = apply { this.value = value } + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) + + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun value(long: Long) = value(Value.ofLong(long)) + + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1271,10 +1358,12 @@ private constructor( fun version(): Long = version.getRequired("version") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -1299,8 +1388,8 @@ private constructor( class Builder { - private var parameters: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var parameters: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(draftVersion: DraftVersion) = apply { @@ -1317,6 +1406,12 @@ private constructor( this.parameters = parameters } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) + + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + /** * The version of the rule, this is incremented whenever the rule's parameters change. */ @@ -1348,8 +1443,8 @@ private constructor( fun build(): DraftVersion = DraftVersion( - parameters, - version, + checkNotNull(parameters) { "`parameters` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1498,7 +1593,9 @@ private constructor( fun conditions(): List = conditions.getRequired("conditions") - @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing @@ -1522,12 +1619,13 @@ private constructor( class Builder { - private var conditions: JsonField> = JsonMissing.of() + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } @@ -1536,7 +1634,18 @@ private constructor( conditions(JsonField.of(conditions)) fun conditions(conditions: JsonField>) = apply { - this.conditions = conditions + this.conditions = conditions.map { it.toMutableList() } + } + + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -1563,7 +1672,8 @@ private constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( - conditions.map { it.toImmutable() }, + checkNotNull(conditions) { "`conditions` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -1665,13 +1775,17 @@ private constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -1804,6 +1918,15 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun value(value: JsonField) = apply { this.value = value } + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) + + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun value(long: Long) = value(Value.ofLong(long)) + + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2DraftResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2DraftResponse.kt index 4b976b8f..2bdb85fd 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2DraftResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2DraftResponse.kt @@ -89,34 +89,44 @@ private constructor( fun excludedCardTokens(): List? = excludedCardTokens.getNullable("excluded_card_tokens") /** Auth Rule Token */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Account tokens to which the Auth Rule applies. */ - @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + @JsonProperty("account_tokens") + @ExcludeMissing + fun _accountTokens(): JsonField> = accountTokens /** Card tokens to which the Auth Rule applies. */ - @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + @JsonProperty("card_tokens") + @ExcludeMissing + fun _cardTokens(): JsonField> = cardTokens - @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + @JsonProperty("current_version") + @ExcludeMissing + fun _currentVersion(): JsonField = currentVersion - @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + @JsonProperty("draft_version") + @ExcludeMissing + fun _draftVersion(): JsonField = draftVersion /** Auth Rule Name */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Whether the Auth Rule applies to all authorizations on the card program. */ - @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + @JsonProperty("program_level") + @ExcludeMissing + fun _programLevel(): JsonField = programLevel /** The state of the Auth Rule */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** The type of Auth Rule */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** Card tokens to which the Auth Rule does not apply. */ @JsonProperty("excluded_card_tokens") @ExcludeMissing - fun _excludedCardTokens() = excludedCardTokens + fun _excludedCardTokens(): JsonField> = excludedCardTokens @JsonAnyGetter @ExcludeMissing @@ -149,29 +159,29 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountTokens: JsonField> = JsonMissing.of() - private var cardTokens: JsonField> = JsonMissing.of() - private var currentVersion: JsonField = JsonMissing.of() - private var draftVersion: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var programLevel: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var excludedCardTokens: JsonField> = JsonMissing.of() + private var token: JsonField? = null + private var accountTokens: JsonField>? = null + private var cardTokens: JsonField>? = null + private var currentVersion: JsonField? = null + private var draftVersion: JsonField? = null + private var name: JsonField? = null + private var programLevel: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var excludedCardTokens: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(v2DraftResponse: V2DraftResponse) = apply { token = v2DraftResponse.token - accountTokens = v2DraftResponse.accountTokens - cardTokens = v2DraftResponse.cardTokens + accountTokens = v2DraftResponse.accountTokens.map { it.toMutableList() } + cardTokens = v2DraftResponse.cardTokens.map { it.toMutableList() } currentVersion = v2DraftResponse.currentVersion draftVersion = v2DraftResponse.draftVersion name = v2DraftResponse.name programLevel = v2DraftResponse.programLevel state = v2DraftResponse.state type = v2DraftResponse.type - excludedCardTokens = v2DraftResponse.excludedCardTokens + excludedCardTokens = v2DraftResponse.excludedCardTokens.map { it.toMutableList() } additionalProperties = v2DraftResponse.additionalProperties.toMutableMap() } @@ -186,30 +196,57 @@ private constructor( /** Account tokens to which the Auth Rule applies. */ fun accountTokens(accountTokens: JsonField>) = apply { - this.accountTokens = accountTokens + this.accountTokens = accountTokens.map { it.toMutableList() } + } + + /** Account tokens to which the Auth Rule applies. */ + fun addAccountToken(accountToken: String) = apply { + accountTokens = + (accountTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(accountToken) + } } /** Card tokens to which the Auth Rule applies. */ fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + fun cardTokens(cardTokens: JsonField>) = apply { + this.cardTokens = cardTokens.map { it.toMutableList() } + } - fun currentVersion(currentVersion: CurrentVersion) = - currentVersion(JsonField.of(currentVersion)) + /** Card tokens to which the Auth Rule applies. */ + fun addCardToken(cardToken: String) = apply { + cardTokens = + (cardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(cardToken) + } + } + + fun currentVersion(currentVersion: CurrentVersion?) = + currentVersion(JsonField.ofNullable(currentVersion)) fun currentVersion(currentVersion: JsonField) = apply { this.currentVersion = currentVersion } - fun draftVersion(draftVersion: DraftVersion) = draftVersion(JsonField.of(draftVersion)) + fun draftVersion(draftVersion: DraftVersion?) = + draftVersion(JsonField.ofNullable(draftVersion)) fun draftVersion(draftVersion: JsonField) = apply { this.draftVersion = draftVersion } /** Auth Rule Name */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) /** Auth Rule Name */ fun name(name: JsonField) = apply { this.name = name } @@ -240,7 +277,19 @@ private constructor( /** Card tokens to which the Auth Rule does not apply. */ fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { - this.excludedCardTokens = excludedCardTokens + this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } + } + + /** Card tokens to which the Auth Rule does not apply. */ + fun addExcludedCardToken(excludedCardToken: String) = apply { + excludedCardTokens = + (excludedCardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(excludedCardToken) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -264,16 +313,18 @@ private constructor( fun build(): V2DraftResponse = V2DraftResponse( - token, - accountTokens.map { it.toImmutable() }, - cardTokens.map { it.toImmutable() }, - currentVersion, - draftVersion, - name, - programLevel, - state, - type, - excludedCardTokens.map { it.toImmutable() }, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountTokens) { "`accountTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(cardTokens) { "`cardTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(currentVersion) { "`currentVersion` is required but was not set" }, + checkNotNull(draftVersion) { "`draftVersion` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(programLevel) { "`programLevel` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -299,10 +350,12 @@ private constructor( fun version(): Long = version.getRequired("version") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -327,8 +380,8 @@ private constructor( class Builder { - private var parameters: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var parameters: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(currentVersion: CurrentVersion) = apply { @@ -345,6 +398,12 @@ private constructor( this.parameters = parameters } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) + + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + /** * The version of the rule, this is incremented whenever the rule's parameters change. */ @@ -376,8 +435,8 @@ private constructor( fun build(): CurrentVersion = CurrentVersion( - parameters, - version, + checkNotNull(parameters) { "`parameters` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -526,7 +585,9 @@ private constructor( fun conditions(): List = conditions.getRequired("conditions") - @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing @@ -550,12 +611,13 @@ private constructor( class Builder { - private var conditions: JsonField> = JsonMissing.of() + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } @@ -564,7 +626,18 @@ private constructor( conditions(JsonField.of(conditions)) fun conditions(conditions: JsonField>) = apply { - this.conditions = conditions + this.conditions = conditions.map { it.toMutableList() } + } + + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -591,7 +664,8 @@ private constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( - conditions.map { it.toImmutable() }, + checkNotNull(conditions) { "`conditions` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -693,13 +767,17 @@ private constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -832,6 +910,15 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun value(value: JsonField) = apply { this.value = value } + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) + + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun value(long: Long) = value(Value.ofLong(long)) + + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1271,10 +1358,12 @@ private constructor( fun version(): Long = version.getRequired("version") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -1299,8 +1388,8 @@ private constructor( class Builder { - private var parameters: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var parameters: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(draftVersion: DraftVersion) = apply { @@ -1317,6 +1406,12 @@ private constructor( this.parameters = parameters } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) + + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + /** * The version of the rule, this is incremented whenever the rule's parameters change. */ @@ -1348,8 +1443,8 @@ private constructor( fun build(): DraftVersion = DraftVersion( - parameters, - version, + checkNotNull(parameters) { "`parameters` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1498,7 +1593,9 @@ private constructor( fun conditions(): List = conditions.getRequired("conditions") - @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing @@ -1522,12 +1619,13 @@ private constructor( class Builder { - private var conditions: JsonField> = JsonMissing.of() + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } @@ -1536,7 +1634,18 @@ private constructor( conditions(JsonField.of(conditions)) fun conditions(conditions: JsonField>) = apply { - this.conditions = conditions + this.conditions = conditions.map { it.toMutableList() } + } + + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -1563,7 +1672,8 @@ private constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( - conditions.map { it.toImmutable() }, + checkNotNull(conditions) { "`conditions` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -1665,13 +1775,17 @@ private constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -1804,6 +1918,15 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun value(value: JsonField) = apply { this.value = value } + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) + + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun value(long: Long) = value(Value.ofLong(long)) + + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2ListResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2ListResponse.kt index 9457a6b8..a9d82199 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2ListResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2ListResponse.kt @@ -89,34 +89,44 @@ private constructor( fun excludedCardTokens(): List? = excludedCardTokens.getNullable("excluded_card_tokens") /** Auth Rule Token */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Account tokens to which the Auth Rule applies. */ - @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + @JsonProperty("account_tokens") + @ExcludeMissing + fun _accountTokens(): JsonField> = accountTokens /** Card tokens to which the Auth Rule applies. */ - @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + @JsonProperty("card_tokens") + @ExcludeMissing + fun _cardTokens(): JsonField> = cardTokens - @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + @JsonProperty("current_version") + @ExcludeMissing + fun _currentVersion(): JsonField = currentVersion - @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + @JsonProperty("draft_version") + @ExcludeMissing + fun _draftVersion(): JsonField = draftVersion /** Auth Rule Name */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Whether the Auth Rule applies to all authorizations on the card program. */ - @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + @JsonProperty("program_level") + @ExcludeMissing + fun _programLevel(): JsonField = programLevel /** The state of the Auth Rule */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** The type of Auth Rule */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** Card tokens to which the Auth Rule does not apply. */ @JsonProperty("excluded_card_tokens") @ExcludeMissing - fun _excludedCardTokens() = excludedCardTokens + fun _excludedCardTokens(): JsonField> = excludedCardTokens @JsonAnyGetter @ExcludeMissing @@ -149,29 +159,29 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountTokens: JsonField> = JsonMissing.of() - private var cardTokens: JsonField> = JsonMissing.of() - private var currentVersion: JsonField = JsonMissing.of() - private var draftVersion: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var programLevel: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var excludedCardTokens: JsonField> = JsonMissing.of() + private var token: JsonField? = null + private var accountTokens: JsonField>? = null + private var cardTokens: JsonField>? = null + private var currentVersion: JsonField? = null + private var draftVersion: JsonField? = null + private var name: JsonField? = null + private var programLevel: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var excludedCardTokens: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(v2ListResponse: V2ListResponse) = apply { token = v2ListResponse.token - accountTokens = v2ListResponse.accountTokens - cardTokens = v2ListResponse.cardTokens + accountTokens = v2ListResponse.accountTokens.map { it.toMutableList() } + cardTokens = v2ListResponse.cardTokens.map { it.toMutableList() } currentVersion = v2ListResponse.currentVersion draftVersion = v2ListResponse.draftVersion name = v2ListResponse.name programLevel = v2ListResponse.programLevel state = v2ListResponse.state type = v2ListResponse.type - excludedCardTokens = v2ListResponse.excludedCardTokens + excludedCardTokens = v2ListResponse.excludedCardTokens.map { it.toMutableList() } additionalProperties = v2ListResponse.additionalProperties.toMutableMap() } @@ -186,30 +196,57 @@ private constructor( /** Account tokens to which the Auth Rule applies. */ fun accountTokens(accountTokens: JsonField>) = apply { - this.accountTokens = accountTokens + this.accountTokens = accountTokens.map { it.toMutableList() } + } + + /** Account tokens to which the Auth Rule applies. */ + fun addAccountToken(accountToken: String) = apply { + accountTokens = + (accountTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(accountToken) + } } /** Card tokens to which the Auth Rule applies. */ fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + fun cardTokens(cardTokens: JsonField>) = apply { + this.cardTokens = cardTokens.map { it.toMutableList() } + } - fun currentVersion(currentVersion: CurrentVersion) = - currentVersion(JsonField.of(currentVersion)) + /** Card tokens to which the Auth Rule applies. */ + fun addCardToken(cardToken: String) = apply { + cardTokens = + (cardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(cardToken) + } + } + + fun currentVersion(currentVersion: CurrentVersion?) = + currentVersion(JsonField.ofNullable(currentVersion)) fun currentVersion(currentVersion: JsonField) = apply { this.currentVersion = currentVersion } - fun draftVersion(draftVersion: DraftVersion) = draftVersion(JsonField.of(draftVersion)) + fun draftVersion(draftVersion: DraftVersion?) = + draftVersion(JsonField.ofNullable(draftVersion)) fun draftVersion(draftVersion: JsonField) = apply { this.draftVersion = draftVersion } /** Auth Rule Name */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) /** Auth Rule Name */ fun name(name: JsonField) = apply { this.name = name } @@ -240,7 +277,19 @@ private constructor( /** Card tokens to which the Auth Rule does not apply. */ fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { - this.excludedCardTokens = excludedCardTokens + this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } + } + + /** Card tokens to which the Auth Rule does not apply. */ + fun addExcludedCardToken(excludedCardToken: String) = apply { + excludedCardTokens = + (excludedCardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(excludedCardToken) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -264,16 +313,18 @@ private constructor( fun build(): V2ListResponse = V2ListResponse( - token, - accountTokens.map { it.toImmutable() }, - cardTokens.map { it.toImmutable() }, - currentVersion, - draftVersion, - name, - programLevel, - state, - type, - excludedCardTokens.map { it.toImmutable() }, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountTokens) { "`accountTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(cardTokens) { "`cardTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(currentVersion) { "`currentVersion` is required but was not set" }, + checkNotNull(draftVersion) { "`draftVersion` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(programLevel) { "`programLevel` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -299,10 +350,12 @@ private constructor( fun version(): Long = version.getRequired("version") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -327,8 +380,8 @@ private constructor( class Builder { - private var parameters: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var parameters: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(currentVersion: CurrentVersion) = apply { @@ -345,6 +398,12 @@ private constructor( this.parameters = parameters } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) + + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + /** * The version of the rule, this is incremented whenever the rule's parameters change. */ @@ -376,8 +435,8 @@ private constructor( fun build(): CurrentVersion = CurrentVersion( - parameters, - version, + checkNotNull(parameters) { "`parameters` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -526,7 +585,9 @@ private constructor( fun conditions(): List = conditions.getRequired("conditions") - @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing @@ -550,12 +611,13 @@ private constructor( class Builder { - private var conditions: JsonField> = JsonMissing.of() + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } @@ -564,7 +626,18 @@ private constructor( conditions(JsonField.of(conditions)) fun conditions(conditions: JsonField>) = apply { - this.conditions = conditions + this.conditions = conditions.map { it.toMutableList() } + } + + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -591,7 +664,8 @@ private constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( - conditions.map { it.toImmutable() }, + checkNotNull(conditions) { "`conditions` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -693,13 +767,17 @@ private constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -832,6 +910,15 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun value(value: JsonField) = apply { this.value = value } + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) + + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun value(long: Long) = value(Value.ofLong(long)) + + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1271,10 +1358,12 @@ private constructor( fun version(): Long = version.getRequired("version") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -1299,8 +1388,8 @@ private constructor( class Builder { - private var parameters: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var parameters: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(draftVersion: DraftVersion) = apply { @@ -1317,6 +1406,12 @@ private constructor( this.parameters = parameters } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) + + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + /** * The version of the rule, this is incremented whenever the rule's parameters change. */ @@ -1348,8 +1443,8 @@ private constructor( fun build(): DraftVersion = DraftVersion( - parameters, - version, + checkNotNull(parameters) { "`parameters` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1498,7 +1593,9 @@ private constructor( fun conditions(): List = conditions.getRequired("conditions") - @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing @@ -1522,12 +1619,13 @@ private constructor( class Builder { - private var conditions: JsonField> = JsonMissing.of() + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } @@ -1536,7 +1634,18 @@ private constructor( conditions(JsonField.of(conditions)) fun conditions(conditions: JsonField>) = apply { - this.conditions = conditions + this.conditions = conditions.map { it.toMutableList() } + } + + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -1563,7 +1672,8 @@ private constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( - conditions.map { it.toImmutable() }, + checkNotNull(conditions) { "`conditions` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -1665,13 +1775,17 @@ private constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -1804,6 +1918,15 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun value(value: JsonField) = apply { this.value = value } + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) + + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun value(long: Long) = value(Value.ofLong(long)) + + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2PromoteResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2PromoteResponse.kt index eccc72a0..0a83dca0 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2PromoteResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2PromoteResponse.kt @@ -89,34 +89,44 @@ private constructor( fun excludedCardTokens(): List? = excludedCardTokens.getNullable("excluded_card_tokens") /** Auth Rule Token */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Account tokens to which the Auth Rule applies. */ - @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + @JsonProperty("account_tokens") + @ExcludeMissing + fun _accountTokens(): JsonField> = accountTokens /** Card tokens to which the Auth Rule applies. */ - @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + @JsonProperty("card_tokens") + @ExcludeMissing + fun _cardTokens(): JsonField> = cardTokens - @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + @JsonProperty("current_version") + @ExcludeMissing + fun _currentVersion(): JsonField = currentVersion - @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + @JsonProperty("draft_version") + @ExcludeMissing + fun _draftVersion(): JsonField = draftVersion /** Auth Rule Name */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Whether the Auth Rule applies to all authorizations on the card program. */ - @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + @JsonProperty("program_level") + @ExcludeMissing + fun _programLevel(): JsonField = programLevel /** The state of the Auth Rule */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** The type of Auth Rule */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** Card tokens to which the Auth Rule does not apply. */ @JsonProperty("excluded_card_tokens") @ExcludeMissing - fun _excludedCardTokens() = excludedCardTokens + fun _excludedCardTokens(): JsonField> = excludedCardTokens @JsonAnyGetter @ExcludeMissing @@ -149,29 +159,29 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountTokens: JsonField> = JsonMissing.of() - private var cardTokens: JsonField> = JsonMissing.of() - private var currentVersion: JsonField = JsonMissing.of() - private var draftVersion: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var programLevel: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var excludedCardTokens: JsonField> = JsonMissing.of() + private var token: JsonField? = null + private var accountTokens: JsonField>? = null + private var cardTokens: JsonField>? = null + private var currentVersion: JsonField? = null + private var draftVersion: JsonField? = null + private var name: JsonField? = null + private var programLevel: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var excludedCardTokens: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(v2PromoteResponse: V2PromoteResponse) = apply { token = v2PromoteResponse.token - accountTokens = v2PromoteResponse.accountTokens - cardTokens = v2PromoteResponse.cardTokens + accountTokens = v2PromoteResponse.accountTokens.map { it.toMutableList() } + cardTokens = v2PromoteResponse.cardTokens.map { it.toMutableList() } currentVersion = v2PromoteResponse.currentVersion draftVersion = v2PromoteResponse.draftVersion name = v2PromoteResponse.name programLevel = v2PromoteResponse.programLevel state = v2PromoteResponse.state type = v2PromoteResponse.type - excludedCardTokens = v2PromoteResponse.excludedCardTokens + excludedCardTokens = v2PromoteResponse.excludedCardTokens.map { it.toMutableList() } additionalProperties = v2PromoteResponse.additionalProperties.toMutableMap() } @@ -186,30 +196,57 @@ private constructor( /** Account tokens to which the Auth Rule applies. */ fun accountTokens(accountTokens: JsonField>) = apply { - this.accountTokens = accountTokens + this.accountTokens = accountTokens.map { it.toMutableList() } + } + + /** Account tokens to which the Auth Rule applies. */ + fun addAccountToken(accountToken: String) = apply { + accountTokens = + (accountTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(accountToken) + } } /** Card tokens to which the Auth Rule applies. */ fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + fun cardTokens(cardTokens: JsonField>) = apply { + this.cardTokens = cardTokens.map { it.toMutableList() } + } - fun currentVersion(currentVersion: CurrentVersion) = - currentVersion(JsonField.of(currentVersion)) + /** Card tokens to which the Auth Rule applies. */ + fun addCardToken(cardToken: String) = apply { + cardTokens = + (cardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(cardToken) + } + } + + fun currentVersion(currentVersion: CurrentVersion?) = + currentVersion(JsonField.ofNullable(currentVersion)) fun currentVersion(currentVersion: JsonField) = apply { this.currentVersion = currentVersion } - fun draftVersion(draftVersion: DraftVersion) = draftVersion(JsonField.of(draftVersion)) + fun draftVersion(draftVersion: DraftVersion?) = + draftVersion(JsonField.ofNullable(draftVersion)) fun draftVersion(draftVersion: JsonField) = apply { this.draftVersion = draftVersion } /** Auth Rule Name */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) /** Auth Rule Name */ fun name(name: JsonField) = apply { this.name = name } @@ -240,7 +277,19 @@ private constructor( /** Card tokens to which the Auth Rule does not apply. */ fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { - this.excludedCardTokens = excludedCardTokens + this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } + } + + /** Card tokens to which the Auth Rule does not apply. */ + fun addExcludedCardToken(excludedCardToken: String) = apply { + excludedCardTokens = + (excludedCardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(excludedCardToken) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -264,16 +313,18 @@ private constructor( fun build(): V2PromoteResponse = V2PromoteResponse( - token, - accountTokens.map { it.toImmutable() }, - cardTokens.map { it.toImmutable() }, - currentVersion, - draftVersion, - name, - programLevel, - state, - type, - excludedCardTokens.map { it.toImmutable() }, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountTokens) { "`accountTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(cardTokens) { "`cardTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(currentVersion) { "`currentVersion` is required but was not set" }, + checkNotNull(draftVersion) { "`draftVersion` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(programLevel) { "`programLevel` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -299,10 +350,12 @@ private constructor( fun version(): Long = version.getRequired("version") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -327,8 +380,8 @@ private constructor( class Builder { - private var parameters: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var parameters: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(currentVersion: CurrentVersion) = apply { @@ -345,6 +398,12 @@ private constructor( this.parameters = parameters } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) + + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + /** * The version of the rule, this is incremented whenever the rule's parameters change. */ @@ -376,8 +435,8 @@ private constructor( fun build(): CurrentVersion = CurrentVersion( - parameters, - version, + checkNotNull(parameters) { "`parameters` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -526,7 +585,9 @@ private constructor( fun conditions(): List = conditions.getRequired("conditions") - @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing @@ -550,12 +611,13 @@ private constructor( class Builder { - private var conditions: JsonField> = JsonMissing.of() + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } @@ -564,7 +626,18 @@ private constructor( conditions(JsonField.of(conditions)) fun conditions(conditions: JsonField>) = apply { - this.conditions = conditions + this.conditions = conditions.map { it.toMutableList() } + } + + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -591,7 +664,8 @@ private constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( - conditions.map { it.toImmutable() }, + checkNotNull(conditions) { "`conditions` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -693,13 +767,17 @@ private constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -832,6 +910,15 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun value(value: JsonField) = apply { this.value = value } + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) + + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun value(long: Long) = value(Value.ofLong(long)) + + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1271,10 +1358,12 @@ private constructor( fun version(): Long = version.getRequired("version") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -1299,8 +1388,8 @@ private constructor( class Builder { - private var parameters: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var parameters: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(draftVersion: DraftVersion) = apply { @@ -1317,6 +1406,12 @@ private constructor( this.parameters = parameters } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) + + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + /** * The version of the rule, this is incremented whenever the rule's parameters change. */ @@ -1348,8 +1443,8 @@ private constructor( fun build(): DraftVersion = DraftVersion( - parameters, - version, + checkNotNull(parameters) { "`parameters` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1498,7 +1593,9 @@ private constructor( fun conditions(): List = conditions.getRequired("conditions") - @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing @@ -1522,12 +1619,13 @@ private constructor( class Builder { - private var conditions: JsonField> = JsonMissing.of() + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } @@ -1536,7 +1634,18 @@ private constructor( conditions(JsonField.of(conditions)) fun conditions(conditions: JsonField>) = apply { - this.conditions = conditions + this.conditions = conditions.map { it.toMutableList() } + } + + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -1563,7 +1672,8 @@ private constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( - conditions.map { it.toImmutable() }, + checkNotNull(conditions) { "`conditions` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -1665,13 +1775,17 @@ private constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -1804,6 +1918,15 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun value(value: JsonField) = apply { this.value = value } + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) + + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun value(long: Long) = value(Value.ofLong(long)) + + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2ReportResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2ReportResponse.kt index 21b02c60..74f91c09 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2ReportResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2ReportResponse.kt @@ -27,7 +27,9 @@ private constructor( fun reportToken(): String? = reportToken.getNullable("report_token") - @JsonProperty("report_token") @ExcludeMissing fun _reportToken() = reportToken + @JsonProperty("report_token") + @ExcludeMissing + fun _reportToken(): JsonField = reportToken @JsonAnyGetter @ExcludeMissing diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2RetrieveResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2RetrieveResponse.kt index 850bd81a..ccb82dac 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2RetrieveResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2RetrieveResponse.kt @@ -89,34 +89,44 @@ private constructor( fun excludedCardTokens(): List? = excludedCardTokens.getNullable("excluded_card_tokens") /** Auth Rule Token */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Account tokens to which the Auth Rule applies. */ - @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + @JsonProperty("account_tokens") + @ExcludeMissing + fun _accountTokens(): JsonField> = accountTokens /** Card tokens to which the Auth Rule applies. */ - @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + @JsonProperty("card_tokens") + @ExcludeMissing + fun _cardTokens(): JsonField> = cardTokens - @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + @JsonProperty("current_version") + @ExcludeMissing + fun _currentVersion(): JsonField = currentVersion - @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + @JsonProperty("draft_version") + @ExcludeMissing + fun _draftVersion(): JsonField = draftVersion /** Auth Rule Name */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Whether the Auth Rule applies to all authorizations on the card program. */ - @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + @JsonProperty("program_level") + @ExcludeMissing + fun _programLevel(): JsonField = programLevel /** The state of the Auth Rule */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** The type of Auth Rule */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** Card tokens to which the Auth Rule does not apply. */ @JsonProperty("excluded_card_tokens") @ExcludeMissing - fun _excludedCardTokens() = excludedCardTokens + fun _excludedCardTokens(): JsonField> = excludedCardTokens @JsonAnyGetter @ExcludeMissing @@ -149,29 +159,29 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountTokens: JsonField> = JsonMissing.of() - private var cardTokens: JsonField> = JsonMissing.of() - private var currentVersion: JsonField = JsonMissing.of() - private var draftVersion: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var programLevel: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var excludedCardTokens: JsonField> = JsonMissing.of() + private var token: JsonField? = null + private var accountTokens: JsonField>? = null + private var cardTokens: JsonField>? = null + private var currentVersion: JsonField? = null + private var draftVersion: JsonField? = null + private var name: JsonField? = null + private var programLevel: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var excludedCardTokens: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(v2RetrieveResponse: V2RetrieveResponse) = apply { token = v2RetrieveResponse.token - accountTokens = v2RetrieveResponse.accountTokens - cardTokens = v2RetrieveResponse.cardTokens + accountTokens = v2RetrieveResponse.accountTokens.map { it.toMutableList() } + cardTokens = v2RetrieveResponse.cardTokens.map { it.toMutableList() } currentVersion = v2RetrieveResponse.currentVersion draftVersion = v2RetrieveResponse.draftVersion name = v2RetrieveResponse.name programLevel = v2RetrieveResponse.programLevel state = v2RetrieveResponse.state type = v2RetrieveResponse.type - excludedCardTokens = v2RetrieveResponse.excludedCardTokens + excludedCardTokens = v2RetrieveResponse.excludedCardTokens.map { it.toMutableList() } additionalProperties = v2RetrieveResponse.additionalProperties.toMutableMap() } @@ -186,30 +196,57 @@ private constructor( /** Account tokens to which the Auth Rule applies. */ fun accountTokens(accountTokens: JsonField>) = apply { - this.accountTokens = accountTokens + this.accountTokens = accountTokens.map { it.toMutableList() } + } + + /** Account tokens to which the Auth Rule applies. */ + fun addAccountToken(accountToken: String) = apply { + accountTokens = + (accountTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(accountToken) + } } /** Card tokens to which the Auth Rule applies. */ fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + fun cardTokens(cardTokens: JsonField>) = apply { + this.cardTokens = cardTokens.map { it.toMutableList() } + } - fun currentVersion(currentVersion: CurrentVersion) = - currentVersion(JsonField.of(currentVersion)) + /** Card tokens to which the Auth Rule applies. */ + fun addCardToken(cardToken: String) = apply { + cardTokens = + (cardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(cardToken) + } + } + + fun currentVersion(currentVersion: CurrentVersion?) = + currentVersion(JsonField.ofNullable(currentVersion)) fun currentVersion(currentVersion: JsonField) = apply { this.currentVersion = currentVersion } - fun draftVersion(draftVersion: DraftVersion) = draftVersion(JsonField.of(draftVersion)) + fun draftVersion(draftVersion: DraftVersion?) = + draftVersion(JsonField.ofNullable(draftVersion)) fun draftVersion(draftVersion: JsonField) = apply { this.draftVersion = draftVersion } /** Auth Rule Name */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) /** Auth Rule Name */ fun name(name: JsonField) = apply { this.name = name } @@ -240,7 +277,19 @@ private constructor( /** Card tokens to which the Auth Rule does not apply. */ fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { - this.excludedCardTokens = excludedCardTokens + this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } + } + + /** Card tokens to which the Auth Rule does not apply. */ + fun addExcludedCardToken(excludedCardToken: String) = apply { + excludedCardTokens = + (excludedCardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(excludedCardToken) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -264,16 +313,18 @@ private constructor( fun build(): V2RetrieveResponse = V2RetrieveResponse( - token, - accountTokens.map { it.toImmutable() }, - cardTokens.map { it.toImmutable() }, - currentVersion, - draftVersion, - name, - programLevel, - state, - type, - excludedCardTokens.map { it.toImmutable() }, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountTokens) { "`accountTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(cardTokens) { "`cardTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(currentVersion) { "`currentVersion` is required but was not set" }, + checkNotNull(draftVersion) { "`draftVersion` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(programLevel) { "`programLevel` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -299,10 +350,12 @@ private constructor( fun version(): Long = version.getRequired("version") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -327,8 +380,8 @@ private constructor( class Builder { - private var parameters: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var parameters: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(currentVersion: CurrentVersion) = apply { @@ -345,6 +398,12 @@ private constructor( this.parameters = parameters } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) + + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + /** * The version of the rule, this is incremented whenever the rule's parameters change. */ @@ -376,8 +435,8 @@ private constructor( fun build(): CurrentVersion = CurrentVersion( - parameters, - version, + checkNotNull(parameters) { "`parameters` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -526,7 +585,9 @@ private constructor( fun conditions(): List = conditions.getRequired("conditions") - @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing @@ -550,12 +611,13 @@ private constructor( class Builder { - private var conditions: JsonField> = JsonMissing.of() + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } @@ -564,7 +626,18 @@ private constructor( conditions(JsonField.of(conditions)) fun conditions(conditions: JsonField>) = apply { - this.conditions = conditions + this.conditions = conditions.map { it.toMutableList() } + } + + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -591,7 +664,8 @@ private constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( - conditions.map { it.toImmutable() }, + checkNotNull(conditions) { "`conditions` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -693,13 +767,17 @@ private constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -832,6 +910,15 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun value(value: JsonField) = apply { this.value = value } + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) + + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun value(long: Long) = value(Value.ofLong(long)) + + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1271,10 +1358,12 @@ private constructor( fun version(): Long = version.getRequired("version") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -1299,8 +1388,8 @@ private constructor( class Builder { - private var parameters: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var parameters: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(draftVersion: DraftVersion) = apply { @@ -1317,6 +1406,12 @@ private constructor( this.parameters = parameters } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) + + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + /** * The version of the rule, this is incremented whenever the rule's parameters change. */ @@ -1348,8 +1443,8 @@ private constructor( fun build(): DraftVersion = DraftVersion( - parameters, - version, + checkNotNull(parameters) { "`parameters` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1498,7 +1593,9 @@ private constructor( fun conditions(): List = conditions.getRequired("conditions") - @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing @@ -1522,12 +1619,13 @@ private constructor( class Builder { - private var conditions: JsonField> = JsonMissing.of() + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } @@ -1536,7 +1634,18 @@ private constructor( conditions(JsonField.of(conditions)) fun conditions(conditions: JsonField>) = apply { - this.conditions = conditions + this.conditions = conditions.map { it.toMutableList() } + } + + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -1563,7 +1672,8 @@ private constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( - conditions.map { it.toImmutable() }, + checkNotNull(conditions) { "`conditions` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -1665,13 +1775,17 @@ private constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -1804,6 +1918,15 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun value(value: JsonField) = apply { this.value = value } + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) + + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun value(long: Long) = value(Value.ofLong(long)) + + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2UpdateResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2UpdateResponse.kt index 06355074..e0655bd1 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2UpdateResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/V2UpdateResponse.kt @@ -89,34 +89,44 @@ private constructor( fun excludedCardTokens(): List? = excludedCardTokens.getNullable("excluded_card_tokens") /** Auth Rule Token */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token /** Account tokens to which the Auth Rule applies. */ - @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + @JsonProperty("account_tokens") + @ExcludeMissing + fun _accountTokens(): JsonField> = accountTokens /** Card tokens to which the Auth Rule applies. */ - @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + @JsonProperty("card_tokens") + @ExcludeMissing + fun _cardTokens(): JsonField> = cardTokens - @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + @JsonProperty("current_version") + @ExcludeMissing + fun _currentVersion(): JsonField = currentVersion - @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + @JsonProperty("draft_version") + @ExcludeMissing + fun _draftVersion(): JsonField = draftVersion /** Auth Rule Name */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Whether the Auth Rule applies to all authorizations on the card program. */ - @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + @JsonProperty("program_level") + @ExcludeMissing + fun _programLevel(): JsonField = programLevel /** The state of the Auth Rule */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** The type of Auth Rule */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** Card tokens to which the Auth Rule does not apply. */ @JsonProperty("excluded_card_tokens") @ExcludeMissing - fun _excludedCardTokens() = excludedCardTokens + fun _excludedCardTokens(): JsonField> = excludedCardTokens @JsonAnyGetter @ExcludeMissing @@ -149,29 +159,29 @@ private constructor( class Builder { - private var token: JsonField = JsonMissing.of() - private var accountTokens: JsonField> = JsonMissing.of() - private var cardTokens: JsonField> = JsonMissing.of() - private var currentVersion: JsonField = JsonMissing.of() - private var draftVersion: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var programLevel: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var excludedCardTokens: JsonField> = JsonMissing.of() + private var token: JsonField? = null + private var accountTokens: JsonField>? = null + private var cardTokens: JsonField>? = null + private var currentVersion: JsonField? = null + private var draftVersion: JsonField? = null + private var name: JsonField? = null + private var programLevel: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var excludedCardTokens: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(v2UpdateResponse: V2UpdateResponse) = apply { token = v2UpdateResponse.token - accountTokens = v2UpdateResponse.accountTokens - cardTokens = v2UpdateResponse.cardTokens + accountTokens = v2UpdateResponse.accountTokens.map { it.toMutableList() } + cardTokens = v2UpdateResponse.cardTokens.map { it.toMutableList() } currentVersion = v2UpdateResponse.currentVersion draftVersion = v2UpdateResponse.draftVersion name = v2UpdateResponse.name programLevel = v2UpdateResponse.programLevel state = v2UpdateResponse.state type = v2UpdateResponse.type - excludedCardTokens = v2UpdateResponse.excludedCardTokens + excludedCardTokens = v2UpdateResponse.excludedCardTokens.map { it.toMutableList() } additionalProperties = v2UpdateResponse.additionalProperties.toMutableMap() } @@ -186,30 +196,57 @@ private constructor( /** Account tokens to which the Auth Rule applies. */ fun accountTokens(accountTokens: JsonField>) = apply { - this.accountTokens = accountTokens + this.accountTokens = accountTokens.map { it.toMutableList() } + } + + /** Account tokens to which the Auth Rule applies. */ + fun addAccountToken(accountToken: String) = apply { + accountTokens = + (accountTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(accountToken) + } } /** Card tokens to which the Auth Rule applies. */ fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + fun cardTokens(cardTokens: JsonField>) = apply { + this.cardTokens = cardTokens.map { it.toMutableList() } + } - fun currentVersion(currentVersion: CurrentVersion) = - currentVersion(JsonField.of(currentVersion)) + /** Card tokens to which the Auth Rule applies. */ + fun addCardToken(cardToken: String) = apply { + cardTokens = + (cardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(cardToken) + } + } + + fun currentVersion(currentVersion: CurrentVersion?) = + currentVersion(JsonField.ofNullable(currentVersion)) fun currentVersion(currentVersion: JsonField) = apply { this.currentVersion = currentVersion } - fun draftVersion(draftVersion: DraftVersion) = draftVersion(JsonField.of(draftVersion)) + fun draftVersion(draftVersion: DraftVersion?) = + draftVersion(JsonField.ofNullable(draftVersion)) fun draftVersion(draftVersion: JsonField) = apply { this.draftVersion = draftVersion } /** Auth Rule Name */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) /** Auth Rule Name */ fun name(name: JsonField) = apply { this.name = name } @@ -240,7 +277,19 @@ private constructor( /** Card tokens to which the Auth Rule does not apply. */ fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { - this.excludedCardTokens = excludedCardTokens + this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } + } + + /** Card tokens to which the Auth Rule does not apply. */ + fun addExcludedCardToken(excludedCardToken: String) = apply { + excludedCardTokens = + (excludedCardTokens ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(excludedCardToken) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -264,16 +313,18 @@ private constructor( fun build(): V2UpdateResponse = V2UpdateResponse( - token, - accountTokens.map { it.toImmutable() }, - cardTokens.map { it.toImmutable() }, - currentVersion, - draftVersion, - name, - programLevel, - state, - type, - excludedCardTokens.map { it.toImmutable() }, + checkNotNull(token) { "`token` is required but was not set" }, + checkNotNull(accountTokens) { "`accountTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(cardTokens) { "`cardTokens` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(currentVersion) { "`currentVersion` is required but was not set" }, + checkNotNull(draftVersion) { "`draftVersion` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(programLevel) { "`programLevel` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -299,10 +350,12 @@ private constructor( fun version(): Long = version.getRequired("version") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -327,8 +380,8 @@ private constructor( class Builder { - private var parameters: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var parameters: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(currentVersion: CurrentVersion) = apply { @@ -345,6 +398,12 @@ private constructor( this.parameters = parameters } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) + + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + /** * The version of the rule, this is incremented whenever the rule's parameters change. */ @@ -376,8 +435,8 @@ private constructor( fun build(): CurrentVersion = CurrentVersion( - parameters, - version, + checkNotNull(parameters) { "`parameters` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -526,7 +585,9 @@ private constructor( fun conditions(): List = conditions.getRequired("conditions") - @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing @@ -550,12 +611,13 @@ private constructor( class Builder { - private var conditions: JsonField> = JsonMissing.of() + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } @@ -564,7 +626,18 @@ private constructor( conditions(JsonField.of(conditions)) fun conditions(conditions: JsonField>) = apply { - this.conditions = conditions + this.conditions = conditions.map { it.toMutableList() } + } + + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -591,7 +664,8 @@ private constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( - conditions.map { it.toImmutable() }, + checkNotNull(conditions) { "`conditions` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -693,13 +767,17 @@ private constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -832,6 +910,15 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun value(value: JsonField) = apply { this.value = value } + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) + + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun value(long: Long) = value(Value.ofLong(long)) + + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1271,10 +1358,12 @@ private constructor( fun version(): Long = version.getRequired("version") /** Parameters for the current version of the Auth Rule */ - @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** The version of the rule, this is incremented whenever the rule's parameters change. */ - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -1299,8 +1388,8 @@ private constructor( class Builder { - private var parameters: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var parameters: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(draftVersion: DraftVersion) = apply { @@ -1317,6 +1406,12 @@ private constructor( this.parameters = parameters } + fun parameters(conditionalBlockParameters: Parameters.ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlockParameters(conditionalBlockParameters)) + + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + /** * The version of the rule, this is incremented whenever the rule's parameters change. */ @@ -1348,8 +1443,8 @@ private constructor( fun build(): DraftVersion = DraftVersion( - parameters, - version, + checkNotNull(parameters) { "`parameters` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1498,7 +1593,9 @@ private constructor( fun conditions(): List = conditions.getRequired("conditions") - @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + @JsonProperty("conditions") + @ExcludeMissing + fun _conditions(): JsonField> = conditions @JsonAnyGetter @ExcludeMissing @@ -1522,12 +1619,13 @@ private constructor( class Builder { - private var conditions: JsonField> = JsonMissing.of() + private var conditions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { - conditions = conditionalBlockParameters.conditions + conditions = + conditionalBlockParameters.conditions.map { it.toMutableList() } additionalProperties = conditionalBlockParameters.additionalProperties.toMutableMap() } @@ -1536,7 +1634,18 @@ private constructor( conditions(JsonField.of(conditions)) fun conditions(conditions: JsonField>) = apply { - this.conditions = conditions + this.conditions = conditions.map { it.toMutableList() } + } + + fun addCondition(condition: Condition) = apply { + conditions = + (conditions ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(condition) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -1563,7 +1672,8 @@ private constructor( fun build(): ConditionalBlockParameters = ConditionalBlockParameters( - conditions.map { it.toImmutable() }, + checkNotNull(conditions) { "`conditions` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -1665,13 +1775,17 @@ private constructor( * - `CARD_TRANSACTION_COUNT_24H`: The number of transactions on the card in the * trailing 24 hours up and until the authorization. */ - @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + @JsonProperty("attribute") + @ExcludeMissing + fun _attribute(): JsonField = attribute /** The operation to apply to the attribute */ - @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + @JsonProperty("operation") + @ExcludeMissing + fun _operation(): JsonField = operation /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -1804,6 +1918,15 @@ private constructor( /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun value(value: JsonField) = apply { this.value = value } + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(string: String) = value(Value.ofString(string)) + + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun value(long: Long) = value(Value.ofLong(long)) + + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/VelocityLimitParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/VelocityLimitParams.kt index 66010558..a7e38fd4 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/VelocityLimitParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/VelocityLimitParams.kt @@ -71,21 +71,21 @@ private constructor( */ fun limitCount(): Long? = limitCount.getNullable("limit_count") - @JsonProperty("filters") @ExcludeMissing fun _filters() = filters + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField = filters /** * The size of the trailing window to calculate Spend Velocity over in seconds. The minimum * value is 10 seconds, and the maximum value is 2678400 seconds. */ - @JsonProperty("period") @ExcludeMissing fun _period() = period + @JsonProperty("period") @ExcludeMissing fun _period(): JsonField = period - @JsonProperty("scope") @ExcludeMissing fun _scope() = scope + @JsonProperty("scope") @ExcludeMissing fun _scope(): JsonField = scope /** * The maximum amount of spend velocity allowed in the period in minor units (the smallest unit * of a currency, e.g. cents for USD). Transactions exceeding this limit will be declined. */ - @JsonProperty("limit_amount") @ExcludeMissing fun _limitAmount() = limitAmount + @JsonProperty("limit_amount") @ExcludeMissing fun _limitAmount(): JsonField = limitAmount /** * The number of spend velocity impacting transactions may not exceed this limit in the period. @@ -93,7 +93,7 @@ private constructor( * a transaction that has been authorized, and optionally settled, or a force post (a * transaction that settled without prior authorization). */ - @JsonProperty("limit_count") @ExcludeMissing fun _limitCount() = limitCount + @JsonProperty("limit_count") @ExcludeMissing fun _limitCount(): JsonField = limitCount @JsonAnyGetter @ExcludeMissing @@ -121,9 +121,9 @@ private constructor( class Builder { - private var filters: JsonField = JsonMissing.of() - private var period: JsonField = JsonMissing.of() - private var scope: JsonField = JsonMissing.of() + private var filters: JsonField? = null + private var period: JsonField? = null + private var scope: JsonField? = null private var limitAmount: JsonField = JsonMissing.of() private var limitCount: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -153,6 +153,21 @@ private constructor( */ fun period(period: JsonField) = apply { this.period = period } + /** + * The size of the trailing window to calculate Spend Velocity over in seconds. The minimum + * value is 10 seconds, and the maximum value is 2678400 seconds. + */ + fun period(long: Long) = period(Period.ofLong(long)) + + /** + * The window of time to calculate Spend Velocity over. + * - `DAY`: Velocity over the current day since midnight Eastern Time. + * - `MONTH`: Velocity over the current month since 00:00 / 12 AM on the first of the month + * in Eastern Time. + */ + fun period(velocityLimitParamsPeriodWindow: VelocityLimitParamsPeriodWindow) = + period(Period.ofVelocityLimitParamsPeriodWindow(velocityLimitParamsPeriodWindow)) + fun scope(scope: Scope) = scope(JsonField.of(scope)) fun scope(scope: JsonField) = apply { this.scope = scope } @@ -162,7 +177,14 @@ private constructor( * unit of a currency, e.g. cents for USD). Transactions exceeding this limit will be * declined. */ - fun limitAmount(limitAmount: Long) = limitAmount(JsonField.of(limitAmount)) + fun limitAmount(limitAmount: Long?) = limitAmount(JsonField.ofNullable(limitAmount)) + + /** + * The maximum amount of spend velocity allowed in the period in minor units (the smallest + * unit of a currency, e.g. cents for USD). Transactions exceeding this limit will be + * declined. + */ + fun limitAmount(limitAmount: Long) = limitAmount(limitAmount as Long?) /** * The maximum amount of spend velocity allowed in the period in minor units (the smallest @@ -177,7 +199,15 @@ private constructor( * transaction is a transaction that has been authorized, and optionally settled, or a force * post (a transaction that settled without prior authorization). */ - fun limitCount(limitCount: Long) = limitCount(JsonField.of(limitCount)) + fun limitCount(limitCount: Long?) = limitCount(JsonField.ofNullable(limitCount)) + + /** + * The number of spend velocity impacting transactions may not exceed this limit in the + * period. Transactions exceeding this limit will be declined. A spend velocity impacting + * transaction is a transaction that has been authorized, and optionally settled, or a force + * post (a transaction that settled without prior authorization). + */ + fun limitCount(limitCount: Long) = limitCount(limitCount as Long?) /** * The number of spend velocity impacting transactions may not exceed this limit in the @@ -208,9 +238,9 @@ private constructor( fun build(): VelocityLimitParams = VelocityLimitParams( - filters, - period, - scope, + checkNotNull(filters) { "`filters` is required but was not set" }, + checkNotNull(period) { "`period` is required but was not set" }, + checkNotNull(scope) { "`scope` is required but was not set" }, limitAmount, limitCount, additionalProperties.toImmutable(), @@ -249,13 +279,15 @@ private constructor( */ @JsonProperty("include_countries") @ExcludeMissing - fun _includeCountries() = includeCountries + fun _includeCountries(): JsonField> = includeCountries /** * Merchant Category Codes to include in the velocity calculation. Transactions not matching * this MCC will not be included in the calculated velocity. */ - @JsonProperty("include_mccs") @ExcludeMissing fun _includeMccs() = includeMccs + @JsonProperty("include_mccs") + @ExcludeMissing + fun _includeMccs(): JsonField> = includeMccs @JsonAnyGetter @ExcludeMissing @@ -280,13 +312,13 @@ private constructor( class Builder { - private var includeCountries: JsonField> = JsonMissing.of() - private var includeMccs: JsonField> = JsonMissing.of() + private var includeCountries: JsonField>? = null + private var includeMccs: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(filters: Filters) = apply { - includeCountries = filters.includeCountries - includeMccs = filters.includeMccs + includeCountries = filters.includeCountries.map { it.toMutableList() } + includeMccs = filters.includeMccs.map { it.toMutableList() } additionalProperties = filters.additionalProperties.toMutableMap() } @@ -294,29 +326,60 @@ private constructor( * ISO-3166-1 alpha-3 Country Codes to include in the velocity calculation. Transactions * not matching any of the provided will not be included in the calculated velocity. */ - fun includeCountries(includeCountries: List) = - includeCountries(JsonField.of(includeCountries)) + fun includeCountries(includeCountries: List?) = + includeCountries(JsonField.ofNullable(includeCountries)) /** * ISO-3166-1 alpha-3 Country Codes to include in the velocity calculation. Transactions * not matching any of the provided will not be included in the calculated velocity. */ fun includeCountries(includeCountries: JsonField>) = apply { - this.includeCountries = includeCountries + this.includeCountries = includeCountries.map { it.toMutableList() } + } + + /** + * ISO-3166-1 alpha-3 Country Codes to include in the velocity calculation. Transactions + * not matching any of the provided will not be included in the calculated velocity. + */ + fun addIncludeCountry(includeCountry: String) = apply { + includeCountries = + (includeCountries ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(includeCountry) + } } /** * Merchant Category Codes to include in the velocity calculation. Transactions not * matching this MCC will not be included in the calculated velocity. */ - fun includeMccs(includeMccs: List) = includeMccs(JsonField.of(includeMccs)) + fun includeMccs(includeMccs: List?) = + includeMccs(JsonField.ofNullable(includeMccs)) /** * Merchant Category Codes to include in the velocity calculation. Transactions not * matching this MCC will not be included in the calculated velocity. */ fun includeMccs(includeMccs: JsonField>) = apply { - this.includeMccs = includeMccs + this.includeMccs = includeMccs.map { it.toMutableList() } + } + + /** + * Merchant Category Codes to include in the velocity calculation. Transactions not + * matching this MCC will not be included in the calculated velocity. + */ + fun addIncludeMcc(includeMcc: String) = apply { + includeMccs = + (includeMccs ?: JsonField.of(mutableListOf())).apply { + (asKnown() + ?: throw IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + )) + .add(includeMcc) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -340,8 +403,8 @@ private constructor( fun build(): Filters = Filters( - includeCountries.map { it.toImmutable() }, - includeMccs.map { it.toImmutable() }, + (includeCountries ?: JsonMissing.of()).map { it.toImmutable() }, + (includeMccs ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/TransactionTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/TransactionTest.kt index 30617ebb..9e07afc8 100644 --- a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/TransactionTest.kt +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/TransactionTest.kt @@ -15,6 +15,7 @@ class TransactionTest { .token("c30c2182-1e69-4e0d-b40f-eec0d2a19123") .accountToken("db3942f0-0627-4887-a190-1ea83b46d091") .acquirerFee(0L) + .acquirerReferenceNumber(null) .amount(1800L) .amounts( Transaction.TransactionAmounts.builder() @@ -56,6 +57,7 @@ class TransactionTest { .cardToken("aac502f9-aecc-458a-954e-4bcf6edb6123") .cardholderAuthentication( Transaction.CardholderAuthentication.builder() + ._3dsVersion(null) .acquirerExemption( Transaction.CardholderAuthentication.AcquirerExemption .AUTHENTICATION_OUTAGE_EXCEPTION @@ -178,6 +180,7 @@ class TransactionTest { Transaction.TransactionEvent.NetworkInfo.builder() .acquirer( Transaction.TransactionEvent.NetworkInfo.Acquirer.builder() + .acquirerReferenceNumber(null) .retrievalReferenceNumber("064386558597") .build() ) @@ -185,6 +188,7 @@ class TransactionTest { Transaction.TransactionEvent.NetworkInfo.Mastercard .builder() .banknetReferenceNumber("U1HSCJ") + .switchSerialNumber(null) .build() ) .visa( @@ -220,6 +224,7 @@ class TransactionTest { assertThat(transaction.token()).isEqualTo("c30c2182-1e69-4e0d-b40f-eec0d2a19123") assertThat(transaction.accountToken()).isEqualTo("db3942f0-0627-4887-a190-1ea83b46d091") assertThat(transaction.acquirerFee()).isEqualTo(0L) + assertThat(transaction.acquirerReferenceNumber()).isNull() assertThat(transaction.amount()).isEqualTo(1800L) assertThat(transaction.amounts()) .isEqualTo( @@ -261,6 +266,7 @@ class TransactionTest { assertThat(transaction.cardholderAuthentication()) .isEqualTo( Transaction.CardholderAuthentication.builder() + ._3dsVersion(null) .acquirerExemption( Transaction.CardholderAuthentication.AcquirerExemption .AUTHENTICATION_OUTAGE_EXCEPTION @@ -380,12 +386,14 @@ class TransactionTest { Transaction.TransactionEvent.NetworkInfo.builder() .acquirer( Transaction.TransactionEvent.NetworkInfo.Acquirer.builder() + .acquirerReferenceNumber(null) .retrievalReferenceNumber("064386558597") .build() ) .mastercard( Transaction.TransactionEvent.NetworkInfo.Mastercard.builder() .banknetReferenceNumber("U1HSCJ") + .switchSerialNumber(null) .build() ) .visa(