From eeb635d8ce89419ec138b3c50da0cd9b9c62be14 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 8 Jul 2025 18:59:19 +0000 Subject: [PATCH 1/5] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index b57de73da..2e6b9fb4e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 165 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-41b87f6139d55188993492b9c042a6bc1bc0506c166334c387072b57b6c79869.yml openapi_spec_hash: 3327246caf3bcbd3504ce99c81062075 -config_hash: b7425db12ddcc27a89a38de7042c4fa2 +config_hash: f390dcd4de9109eff9667160949feef2 From 1bf367a7cffe53272387316678edaa89035f2330 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 8 Jul 2025 20:09:23 +0000 Subject: [PATCH 2/5] chore(ci): ensure docs generation always succeeds --- .github/workflows/publish-sonatype.yml | 2 +- buildSrc/src/main/kotlin/lithic.publish.gradle.kts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index f29849ee6..16a7e4270 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -33,7 +33,7 @@ jobs: export -- GPG_SIGNING_KEY_ID printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" - ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache + ./gradlew publishAndReleaseToMavenCentral -Dorg.gradle.jvmargs="-Xmx8g" --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache env: SONATYPE_USERNAME: ${{ secrets.LITHIC_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.LITHIC_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} diff --git a/buildSrc/src/main/kotlin/lithic.publish.gradle.kts b/buildSrc/src/main/kotlin/lithic.publish.gradle.kts index 961f26ae4..e5ca4e7e8 100644 --- a/buildSrc/src/main/kotlin/lithic.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/lithic.publish.gradle.kts @@ -53,3 +53,7 @@ configure { } } } + +tasks.withType().configureEach { + isZip64 = true +} From 076028b56cbab680e6e56fd31578009de54ed394 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 18:45:27 +0000 Subject: [PATCH 3/5] feat(api): adds Network Programs and Account/Card Sub-statuses - Add detailed substatus enums for Account and Card state management with fraud, risk, and lifecycle reason codes - Add Network Program endpoints for program management. --- .stats.yml | 8 +- .../com/lithic/api/client/LithicClient.kt | 5 + .../lithic/api/client/LithicClientAsync.kt | 5 + .../api/client/LithicClientAsyncImpl.kt | 14 + .../com/lithic/api/client/LithicClientImpl.kt | 14 + .../kotlin/com/lithic/api/models/Account.kt | 314 ++- .../lithic/api/models/AccountUpdateParams.kt | 423 +++- .../com/lithic/api/models/AggregateBalance.kt | 6 + .../api/models/AggregateBalanceListParams.kt | 6 + .../kotlin/com/lithic/api/models/Balance.kt | 6 + .../lithic/api/models/BalanceListParams.kt | 6 + .../lithic/api/models/BalanceListResponse.kt | 6 + .../main/kotlin/com/lithic/api/models/Card.kt | 175 +- .../com/lithic/api/models/CardCreateParams.kt | 459 +++- .../com/lithic/api/models/CardProgram.kt | 55 +- .../com/lithic/api/models/CardUpdateParams.kt | 519 +++- .../models/Conditional3dsActionParameters.kt | 19 +- .../com/lithic/api/models/ExternalResource.kt | 275 +++ .../lithic/api/models/ExternalResourceType.kt | 147 ++ .../api/models/FinancialAccountListParams.kt | 6 + .../models/ManagementOperationCreateParams.kt | 211 +- .../models/ManagementOperationTransaction.kt | 54 +- .../com/lithic/api/models/NetworkProgram.kt | 309 +++ .../api/models/NetworkProgramListPage.kt | 126 + .../api/models/NetworkProgramListPageAsync.kt | 140 ++ .../models/NetworkProgramListPageResponse.kt | 228 ++ .../api/models/NetworkProgramListParams.kt | 239 ++ .../models/NetworkProgramRetrieveParams.kt | 195 ++ .../com/lithic/api/models/NonPciCard.kt | 370 ++- .../api/models/PaymentSimulateActionParams.kt | 6 + .../com/lithic/api/models/Transaction.kt | 79 +- .../lithic/api/models/VelocityLimitParams.kt | 323 +-- .../models/VelocityLimitParamsPeriodWindow.kt | 2136 ++++++++++++++++- .../async/NetworkProgramServiceAsync.kt | 173 ++ .../async/NetworkProgramServiceAsyncImpl.kt | 139 ++ .../blocking/NetworkProgramService.kt | 169 ++ .../blocking/NetworkProgramServiceImpl.kt | 129 + .../api/models/AccountListPageResponseTest.kt | 6 + .../com/lithic/api/models/AccountTest.kt | 6 + .../api/models/AccountUpdateParamsTest.kt | 6 + .../lithic/api/models/CardCreateParamsTest.kt | 6 + .../api/models/CardListPageResponseTest.kt | 9 + .../models/CardProgramListPageResponseTest.kt | 3 + .../com/lithic/api/models/CardProgramTest.kt | 3 + .../kotlin/com/lithic/api/models/CardTest.kt | 9 + .../lithic/api/models/CardUpdateParamsTest.kt | 9 + .../lithic/api/models/ExternalResourceTest.kt | 46 + .../ManagementOperationCreateParamsTest.kt | 4 + ...ManagementOperationListPageResponseTest.kt | 21 + .../ManagementOperationTransactionTest.kt | 22 + .../NetworkProgramListPageResponseTest.kt | 70 + .../models/NetworkProgramListParamsTest.kt | 50 + .../NetworkProgramRetrieveParamsTest.kt | 28 + .../lithic/api/models/NetworkProgramTest.kt | 48 + .../com/lithic/api/models/NonPciCardTest.kt | 10 + .../VelocityLimitParamsPeriodWindowTest.kt | 292 +++ .../api/models/VelocityLimitParamsTest.kt | 2 +- .../lithic/api/services/ErrorHandlingTest.kt | 18 + .../lithic/api/services/ServiceParamsTest.kt | 2 + .../services/async/AccountServiceAsyncTest.kt | 2 + .../services/async/CardServiceAsyncTest.kt | 5 + .../ManagementOperationServiceAsyncTest.kt | 1 + .../async/NetworkProgramServiceAsyncTest.kt | 43 + .../services/blocking/AccountServiceTest.kt | 2 + .../api/services/blocking/CardServiceTest.kt | 5 + .../ManagementOperationServiceTest.kt | 1 + .../blocking/NetworkProgramServiceTest.kt | 40 + 67 files changed, 7823 insertions(+), 440 deletions(-) create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalResource.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalResourceType.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgram.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListPage.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListPageAsync.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListPageResponse.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListParams.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramRetrieveParams.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsync.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsyncImpl.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/NetworkProgramService.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/NetworkProgramServiceImpl.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalResourceTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramListPageResponseTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramListParamsTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramRetrieveParamsTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/VelocityLimitParamsPeriodWindowTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsyncTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/NetworkProgramServiceTest.kt diff --git a/.stats.yml b/.stats.yml index 2e6b9fb4e..c9520d6b7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 165 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-41b87f6139d55188993492b9c042a6bc1bc0506c166334c387072b57b6c79869.yml -openapi_spec_hash: 3327246caf3bcbd3504ce99c81062075 -config_hash: f390dcd4de9109eff9667160949feef2 +configured_endpoints: 167 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-b9c76d077831114f1e4c5c15ff3f1d835ef3e9361b768af8468f8eb07a09ef3e.yml +openapi_spec_hash: 5f9bcf1afd68f962a870727c35628394 +config_hash: e9a46eb8acb9dc2c236f3e1958a1c4dd diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt index 66dbb9a57..1a5d815fa 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt @@ -27,6 +27,7 @@ import com.lithic.api.services.blocking.FinancialAccountService import com.lithic.api.services.blocking.FraudService import com.lithic.api.services.blocking.FundingEventService import com.lithic.api.services.blocking.ManagementOperationService +import com.lithic.api.services.blocking.NetworkProgramService import com.lithic.api.services.blocking.PaymentService import com.lithic.api.services.blocking.ReportService import com.lithic.api.services.blocking.ResponderEndpointService @@ -130,6 +131,8 @@ interface LithicClient { fun fraud(): FraudService + fun networkPrograms(): NetworkProgramService + /** Status of api */ fun apiStatus(): ApiStatus = apiStatus(ClientApiStatusParams.none()) @@ -224,6 +227,8 @@ interface LithicClient { fun fraud(): FraudService.WithRawResponse + fun networkPrograms(): NetworkProgramService.WithRawResponse + /** * Returns a raw HTTP response for `get /v1/status`, but is otherwise the same as * [LithicClient.apiStatus]. diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt index da1641789..25833f2ec 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt @@ -26,6 +26,7 @@ import com.lithic.api.services.async.FinancialAccountServiceAsync import com.lithic.api.services.async.FraudServiceAsync import com.lithic.api.services.async.FundingEventServiceAsync import com.lithic.api.services.async.ManagementOperationServiceAsync +import com.lithic.api.services.async.NetworkProgramServiceAsync import com.lithic.api.services.async.PaymentServiceAsync import com.lithic.api.services.async.ReportServiceAsync import com.lithic.api.services.async.ResponderEndpointServiceAsync @@ -130,6 +131,8 @@ interface LithicClientAsync { fun fraud(): FraudServiceAsync + fun networkPrograms(): NetworkProgramServiceAsync + /** Status of api */ fun apiStatus(): CompletableFuture = apiStatus(ClientApiStatusParams.none()) @@ -227,6 +230,8 @@ interface LithicClientAsync { fun fraud(): FraudServiceAsync.WithRawResponse + fun networkPrograms(): NetworkProgramServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /v1/status`, but is otherwise the same as * [LithicClientAsync.apiStatus]. diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt index ff705c2f7..8d7d5bb73 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt @@ -55,6 +55,8 @@ import com.lithic.api.services.async.FundingEventServiceAsync import com.lithic.api.services.async.FundingEventServiceAsyncImpl import com.lithic.api.services.async.ManagementOperationServiceAsync import com.lithic.api.services.async.ManagementOperationServiceAsyncImpl +import com.lithic.api.services.async.NetworkProgramServiceAsync +import com.lithic.api.services.async.NetworkProgramServiceAsyncImpl import com.lithic.api.services.async.PaymentServiceAsync import com.lithic.api.services.async.PaymentServiceAsyncImpl import com.lithic.api.services.async.ReportServiceAsync @@ -201,6 +203,10 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl FraudServiceAsyncImpl(clientOptionsWithUserAgent) } + private val networkPrograms: NetworkProgramServiceAsync by lazy { + NetworkProgramServiceAsyncImpl(clientOptionsWithUserAgent) + } + override fun sync(): LithicClient = sync override fun withRawResponse(): LithicClientAsync.WithRawResponse = withRawResponse @@ -265,6 +271,8 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl override fun fraud(): FraudServiceAsync = fraud + override fun networkPrograms(): NetworkProgramServiceAsync = networkPrograms + override fun apiStatus( params: ClientApiStatusParams, requestOptions: RequestOptions, @@ -388,6 +396,10 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl FraudServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val networkPrograms: NetworkProgramServiceAsync.WithRawResponse by lazy { + NetworkProgramServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): LithicClientAsync.WithRawResponse = @@ -457,6 +469,8 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl override fun fraud(): FraudServiceAsync.WithRawResponse = fraud + override fun networkPrograms(): NetworkProgramServiceAsync.WithRawResponse = networkPrograms + private val apiStatusHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt index 5a216e0b6..859f2f678 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt @@ -55,6 +55,8 @@ import com.lithic.api.services.blocking.FundingEventService import com.lithic.api.services.blocking.FundingEventServiceImpl import com.lithic.api.services.blocking.ManagementOperationService import com.lithic.api.services.blocking.ManagementOperationServiceImpl +import com.lithic.api.services.blocking.NetworkProgramService +import com.lithic.api.services.blocking.NetworkProgramServiceImpl import com.lithic.api.services.blocking.PaymentService import com.lithic.api.services.blocking.PaymentServiceImpl import com.lithic.api.services.blocking.ReportService @@ -184,6 +186,10 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient private val fraud: FraudService by lazy { FraudServiceImpl(clientOptionsWithUserAgent) } + private val networkPrograms: NetworkProgramService by lazy { + NetworkProgramServiceImpl(clientOptionsWithUserAgent) + } + override fun async(): LithicClientAsync = async override fun withRawResponse(): LithicClient.WithRawResponse = withRawResponse @@ -247,6 +253,8 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient override fun fraud(): FraudService = fraud + override fun networkPrograms(): NetworkProgramService = networkPrograms + override fun apiStatus( params: ClientApiStatusParams, requestOptions: RequestOptions, @@ -370,6 +378,10 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient FraudServiceImpl.WithRawResponseImpl(clientOptions) } + private val networkPrograms: NetworkProgramService.WithRawResponse by lazy { + NetworkProgramServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): LithicClient.WithRawResponse = @@ -438,6 +450,8 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient override fun fraud(): FraudService.WithRawResponse = fraud + override fun networkPrograms(): NetworkProgramService.WithRawResponse = networkPrograms + private val apiStatusHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Account.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Account.kt index 9c1a94d9a..82242b23b 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Account.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Account.kt @@ -30,6 +30,8 @@ private constructor( private val accountHolder: JsonField, private val authRuleTokens: JsonField>, private val cardholderCurrency: JsonField, + private val comment: JsonField, + private val substatus: JsonField, private val verificationAddress: JsonField, private val additionalProperties: MutableMap, ) { @@ -53,6 +55,10 @@ private constructor( @JsonProperty("cardholder_currency") @ExcludeMissing cardholderCurrency: JsonField = JsonMissing.of(), + @JsonProperty("comment") @ExcludeMissing comment: JsonField = JsonMissing.of(), + @JsonProperty("substatus") + @ExcludeMissing + substatus: JsonField = JsonMissing.of(), @JsonProperty("verification_address") @ExcludeMissing verificationAddress: JsonField = JsonMissing.of(), @@ -64,6 +70,8 @@ private constructor( accountHolder, authRuleTokens, cardholderCurrency, + comment, + substatus, verificationAddress, mutableMapOf(), ) @@ -139,6 +147,45 @@ private constructor( fun cardholderCurrency(): Optional = cardholderCurrency.getOptional("cardholder_currency") + /** + * Additional context or information related to the account. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun comment(): Optional = comment.getOptional("comment") + + /** + * Account state substatus values: + * - `FRAUD_IDENTIFIED` - The account has been recognized as being created or used with stolen + * or fabricated identity information, encompassing both true identity theft and synthetic + * identities. + * - `SUSPICIOUS_ACTIVITY` - The account has exhibited suspicious behavior, such as unauthorized + * access or fraudulent transactions, necessitating further investigation. + * - `RISK_VIOLATION` - The account has been involved in deliberate misuse by the legitimate + * account holder. Examples include disputing valid transactions without cause, falsely + * claiming non-receipt of goods, or engaging in intentional bust-out schemes to exploit + * account services. + * - `END_USER_REQUEST` - The account holder has voluntarily requested the closure of the + * account for personal reasons. This encompasses situations such as bankruptcy, other + * financial considerations, or the account holder's death. + * - `ISSUER_REQUEST` - The issuer has initiated the closure of the account due to business + * strategy, risk management, inactivity, product changes, regulatory concerns, or violations + * of terms and conditions. + * - `NOT_ACTIVE` - The account has not had any transactions or payment activity within a + * specified period. This status applies to accounts that are paused or closed due to + * inactivity. + * - `INTERNAL_REVIEW` - The account is temporarily paused pending further internal review. In + * future implementations, this status may prevent clients from activating the account via + * APIs until the review is completed. + * - `OTHER` - The reason for the account's current status does not fall into any of the above + * categories. A comment should be provided to specify the particular reason. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun substatus(): Optional = substatus.getOptional("substatus") + /** * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -206,6 +253,20 @@ private constructor( @ExcludeMissing fun _cardholderCurrency(): JsonField = cardholderCurrency + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment + + /** + * Returns the raw JSON value of [substatus]. + * + * Unlike [substatus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("substatus") @ExcludeMissing fun _substatus(): JsonField = substatus + /** * Returns the raw JSON value of [verificationAddress]. * @@ -255,6 +316,8 @@ private constructor( private var accountHolder: JsonField = JsonMissing.of() private var authRuleTokens: JsonField>? = null private var cardholderCurrency: JsonField = JsonMissing.of() + private var comment: JsonField = JsonMissing.of() + private var substatus: JsonField = JsonMissing.of() private var verificationAddress: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -267,6 +330,8 @@ private constructor( accountHolder = account.accountHolder authRuleTokens = account.authRuleTokens.map { it.toMutableList() } cardholderCurrency = account.cardholderCurrency + comment = account.comment + substatus = account.substatus verificationAddress = account.verificationAddress additionalProperties = account.additionalProperties.toMutableMap() } @@ -401,6 +466,54 @@ private constructor( this.cardholderCurrency = cardholderCurrency } + /** Additional context or information related to the account. */ + fun comment(comment: String) = comment(JsonField.of(comment)) + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun comment(comment: JsonField) = apply { this.comment = comment } + + /** + * Account state substatus values: + * - `FRAUD_IDENTIFIED` - The account has been recognized as being created or used with + * stolen or fabricated identity information, encompassing both true identity theft and + * synthetic identities. + * - `SUSPICIOUS_ACTIVITY` - The account has exhibited suspicious behavior, such as + * unauthorized access or fraudulent transactions, necessitating further investigation. + * - `RISK_VIOLATION` - The account has been involved in deliberate misuse by the legitimate + * account holder. Examples include disputing valid transactions without cause, falsely + * claiming non-receipt of goods, or engaging in intentional bust-out schemes to exploit + * account services. + * - `END_USER_REQUEST` - The account holder has voluntarily requested the closure of the + * account for personal reasons. This encompasses situations such as bankruptcy, other + * financial considerations, or the account holder's death. + * - `ISSUER_REQUEST` - The issuer has initiated the closure of the account due to business + * strategy, risk management, inactivity, product changes, regulatory concerns, or + * violations of terms and conditions. + * - `NOT_ACTIVE` - The account has not had any transactions or payment activity within a + * specified period. This status applies to accounts that are paused or closed due to + * inactivity. + * - `INTERNAL_REVIEW` - The account is temporarily paused pending further internal review. + * In future implementations, this status may prevent clients from activating the account + * via APIs until the review is completed. + * - `OTHER` - The reason for the account's current status does not fall into any of the + * above categories. A comment should be provided to specify the particular reason. + */ + fun substatus(substatus: Substatus) = substatus(JsonField.of(substatus)) + + /** + * Sets [Builder.substatus] to an arbitrary JSON value. + * + * You should usually call [Builder.substatus] with a well-typed [Substatus] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun substatus(substatus: JsonField) = apply { this.substatus = substatus } + @Deprecated("deprecated") fun verificationAddress(verificationAddress: VerificationAddress) = verificationAddress(JsonField.of(verificationAddress)) @@ -460,6 +573,8 @@ private constructor( accountHolder, (authRuleTokens ?: JsonMissing.of()).map { it.toImmutable() }, cardholderCurrency, + comment, + substatus, verificationAddress, additionalProperties.toMutableMap(), ) @@ -479,6 +594,8 @@ private constructor( accountHolder().ifPresent { it.validate() } authRuleTokens() cardholderCurrency() + comment() + substatus().ifPresent { it.validate() } verificationAddress().ifPresent { it.validate() } validated = true } @@ -505,6 +622,8 @@ private constructor( (accountHolder.asKnown().getOrNull()?.validity() ?: 0) + (authRuleTokens.asKnown().getOrNull()?.size ?: 0) + (if (cardholderCurrency.asKnown().isPresent) 1 else 0) + + (if (comment.asKnown().isPresent) 1 else 0) + + (substatus.asKnown().getOrNull()?.validity() ?: 0) + (verificationAddress.asKnown().getOrNull()?.validity() ?: 0) /** @@ -1176,6 +1295,195 @@ private constructor( "AccountHolder{token=$token, businessAccountToken=$businessAccountToken, email=$email, phoneNumber=$phoneNumber, additionalProperties=$additionalProperties}" } + /** + * Account state substatus values: + * - `FRAUD_IDENTIFIED` - The account has been recognized as being created or used with stolen + * or fabricated identity information, encompassing both true identity theft and synthetic + * identities. + * - `SUSPICIOUS_ACTIVITY` - The account has exhibited suspicious behavior, such as unauthorized + * access or fraudulent transactions, necessitating further investigation. + * - `RISK_VIOLATION` - The account has been involved in deliberate misuse by the legitimate + * account holder. Examples include disputing valid transactions without cause, falsely + * claiming non-receipt of goods, or engaging in intentional bust-out schemes to exploit + * account services. + * - `END_USER_REQUEST` - The account holder has voluntarily requested the closure of the + * account for personal reasons. This encompasses situations such as bankruptcy, other + * financial considerations, or the account holder's death. + * - `ISSUER_REQUEST` - The issuer has initiated the closure of the account due to business + * strategy, risk management, inactivity, product changes, regulatory concerns, or violations + * of terms and conditions. + * - `NOT_ACTIVE` - The account has not had any transactions or payment activity within a + * specified period. This status applies to accounts that are paused or closed due to + * inactivity. + * - `INTERNAL_REVIEW` - The account is temporarily paused pending further internal review. In + * future implementations, this status may prevent clients from activating the account via + * APIs until the review is completed. + * - `OTHER` - The reason for the account's current status does not fall into any of the above + * categories. A comment should be provided to specify the particular reason. + */ + class Substatus @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val FRAUD_IDENTIFIED = of("FRAUD_IDENTIFIED") + + @JvmField val SUSPICIOUS_ACTIVITY = of("SUSPICIOUS_ACTIVITY") + + @JvmField val RISK_VIOLATION = of("RISK_VIOLATION") + + @JvmField val END_USER_REQUEST = of("END_USER_REQUEST") + + @JvmField val ISSUER_REQUEST = of("ISSUER_REQUEST") + + @JvmField val NOT_ACTIVE = of("NOT_ACTIVE") + + @JvmField val INTERNAL_REVIEW = of("INTERNAL_REVIEW") + + @JvmField val OTHER = of("OTHER") + + @JvmStatic fun of(value: String) = Substatus(JsonField.of(value)) + } + + /** An enum containing [Substatus]'s known values. */ + enum class Known { + FRAUD_IDENTIFIED, + SUSPICIOUS_ACTIVITY, + RISK_VIOLATION, + END_USER_REQUEST, + ISSUER_REQUEST, + NOT_ACTIVE, + INTERNAL_REVIEW, + OTHER, + } + + /** + * An enum containing [Substatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Substatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FRAUD_IDENTIFIED, + SUSPICIOUS_ACTIVITY, + RISK_VIOLATION, + END_USER_REQUEST, + ISSUER_REQUEST, + NOT_ACTIVE, + INTERNAL_REVIEW, + OTHER, + /** + * An enum member indicating that [Substatus] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FRAUD_IDENTIFIED -> Value.FRAUD_IDENTIFIED + SUSPICIOUS_ACTIVITY -> Value.SUSPICIOUS_ACTIVITY + RISK_VIOLATION -> Value.RISK_VIOLATION + END_USER_REQUEST -> Value.END_USER_REQUEST + ISSUER_REQUEST -> Value.ISSUER_REQUEST + NOT_ACTIVE -> Value.NOT_ACTIVE + INTERNAL_REVIEW -> Value.INTERNAL_REVIEW + OTHER -> Value.OTHER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FRAUD_IDENTIFIED -> Known.FRAUD_IDENTIFIED + SUSPICIOUS_ACTIVITY -> Known.SUSPICIOUS_ACTIVITY + RISK_VIOLATION -> Known.RISK_VIOLATION + END_USER_REQUEST -> Known.END_USER_REQUEST + ISSUER_REQUEST -> Known.ISSUER_REQUEST + NOT_ACTIVE -> Known.NOT_ACTIVE + INTERNAL_REVIEW -> Known.INTERNAL_REVIEW + OTHER -> Known.OTHER + else -> throw LithicInvalidDataException("Unknown Substatus: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Substatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Substatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + @Deprecated("deprecated") class VerificationAddress private constructor( @@ -1535,15 +1843,15 @@ private constructor( return true } - return /* spotless:off */ other is Account && token == other.token && created == other.created && spendLimit == other.spendLimit && state == other.state && accountHolder == other.accountHolder && authRuleTokens == other.authRuleTokens && cardholderCurrency == other.cardholderCurrency && verificationAddress == other.verificationAddress && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Account && token == other.token && created == other.created && spendLimit == other.spendLimit && state == other.state && accountHolder == other.accountHolder && authRuleTokens == other.authRuleTokens && cardholderCurrency == other.cardholderCurrency && comment == other.comment && substatus == other.substatus && verificationAddress == other.verificationAddress && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(token, created, spendLimit, state, accountHolder, authRuleTokens, cardholderCurrency, verificationAddress, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(token, created, spendLimit, state, accountHolder, authRuleTokens, cardholderCurrency, comment, substatus, verificationAddress, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Account{token=$token, created=$created, spendLimit=$spendLimit, state=$state, accountHolder=$accountHolder, authRuleTokens=$authRuleTokens, cardholderCurrency=$cardholderCurrency, verificationAddress=$verificationAddress, additionalProperties=$additionalProperties}" + "Account{token=$token, created=$created, spendLimit=$spendLimit, state=$state, accountHolder=$accountHolder, authRuleTokens=$authRuleTokens, cardholderCurrency=$cardholderCurrency, comment=$comment, substatus=$substatus, verificationAddress=$verificationAddress, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountUpdateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountUpdateParams.kt index 49e66c13a..00fb0fc39 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountUpdateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountUpdateParams.kt @@ -35,6 +35,14 @@ private constructor( fun accountToken(): Optional = Optional.ofNullable(accountToken) + /** + * Additional context or information related to the account. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun comment(): Optional = body.comment() + /** * Amount (in cents) for the account's daily spend limit (e.g. 100000 would be a $1,000 limit). * By default the daily spend limit is set to $1,250. @@ -74,6 +82,37 @@ private constructor( */ fun state(): Optional = body.state() + /** + * Account state substatus values: + * - `FRAUD_IDENTIFIED` - The account has been recognized as being created or used with stolen + * or fabricated identity information, encompassing both true identity theft and synthetic + * identities. + * - `SUSPICIOUS_ACTIVITY` - The account has exhibited suspicious behavior, such as unauthorized + * access or fraudulent transactions, necessitating further investigation. + * - `RISK_VIOLATION` - The account has been involved in deliberate misuse by the legitimate + * account holder. Examples include disputing valid transactions without cause, falsely + * claiming non-receipt of goods, or engaging in intentional bust-out schemes to exploit + * account services. + * - `END_USER_REQUEST` - The account holder has voluntarily requested the closure of the + * account for personal reasons. This encompasses situations such as bankruptcy, other + * financial considerations, or the account holder's death. + * - `ISSUER_REQUEST` - The issuer has initiated the closure of the account due to business + * strategy, risk management, inactivity, product changes, regulatory concerns, or violations + * of terms and conditions. + * - `NOT_ACTIVE` - The account has not had any transactions or payment activity within a + * specified period. This status applies to accounts that are paused or closed due to + * inactivity. + * - `INTERNAL_REVIEW` - The account is temporarily paused pending further internal review. In + * future implementations, this status may prevent clients from activating the account via + * APIs until the review is completed. + * - `OTHER` - The reason for the account's current status does not fall into any of the above + * categories. A comment should be provided to specify the particular reason. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun substatus(): Optional = body.substatus() + /** * 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 Auth Rules. @@ -85,6 +124,13 @@ private constructor( @Deprecated("deprecated") fun verificationAddress(): Optional = body.verificationAddress() + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _comment(): JsonField = body._comment() + /** * Returns the raw JSON value of [dailySpendLimit]. * @@ -115,6 +161,13 @@ private constructor( */ fun _state(): JsonField = body._state() + /** + * Returns the raw JSON value of [substatus]. + * + * Unlike [substatus], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _substatus(): JsonField = body._substatus() + /** * Returns the raw JSON value of [verificationAddress]. * @@ -166,15 +219,26 @@ private constructor( * * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: + * - [comment] * - [dailySpendLimit] * - [lifetimeSpendLimit] * - [monthlySpendLimit] * - [state] - * - [verificationAddress] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** Additional context or information related to the account. */ + fun comment(comment: String) = apply { body.comment(comment) } + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun comment(comment: JsonField) = apply { body.comment(comment) } + /** * Amount (in cents) for the account's daily spend limit (e.g. 100000 would be a $1,000 * limit). By default the daily spend limit is set to $1,250. @@ -245,6 +309,43 @@ private constructor( */ fun state(state: JsonField) = apply { body.state(state) } + /** + * Account state substatus values: + * - `FRAUD_IDENTIFIED` - The account has been recognized as being created or used with + * stolen or fabricated identity information, encompassing both true identity theft and + * synthetic identities. + * - `SUSPICIOUS_ACTIVITY` - The account has exhibited suspicious behavior, such as + * unauthorized access or fraudulent transactions, necessitating further investigation. + * - `RISK_VIOLATION` - The account has been involved in deliberate misuse by the legitimate + * account holder. Examples include disputing valid transactions without cause, falsely + * claiming non-receipt of goods, or engaging in intentional bust-out schemes to exploit + * account services. + * - `END_USER_REQUEST` - The account holder has voluntarily requested the closure of the + * account for personal reasons. This encompasses situations such as bankruptcy, other + * financial considerations, or the account holder's death. + * - `ISSUER_REQUEST` - The issuer has initiated the closure of the account due to business + * strategy, risk management, inactivity, product changes, regulatory concerns, or + * violations of terms and conditions. + * - `NOT_ACTIVE` - The account has not had any transactions or payment activity within a + * specified period. This status applies to accounts that are paused or closed due to + * inactivity. + * - `INTERNAL_REVIEW` - The account is temporarily paused pending further internal review. + * In future implementations, this status may prevent clients from activating the account + * via APIs until the review is completed. + * - `OTHER` - The reason for the account's current status does not fall into any of the + * above categories. A comment should be provided to specify the particular reason. + */ + fun substatus(substatus: Substatus) = apply { body.substatus(substatus) } + + /** + * Sets [Builder.substatus] to an arbitrary JSON value. + * + * You should usually call [Builder.substatus] with a well-typed [Substatus] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun substatus(substatus: JsonField) = apply { body.substatus(substatus) } + /** * 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 @@ -412,16 +513,19 @@ private constructor( class Body private constructor( + private val comment: JsonField, private val dailySpendLimit: JsonField, private val lifetimeSpendLimit: JsonField, private val monthlySpendLimit: JsonField, private val state: JsonField, + private val substatus: JsonField, private val verificationAddress: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("comment") @ExcludeMissing comment: JsonField = JsonMissing.of(), @JsonProperty("daily_spend_limit") @ExcludeMissing dailySpendLimit: JsonField = JsonMissing.of(), @@ -432,18 +536,31 @@ private constructor( @ExcludeMissing monthlySpendLimit: JsonField = JsonMissing.of(), @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), + @JsonProperty("substatus") + @ExcludeMissing + substatus: JsonField = JsonMissing.of(), @JsonProperty("verification_address") @ExcludeMissing verificationAddress: JsonField = JsonMissing.of(), ) : this( + comment, dailySpendLimit, lifetimeSpendLimit, monthlySpendLimit, state, + substatus, verificationAddress, mutableMapOf(), ) + /** + * Additional context or information related to the account. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun comment(): Optional = comment.getOptional("comment") + /** * Amount (in cents) for the account's daily spend limit (e.g. 100000 would be a $1,000 * limit). By default the daily spend limit is set to $1,250. @@ -485,6 +602,37 @@ private constructor( */ fun state(): Optional = state.getOptional("state") + /** + * Account state substatus values: + * - `FRAUD_IDENTIFIED` - The account has been recognized as being created or used with + * stolen or fabricated identity information, encompassing both true identity theft and + * synthetic identities. + * - `SUSPICIOUS_ACTIVITY` - The account has exhibited suspicious behavior, such as + * unauthorized access or fraudulent transactions, necessitating further investigation. + * - `RISK_VIOLATION` - The account has been involved in deliberate misuse by the legitimate + * account holder. Examples include disputing valid transactions without cause, falsely + * claiming non-receipt of goods, or engaging in intentional bust-out schemes to exploit + * account services. + * - `END_USER_REQUEST` - The account holder has voluntarily requested the closure of the + * account for personal reasons. This encompasses situations such as bankruptcy, other + * financial considerations, or the account holder's death. + * - `ISSUER_REQUEST` - The issuer has initiated the closure of the account due to business + * strategy, risk management, inactivity, product changes, regulatory concerns, or + * violations of terms and conditions. + * - `NOT_ACTIVE` - The account has not had any transactions or payment activity within a + * specified period. This status applies to accounts that are paused or closed due to + * inactivity. + * - `INTERNAL_REVIEW` - The account is temporarily paused pending further internal review. + * In future implementations, this status may prevent clients from activating the account + * via APIs until the review is completed. + * - `OTHER` - The reason for the account's current status does not fall into any of the + * above categories. A comment should be provided to specify the particular reason. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun substatus(): Optional = substatus.getOptional("substatus") + /** * 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 @@ -497,6 +645,13 @@ private constructor( fun verificationAddress(): Optional = verificationAddress.getOptional("verification_address") + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment + /** * Returns the raw JSON value of [dailySpendLimit]. * @@ -534,6 +689,15 @@ private constructor( */ @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + /** + * Returns the raw JSON value of [substatus]. + * + * Unlike [substatus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("substatus") + @ExcludeMissing + fun _substatus(): JsonField = substatus + /** * Returns the raw JSON value of [verificationAddress]. * @@ -566,23 +730,39 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var comment: JsonField = JsonMissing.of() 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 substatus: JsonField = JsonMissing.of() private var verificationAddress: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { + comment = body.comment dailySpendLimit = body.dailySpendLimit lifetimeSpendLimit = body.lifetimeSpendLimit monthlySpendLimit = body.monthlySpendLimit state = body.state + substatus = body.substatus verificationAddress = body.verificationAddress additionalProperties = body.additionalProperties.toMutableMap() } + /** Additional context or information related to the account. */ + fun comment(comment: String) = comment(JsonField.of(comment)) + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun comment(comment: JsonField) = apply { this.comment = comment } + /** * Amount (in cents) for the account's daily spend limit (e.g. 100000 would be a $1,000 * limit). By default the daily spend limit is set to $1,250. @@ -654,6 +834,44 @@ private constructor( */ fun state(state: JsonField) = apply { this.state = state } + /** + * Account state substatus values: + * - `FRAUD_IDENTIFIED` - The account has been recognized as being created or used with + * stolen or fabricated identity information, encompassing both true identity theft + * and synthetic identities. + * - `SUSPICIOUS_ACTIVITY` - The account has exhibited suspicious behavior, such as + * unauthorized access or fraudulent transactions, necessitating further + * investigation. + * - `RISK_VIOLATION` - The account has been involved in deliberate misuse by the + * legitimate account holder. Examples include disputing valid transactions without + * cause, falsely claiming non-receipt of goods, or engaging in intentional bust-out + * schemes to exploit account services. + * - `END_USER_REQUEST` - The account holder has voluntarily requested the closure of + * the account for personal reasons. This encompasses situations such as bankruptcy, + * other financial considerations, or the account holder's death. + * - `ISSUER_REQUEST` - The issuer has initiated the closure of the account due to + * business strategy, risk management, inactivity, product changes, regulatory + * concerns, or violations of terms and conditions. + * - `NOT_ACTIVE` - The account has not had any transactions or payment activity within + * a specified period. This status applies to accounts that are paused or closed due + * to inactivity. + * - `INTERNAL_REVIEW` - The account is temporarily paused pending further internal + * review. In future implementations, this status may prevent clients from activating + * the account via APIs until the review is completed. + * - `OTHER` - The reason for the account's current status does not fall into any of the + * above categories. A comment should be provided to specify the particular reason. + */ + fun substatus(substatus: Substatus) = substatus(JsonField.of(substatus)) + + /** + * Sets [Builder.substatus] to an arbitrary JSON value. + * + * You should usually call [Builder.substatus] with a well-typed [Substatus] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun substatus(substatus: JsonField) = apply { this.substatus = substatus } + /** * 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 @@ -702,10 +920,12 @@ private constructor( */ fun build(): Body = Body( + comment, dailySpendLimit, lifetimeSpendLimit, monthlySpendLimit, state, + substatus, verificationAddress, additionalProperties.toMutableMap(), ) @@ -718,10 +938,12 @@ private constructor( return@apply } + comment() dailySpendLimit() lifetimeSpendLimit() monthlySpendLimit() state().ifPresent { it.validate() } + substatus().ifPresent { it.validate() } verificationAddress().ifPresent { it.validate() } validated = true } @@ -742,10 +964,12 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (dailySpendLimit.asKnown().isPresent) 1 else 0) + + (if (comment.asKnown().isPresent) 1 else 0) + + (if (dailySpendLimit.asKnown().isPresent) 1 else 0) + (if (lifetimeSpendLimit.asKnown().isPresent) 1 else 0) + (if (monthlySpendLimit.asKnown().isPresent) 1 else 0) + (state.asKnown().getOrNull()?.validity() ?: 0) + + (substatus.asKnown().getOrNull()?.validity() ?: 0) + (verificationAddress.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { @@ -753,17 +977,17 @@ private constructor( return true } - return /* spotless:off */ other is Body && dailySpendLimit == other.dailySpendLimit && lifetimeSpendLimit == other.lifetimeSpendLimit && monthlySpendLimit == other.monthlySpendLimit && state == other.state && verificationAddress == other.verificationAddress && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && comment == other.comment && dailySpendLimit == other.dailySpendLimit && lifetimeSpendLimit == other.lifetimeSpendLimit && monthlySpendLimit == other.monthlySpendLimit && state == other.state && substatus == other.substatus && verificationAddress == other.verificationAddress && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(dailySpendLimit, lifetimeSpendLimit, monthlySpendLimit, state, verificationAddress, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(comment, dailySpendLimit, lifetimeSpendLimit, monthlySpendLimit, state, substatus, verificationAddress, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Body{dailySpendLimit=$dailySpendLimit, lifetimeSpendLimit=$lifetimeSpendLimit, monthlySpendLimit=$monthlySpendLimit, state=$state, verificationAddress=$verificationAddress, additionalProperties=$additionalProperties}" + "Body{comment=$comment, dailySpendLimit=$dailySpendLimit, lifetimeSpendLimit=$lifetimeSpendLimit, monthlySpendLimit=$monthlySpendLimit, state=$state, substatus=$substatus, verificationAddress=$verificationAddress, additionalProperties=$additionalProperties}" } /** Account states. */ @@ -898,6 +1122,195 @@ private constructor( override fun toString() = value.toString() } + /** + * Account state substatus values: + * - `FRAUD_IDENTIFIED` - The account has been recognized as being created or used with stolen + * or fabricated identity information, encompassing both true identity theft and synthetic + * identities. + * - `SUSPICIOUS_ACTIVITY` - The account has exhibited suspicious behavior, such as unauthorized + * access or fraudulent transactions, necessitating further investigation. + * - `RISK_VIOLATION` - The account has been involved in deliberate misuse by the legitimate + * account holder. Examples include disputing valid transactions without cause, falsely + * claiming non-receipt of goods, or engaging in intentional bust-out schemes to exploit + * account services. + * - `END_USER_REQUEST` - The account holder has voluntarily requested the closure of the + * account for personal reasons. This encompasses situations such as bankruptcy, other + * financial considerations, or the account holder's death. + * - `ISSUER_REQUEST` - The issuer has initiated the closure of the account due to business + * strategy, risk management, inactivity, product changes, regulatory concerns, or violations + * of terms and conditions. + * - `NOT_ACTIVE` - The account has not had any transactions or payment activity within a + * specified period. This status applies to accounts that are paused or closed due to + * inactivity. + * - `INTERNAL_REVIEW` - The account is temporarily paused pending further internal review. In + * future implementations, this status may prevent clients from activating the account via + * APIs until the review is completed. + * - `OTHER` - The reason for the account's current status does not fall into any of the above + * categories. A comment should be provided to specify the particular reason. + */ + class Substatus @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val FRAUD_IDENTIFIED = of("FRAUD_IDENTIFIED") + + @JvmField val SUSPICIOUS_ACTIVITY = of("SUSPICIOUS_ACTIVITY") + + @JvmField val RISK_VIOLATION = of("RISK_VIOLATION") + + @JvmField val END_USER_REQUEST = of("END_USER_REQUEST") + + @JvmField val ISSUER_REQUEST = of("ISSUER_REQUEST") + + @JvmField val NOT_ACTIVE = of("NOT_ACTIVE") + + @JvmField val INTERNAL_REVIEW = of("INTERNAL_REVIEW") + + @JvmField val OTHER = of("OTHER") + + @JvmStatic fun of(value: String) = Substatus(JsonField.of(value)) + } + + /** An enum containing [Substatus]'s known values. */ + enum class Known { + FRAUD_IDENTIFIED, + SUSPICIOUS_ACTIVITY, + RISK_VIOLATION, + END_USER_REQUEST, + ISSUER_REQUEST, + NOT_ACTIVE, + INTERNAL_REVIEW, + OTHER, + } + + /** + * An enum containing [Substatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Substatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FRAUD_IDENTIFIED, + SUSPICIOUS_ACTIVITY, + RISK_VIOLATION, + END_USER_REQUEST, + ISSUER_REQUEST, + NOT_ACTIVE, + INTERNAL_REVIEW, + OTHER, + /** + * An enum member indicating that [Substatus] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FRAUD_IDENTIFIED -> Value.FRAUD_IDENTIFIED + SUSPICIOUS_ACTIVITY -> Value.SUSPICIOUS_ACTIVITY + RISK_VIOLATION -> Value.RISK_VIOLATION + END_USER_REQUEST -> Value.END_USER_REQUEST + ISSUER_REQUEST -> Value.ISSUER_REQUEST + NOT_ACTIVE -> Value.NOT_ACTIVE + INTERNAL_REVIEW -> Value.INTERNAL_REVIEW + OTHER -> Value.OTHER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FRAUD_IDENTIFIED -> Known.FRAUD_IDENTIFIED + SUSPICIOUS_ACTIVITY -> Known.SUSPICIOUS_ACTIVITY + RISK_VIOLATION -> Known.RISK_VIOLATION + END_USER_REQUEST -> Known.END_USER_REQUEST + ISSUER_REQUEST -> Known.ISSUER_REQUEST + NOT_ACTIVE -> Known.NOT_ACTIVE + INTERNAL_REVIEW -> Known.INTERNAL_REVIEW + OTHER -> Known.OTHER + else -> throw LithicInvalidDataException("Unknown Substatus: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Substatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Substatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** * 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 Auth Rules. diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AggregateBalance.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AggregateBalance.kt index f85700cd8..f3438ffc2 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AggregateBalance.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AggregateBalance.kt @@ -583,6 +583,8 @@ private constructor( @JvmField val RESERVE = of("RESERVE") + @JvmField val SECURITY = of("SECURITY") + @JvmStatic fun of(value: String) = FinancialAccountType(JsonField.of(value)) } @@ -591,6 +593,7 @@ private constructor( ISSUING, OPERATING, RESERVE, + SECURITY, } /** @@ -607,6 +610,7 @@ private constructor( ISSUING, OPERATING, RESERVE, + SECURITY, /** * An enum member indicating that [FinancialAccountType] was instantiated with an * unknown value. @@ -626,6 +630,7 @@ private constructor( ISSUING -> Value.ISSUING OPERATING -> Value.OPERATING RESERVE -> Value.RESERVE + SECURITY -> Value.SECURITY else -> Value._UNKNOWN } @@ -643,6 +648,7 @@ private constructor( ISSUING -> Known.ISSUING OPERATING -> Known.OPERATING RESERVE -> Known.RESERVE + SECURITY -> Known.SECURITY else -> throw LithicInvalidDataException("Unknown FinancialAccountType: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AggregateBalanceListParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AggregateBalanceListParams.kt index 939ec157d..b0013c089 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AggregateBalanceListParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AggregateBalanceListParams.kt @@ -211,6 +211,8 @@ private constructor( @JvmField val RESERVE = of("RESERVE") + @JvmField val SECURITY = of("SECURITY") + @JvmStatic fun of(value: String) = FinancialAccountType(JsonField.of(value)) } @@ -219,6 +221,7 @@ private constructor( ISSUING, OPERATING, RESERVE, + SECURITY, } /** @@ -235,6 +238,7 @@ private constructor( ISSUING, OPERATING, RESERVE, + SECURITY, /** * An enum member indicating that [FinancialAccountType] was instantiated with an * unknown value. @@ -254,6 +258,7 @@ private constructor( ISSUING -> Value.ISSUING OPERATING -> Value.OPERATING RESERVE -> Value.RESERVE + SECURITY -> Value.SECURITY else -> Value._UNKNOWN } @@ -271,6 +276,7 @@ private constructor( ISSUING -> Known.ISSUING OPERATING -> Known.OPERATING RESERVE -> Known.RESERVE + SECURITY -> Known.SECURITY else -> throw LithicInvalidDataException("Unknown FinancialAccountType: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Balance.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Balance.kt index 0ffcff6a0..13d1e39f6 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Balance.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Balance.kt @@ -585,6 +585,8 @@ private constructor( @JvmField val RESERVE = of("RESERVE") + @JvmField val SECURITY = of("SECURITY") + @JvmStatic fun of(value: String) = FinancialAccountType(JsonField.of(value)) } @@ -593,6 +595,7 @@ private constructor( ISSUING, OPERATING, RESERVE, + SECURITY, } /** @@ -609,6 +612,7 @@ private constructor( ISSUING, OPERATING, RESERVE, + SECURITY, /** * An enum member indicating that [FinancialAccountType] was instantiated with an * unknown value. @@ -628,6 +632,7 @@ private constructor( ISSUING -> Value.ISSUING OPERATING -> Value.OPERATING RESERVE -> Value.RESERVE + SECURITY -> Value.SECURITY else -> Value._UNKNOWN } @@ -645,6 +650,7 @@ private constructor( ISSUING -> Known.ISSUING OPERATING -> Known.OPERATING RESERVE -> Known.RESERVE + SECURITY -> Known.SECURITY else -> throw LithicInvalidDataException("Unknown FinancialAccountType: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceListParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceListParams.kt index 430b95e66..c90b4adec 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceListParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceListParams.kt @@ -262,6 +262,8 @@ private constructor( @JvmField val RESERVE = of("RESERVE") + @JvmField val SECURITY = of("SECURITY") + @JvmStatic fun of(value: String) = FinancialAccountType(JsonField.of(value)) } @@ -270,6 +272,7 @@ private constructor( ISSUING, OPERATING, RESERVE, + SECURITY, } /** @@ -286,6 +289,7 @@ private constructor( ISSUING, OPERATING, RESERVE, + SECURITY, /** * An enum member indicating that [FinancialAccountType] was instantiated with an * unknown value. @@ -305,6 +309,7 @@ private constructor( ISSUING -> Value.ISSUING OPERATING -> Value.OPERATING RESERVE -> Value.RESERVE + SECURITY -> Value.SECURITY else -> Value._UNKNOWN } @@ -322,6 +327,7 @@ private constructor( ISSUING -> Known.ISSUING OPERATING -> Known.OPERATING RESERVE -> Known.RESERVE + SECURITY -> Known.SECURITY else -> throw LithicInvalidDataException("Unknown FinancialAccountType: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceListResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceListResponse.kt index b909e51b4..e441cf259 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceListResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceListResponse.kt @@ -563,6 +563,8 @@ private constructor( @JvmField val RESERVE = of("RESERVE") + @JvmField val SECURITY = of("SECURITY") + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } @@ -571,6 +573,7 @@ private constructor( ISSUING, OPERATING, RESERVE, + SECURITY, } /** @@ -586,6 +589,7 @@ private constructor( ISSUING, OPERATING, RESERVE, + SECURITY, /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -602,6 +606,7 @@ private constructor( ISSUING -> Value.ISSUING OPERATING -> Value.OPERATING RESERVE -> Value.RESERVE + SECURITY -> Value.SECURITY else -> Value._UNKNOWN } @@ -619,6 +624,7 @@ private constructor( ISSUING -> Known.ISSUING OPERATING -> Known.OPERATING RESERVE -> Known.RESERVE + SECURITY -> Known.SECURITY else -> throw LithicInvalidDataException("Unknown Type: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Card.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Card.kt index 5b25db8d6..de2e73d74 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Card.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Card.kt @@ -36,14 +36,17 @@ private constructor( private val type: JsonField, private val authRuleTokens: JsonField>, private val cardholderCurrency: JsonField, + private val comment: JsonField, private val digitalCardArtToken: JsonField, private val expMonth: JsonField, private val expYear: JsonField, private val hostname: JsonField, private val memo: JsonField, + private val networkProgramToken: JsonField, private val pendingCommands: JsonField>, private val productId: JsonField, private val replacementFor: JsonField, + private val substatus: JsonField, private val cvv: JsonField, private val pan: JsonField, private val additionalProperties: MutableMap, @@ -82,6 +85,7 @@ private constructor( @JsonProperty("cardholder_currency") @ExcludeMissing cardholderCurrency: JsonField = JsonMissing.of(), + @JsonProperty("comment") @ExcludeMissing comment: JsonField = JsonMissing.of(), @JsonProperty("digital_card_art_token") @ExcludeMissing digitalCardArtToken: JsonField = JsonMissing.of(), @@ -89,6 +93,9 @@ private constructor( @JsonProperty("exp_year") @ExcludeMissing expYear: JsonField = JsonMissing.of(), @JsonProperty("hostname") @ExcludeMissing hostname: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("network_program_token") + @ExcludeMissing + networkProgramToken: JsonField = JsonMissing.of(), @JsonProperty("pending_commands") @ExcludeMissing pendingCommands: JsonField> = JsonMissing.of(), @@ -96,6 +103,9 @@ private constructor( @JsonProperty("replacement_for") @ExcludeMissing replacementFor: JsonField = JsonMissing.of(), + @JsonProperty("substatus") + @ExcludeMissing + substatus: JsonField = JsonMissing.of(), @JsonProperty("cvv") @ExcludeMissing cvv: JsonField = JsonMissing.of(), @JsonProperty("pan") @ExcludeMissing pan: JsonField = JsonMissing.of(), ) : this( @@ -112,14 +122,17 @@ private constructor( type, authRuleTokens, cardholderCurrency, + comment, digitalCardArtToken, expMonth, expYear, hostname, memo, + networkProgramToken, pendingCommands, productId, replacementFor, + substatus, cvv, pan, mutableMapOf(), @@ -140,14 +153,17 @@ private constructor( .type(type) .authRuleTokens(authRuleTokens) .cardholderCurrency(cardholderCurrency) + .comment(comment) .digitalCardArtToken(digitalCardArtToken) .expMonth(expMonth) .expYear(expYear) .hostname(hostname) .memo(memo) + .networkProgramToken(networkProgramToken) .pendingCommands(pendingCommands) .productId(productId) .replacementFor(replacementFor) + .substatus(substatus) .build() /** @@ -287,6 +303,14 @@ private constructor( fun cardholderCurrency(): Optional = cardholderCurrency.getOptional("cardholder_currency") + /** + * Additional context or information related to the card. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun comment(): Optional = comment.getOptional("comment") + /** * 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. @@ -329,6 +353,17 @@ private constructor( */ fun memo(): Optional = memo.getOptional("memo") + /** + * Globally unique identifier for the card's network program. Null if the card is not associated + * with a network program. Currently applicable to Visa cards participating in Account Level + * Management only + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkProgramToken(): Optional = + networkProgramToken.getOptional("network_program_token") + /** * 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 @@ -358,6 +393,30 @@ private constructor( */ fun replacementFor(): Optional = replacementFor.getOptional("replacement_for") + /** + * Card state substatus values: _ `LOST` - The physical card is no longer in the cardholder's + * possession due to being lost or never received by the cardholder. _ `COMPROMISED` - Card + * information has been exposed, potentially leading to unauthorized access. This may involve + * physical card theft, cloning, or online data breaches. _ `DAMAGED` - The physical card is not + * functioning properly, such as having chip failures or a demagnetized magnetic stripe. _ + * `END_USER_REQUEST` - The cardholder requested the closure of the card for reasons unrelated + * to fraud or damage, such as switching to a different product or closing the account. _ + * `ISSUER_REQUEST` - The issuer closed the card for reasons unrelated to fraud or damage, such + * as account inactivity, product or policy changes, or technology upgrades. _ `NOT_ACTIVE` - + * The card hasn’t had any transaction activity for a specified period, applicable to statuses + * like `PAUSED` or `CLOSED`. _ `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious + * transactions or activities that require review. This can involve prompting the cardholder to + * confirm legitimate use or report confirmed fraud. _ `INTERNAL_REVIEW` - The card is + * temporarily paused pending further internal review. _ `EXPIRED` - The card has expired and + * has been closed without being reissued. _ `UNDELIVERABLE` - The card cannot be delivered to + * the cardholder and has been returned. \* `OTHER` - The reason for the status does not fall + * into any of the above categories. A comment can be provided to specify the reason. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun substatus(): Optional = substatus.getOptional("substatus") + /** * Three digit cvv printed on the back of the card. * @@ -484,6 +543,13 @@ private constructor( @ExcludeMissing fun _cardholderCurrency(): JsonField = cardholderCurrency + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment + /** * Returns the raw JSON value of [digitalCardArtToken]. * @@ -522,6 +588,16 @@ private constructor( */ @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + /** + * Returns the raw JSON value of [networkProgramToken]. + * + * Unlike [networkProgramToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("network_program_token") + @ExcludeMissing + fun _networkProgramToken(): JsonField = networkProgramToken + /** * Returns the raw JSON value of [pendingCommands]. * @@ -547,6 +623,15 @@ private constructor( @ExcludeMissing fun _replacementFor(): JsonField = replacementFor + /** + * Returns the raw JSON value of [substatus]. + * + * Unlike [substatus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("substatus") + @ExcludeMissing + fun _substatus(): JsonField = substatus + /** * Returns the raw JSON value of [cvv]. * @@ -612,14 +697,17 @@ private constructor( private var type: JsonField? = null private var authRuleTokens: JsonField>? = null private var cardholderCurrency: JsonField = JsonMissing.of() + private var comment: JsonField = JsonMissing.of() private var digitalCardArtToken: JsonField = JsonMissing.of() private var expMonth: JsonField = JsonMissing.of() private var expYear: JsonField = JsonMissing.of() private var hostname: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() + private var networkProgramToken: JsonField = JsonMissing.of() private var pendingCommands: JsonField>? = null private var productId: JsonField = JsonMissing.of() private var replacementFor: JsonField = JsonMissing.of() + private var substatus: JsonField = JsonMissing.of() private var cvv: JsonField = JsonMissing.of() private var pan: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -639,14 +727,17 @@ private constructor( type = card.type authRuleTokens = card.authRuleTokens.map { it.toMutableList() } cardholderCurrency = card.cardholderCurrency + comment = card.comment digitalCardArtToken = card.digitalCardArtToken expMonth = card.expMonth expYear = card.expYear hostname = card.hostname memo = card.memo + networkProgramToken = card.networkProgramToken pendingCommands = card.pendingCommands.map { it.toMutableList() } productId = card.productId replacementFor = card.replacementFor + substatus = card.substatus cvv = card.cvv pan = card.pan additionalProperties = card.additionalProperties.toMutableMap() @@ -884,6 +975,17 @@ private constructor( this.cardholderCurrency = cardholderCurrency } + /** Additional context or information related to the card. */ + fun comment(comment: String) = comment(JsonField.of(comment)) + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun comment(comment: JsonField) = apply { this.comment = comment } + /** * 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 @@ -947,6 +1049,31 @@ private constructor( */ fun memo(memo: JsonField) = apply { this.memo = memo } + /** + * Globally unique identifier for the card's network program. Null if the card is not + * associated with a network program. Currently applicable to Visa cards participating in + * Account Level Management only + */ + fun networkProgramToken(networkProgramToken: String?) = + networkProgramToken(JsonField.ofNullable(networkProgramToken)) + + /** + * Alias for calling [Builder.networkProgramToken] with `networkProgramToken.orElse(null)`. + */ + fun networkProgramToken(networkProgramToken: Optional) = + networkProgramToken(networkProgramToken.getOrNull()) + + /** + * Sets [Builder.networkProgramToken] to an arbitrary JSON value. + * + * You should usually call [Builder.networkProgramToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun networkProgramToken(networkProgramToken: JsonField) = apply { + this.networkProgramToken = networkProgramToken + } + /** * 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 @@ -1016,6 +1143,39 @@ private constructor( this.replacementFor = replacementFor } + /** + * Card state substatus values: _ `LOST` - The physical card is no longer in the + * cardholder's possession due to being lost or never received by the cardholder. _ + * `COMPROMISED` - Card information has been exposed, potentially leading to unauthorized + * access. This may involve physical card theft, cloning, or online data breaches. _ + * `DAMAGED` - The physical card is not functioning properly, such as having chip failures + * or a demagnetized magnetic stripe. _ `END_USER_REQUEST` - The cardholder requested the + * closure of the card for reasons unrelated to fraud or damage, such as switching to a + * different product or closing the account. _ `ISSUER_REQUEST` - The issuer closed the card + * for reasons unrelated to fraud or damage, such as account inactivity, product or policy + * changes, or technology upgrades. _ `NOT_ACTIVE` - The card hasn’t had any transaction + * activity for a specified period, applicable to statuses like `PAUSED` or `CLOSED`. _ + * `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious transactions or activities + * that require review. This can involve prompting the cardholder to confirm legitimate use + * or report confirmed fraud. _ `INTERNAL_REVIEW` - The card is temporarily paused pending + * further internal review. _ `EXPIRED` - The card has expired and has been closed without + * being reissued. _ `UNDELIVERABLE` - The card cannot be delivered to the cardholder and + * has been returned. \* `OTHER` - The reason for the status does not fall into any of the + * above categories. A comment can be provided to specify the reason. + */ + fun substatus(substatus: NonPciCard.Substatus) = substatus(JsonField.of(substatus)) + + /** + * Sets [Builder.substatus] to an arbitrary JSON value. + * + * You should usually call [Builder.substatus] with a well-typed [NonPciCard.Substatus] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun substatus(substatus: JsonField) = apply { + this.substatus = substatus + } + /** Three digit cvv printed on the back of the card. */ fun cvv(cvv: String) = cvv(JsonField.of(cvv)) @@ -1098,14 +1258,17 @@ private constructor( checkRequired("type", type), (authRuleTokens ?: JsonMissing.of()).map { it.toImmutable() }, cardholderCurrency, + comment, digitalCardArtToken, expMonth, expYear, hostname, memo, + networkProgramToken, (pendingCommands ?: JsonMissing.of()).map { it.toImmutable() }, productId, replacementFor, + substatus, cvv, pan, additionalProperties.toMutableMap(), @@ -1132,14 +1295,17 @@ private constructor( type().validate() authRuleTokens() cardholderCurrency() + comment() digitalCardArtToken() expMonth() expYear() hostname() memo() + networkProgramToken() pendingCommands() productId() replacementFor() + substatus().ifPresent { it.validate() } cvv() pan() validated = true @@ -1173,14 +1339,17 @@ private constructor( (type.asKnown().getOrNull()?.validity() ?: 0) + (authRuleTokens.asKnown().getOrNull()?.size ?: 0) + (if (cardholderCurrency.asKnown().isPresent) 1 else 0) + + (if (comment.asKnown().isPresent) 1 else 0) + (if (digitalCardArtToken.asKnown().isPresent) 1 else 0) + (if (expMonth.asKnown().isPresent) 1 else 0) + (if (expYear.asKnown().isPresent) 1 else 0) + (if (hostname.asKnown().isPresent) 1 else 0) + (if (memo.asKnown().isPresent) 1 else 0) + + (if (networkProgramToken.asKnown().isPresent) 1 else 0) + (pendingCommands.asKnown().getOrNull()?.size ?: 0) + (if (productId.asKnown().isPresent) 1 else 0) + (if (replacementFor.asKnown().isPresent) 1 else 0) + + (substatus.asKnown().getOrNull()?.validity() ?: 0) + (if (cvv.asKnown().isPresent) 1 else 0) + (if (pan.asKnown().isPresent) 1 else 0) @@ -1189,15 +1358,15 @@ private constructor( return true } - return /* spotless:off */ other is Card && token == other.token && accountToken == other.accountToken && cardProgramToken == other.cardProgramToken && created == other.created && funding == other.funding && lastFour == other.lastFour && pinStatus == other.pinStatus && spendLimit == other.spendLimit && spendLimitDuration == other.spendLimitDuration && state == other.state && type == other.type && authRuleTokens == other.authRuleTokens && cardholderCurrency == other.cardholderCurrency && digitalCardArtToken == other.digitalCardArtToken && expMonth == other.expMonth && expYear == other.expYear && hostname == other.hostname && memo == other.memo && pendingCommands == other.pendingCommands && productId == other.productId && replacementFor == other.replacementFor && cvv == other.cvv && pan == other.pan && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Card && token == other.token && accountToken == other.accountToken && cardProgramToken == other.cardProgramToken && created == other.created && funding == other.funding && lastFour == other.lastFour && pinStatus == other.pinStatus && spendLimit == other.spendLimit && spendLimitDuration == other.spendLimitDuration && state == other.state && type == other.type && authRuleTokens == other.authRuleTokens && cardholderCurrency == other.cardholderCurrency && comment == other.comment && digitalCardArtToken == other.digitalCardArtToken && expMonth == other.expMonth && expYear == other.expYear && hostname == other.hostname && memo == other.memo && networkProgramToken == other.networkProgramToken && pendingCommands == other.pendingCommands && productId == other.productId && replacementFor == other.replacementFor && substatus == other.substatus && cvv == other.cvv && pan == other.pan && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(token, accountToken, cardProgramToken, created, funding, lastFour, pinStatus, spendLimit, spendLimitDuration, state, type, authRuleTokens, cardholderCurrency, digitalCardArtToken, expMonth, expYear, hostname, memo, pendingCommands, productId, replacementFor, cvv, pan, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(token, accountToken, cardProgramToken, created, funding, lastFour, pinStatus, spendLimit, spendLimitDuration, state, type, authRuleTokens, cardholderCurrency, comment, digitalCardArtToken, expMonth, expYear, hostname, memo, networkProgramToken, pendingCommands, productId, replacementFor, substatus, cvv, pan, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Card{token=$token, accountToken=$accountToken, cardProgramToken=$cardProgramToken, created=$created, funding=$funding, lastFour=$lastFour, pinStatus=$pinStatus, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, type=$type, authRuleTokens=$authRuleTokens, cardholderCurrency=$cardholderCurrency, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, hostname=$hostname, memo=$memo, pendingCommands=$pendingCommands, productId=$productId, replacementFor=$replacementFor, cvv=$cvv, pan=$pan, additionalProperties=$additionalProperties}" + "Card{token=$token, accountToken=$accountToken, cardProgramToken=$cardProgramToken, created=$created, funding=$funding, lastFour=$lastFour, pinStatus=$pinStatus, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, type=$type, authRuleTokens=$authRuleTokens, cardholderCurrency=$cardholderCurrency, comment=$comment, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, hostname=$hostname, memo=$memo, networkProgramToken=$networkProgramToken, pendingCommands=$pendingCommands, productId=$productId, replacementFor=$replacementFor, substatus=$substatus, cvv=$cvv, pan=$pan, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardCreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardCreateParams.kt index c3cff84b3..52eb2d79b 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardCreateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardCreateParams.kt @@ -148,6 +148,14 @@ private constructor( */ fun replacementAccountToken(): Optional = body.replacementAccountToken() + /** + * Additional context or information related to the card that this card will replace. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacementComment(): Optional = body.replacementComment() + /** * 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 @@ -158,6 +166,34 @@ private constructor( */ fun replacementFor(): Optional = body.replacementFor() + /** + * Card state substatus values for the card that this card will replace: + * - `LOST` - The physical card is no longer in the cardholder's possession due to being lost or + * never received by the cardholder. + * - `COMPROMISED` - Card information has been exposed, potentially leading to unauthorized + * access. This may involve physical card theft, cloning, or online data breaches. + * - `DAMAGED` - The physical card is not functioning properly, such as having chip failures or + * a demagnetized magnetic stripe. + * - `END_USER_REQUEST` - The cardholder requested the closure of the card for reasons unrelated + * to fraud or damage, such as switching to a different product or closing the account. + * - `ISSUER_REQUEST` - The issuer closed the card for reasons unrelated to fraud or damage, + * such as account inactivity, product or policy changes, or technology upgrades. + * - `NOT_ACTIVE` - The card hasn’t had any transaction activity for a specified period, + * applicable to statuses like `PAUSED` or `CLOSED`. + * - `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious transactions or activities that + * require review. This can involve prompting the cardholder to confirm legitimate use or + * report confirmed fraud. + * - `INTERNAL_REVIEW` - The card is temporarily paused pending further internal review. + * - `EXPIRED` - The card has expired and has been closed without being reissued. + * - `UNDELIVERABLE` - The card cannot be delivered to the cardholder and has been returned. + * - `OTHER` - The reason for the status does not fall into any of the above categories. A + * comment should be provided to specify the reason. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacementSubstatus(): Optional = body.replacementSubstatus() + /** * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -298,6 +334,14 @@ private constructor( */ fun _replacementAccountToken(): JsonField = body._replacementAccountToken() + /** + * Returns the raw JSON value of [replacementComment]. + * + * Unlike [replacementComment], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _replacementComment(): JsonField = body._replacementComment() + /** * Returns the raw JSON value of [replacementFor]. * @@ -305,6 +349,14 @@ private constructor( */ fun _replacementFor(): JsonField = body._replacementFor() + /** + * Returns the raw JSON value of [replacementSubstatus]. + * + * Unlike [replacementSubstatus], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _replacementSubstatus(): JsonField = body._replacementSubstatus() + /** * Returns the raw JSON value of [shippingAddress]. * @@ -578,6 +630,22 @@ private constructor( body.replacementAccountToken(replacementAccountToken) } + /** Additional context or information related to the card that this card will replace. */ + fun replacementComment(replacementComment: String) = apply { + body.replacementComment(replacementComment) + } + + /** + * Sets [Builder.replacementComment] to an arbitrary JSON value. + * + * You should usually call [Builder.replacementComment] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacementComment(replacementComment: JsonField) = apply { + body.replacementComment(replacementComment) + } + /** * 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 @@ -596,6 +664,45 @@ private constructor( body.replacementFor(replacementFor) } + /** + * Card state substatus values for the card that this card will replace: + * - `LOST` - The physical card is no longer in the cardholder's possession due to being + * lost or never received by the cardholder. + * - `COMPROMISED` - Card information has been exposed, potentially leading to unauthorized + * access. This may involve physical card theft, cloning, or online data breaches. + * - `DAMAGED` - The physical card is not functioning properly, such as having chip failures + * or a demagnetized magnetic stripe. + * - `END_USER_REQUEST` - The cardholder requested the closure of the card for reasons + * unrelated to fraud or damage, such as switching to a different product or closing the + * account. + * - `ISSUER_REQUEST` - The issuer closed the card for reasons unrelated to fraud or damage, + * such as account inactivity, product or policy changes, or technology upgrades. + * - `NOT_ACTIVE` - The card hasn’t had any transaction activity for a specified period, + * applicable to statuses like `PAUSED` or `CLOSED`. + * - `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious transactions or activities + * that require review. This can involve prompting the cardholder to confirm legitimate + * use or report confirmed fraud. + * - `INTERNAL_REVIEW` - The card is temporarily paused pending further internal review. + * - `EXPIRED` - The card has expired and has been closed without being reissued. + * - `UNDELIVERABLE` - The card cannot be delivered to the cardholder and has been returned. + * - `OTHER` - The reason for the status does not fall into any of the above categories. A + * comment should be provided to specify the reason. + */ + fun replacementSubstatus(replacementSubstatus: ReplacementSubstatus) = apply { + body.replacementSubstatus(replacementSubstatus) + } + + /** + * Sets [Builder.replacementSubstatus] to an arbitrary JSON value. + * + * You should usually call [Builder.replacementSubstatus] with a well-typed + * [ReplacementSubstatus] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun replacementSubstatus(replacementSubstatus: JsonField) = apply { + body.replacementSubstatus(replacementSubstatus) + } + fun shippingAddress(shippingAddress: ShippingAddress) = apply { body.shippingAddress(shippingAddress) } @@ -850,7 +957,9 @@ private constructor( private val pin: JsonField, private val productId: JsonField, private val replacementAccountToken: JsonField, + private val replacementComment: JsonField, private val replacementFor: JsonField, + private val replacementSubstatus: JsonField, private val shippingAddress: JsonField, private val shippingMethod: JsonField, private val spendLimit: JsonField, @@ -884,9 +993,15 @@ private constructor( @JsonProperty("replacement_account_token") @ExcludeMissing replacementAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("replacement_comment") + @ExcludeMissing + replacementComment: JsonField = JsonMissing.of(), @JsonProperty("replacement_for") @ExcludeMissing replacementFor: JsonField = JsonMissing.of(), + @JsonProperty("replacement_substatus") + @ExcludeMissing + replacementSubstatus: JsonField = JsonMissing.of(), @JsonProperty("shipping_address") @ExcludeMissing shippingAddress: JsonField = JsonMissing.of(), @@ -912,7 +1027,9 @@ private constructor( pin, productId, replacementAccountToken, + replacementComment, replacementFor, + replacementSubstatus, shippingAddress, shippingMethod, spendLimit, @@ -1041,6 +1158,15 @@ private constructor( fun replacementAccountToken(): Optional = replacementAccountToken.getOptional("replacement_account_token") + /** + * Additional context or information related to the card that this card will replace. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacementComment(): Optional = + replacementComment.getOptional("replacement_comment") + /** * 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 @@ -1051,6 +1177,36 @@ private constructor( */ fun replacementFor(): Optional = replacementFor.getOptional("replacement_for") + /** + * Card state substatus values for the card that this card will replace: + * - `LOST` - The physical card is no longer in the cardholder's possession due to being + * lost or never received by the cardholder. + * - `COMPROMISED` - Card information has been exposed, potentially leading to unauthorized + * access. This may involve physical card theft, cloning, or online data breaches. + * - `DAMAGED` - The physical card is not functioning properly, such as having chip failures + * or a demagnetized magnetic stripe. + * - `END_USER_REQUEST` - The cardholder requested the closure of the card for reasons + * unrelated to fraud or damage, such as switching to a different product or closing the + * account. + * - `ISSUER_REQUEST` - The issuer closed the card for reasons unrelated to fraud or damage, + * such as account inactivity, product or policy changes, or technology upgrades. + * - `NOT_ACTIVE` - The card hasn’t had any transaction activity for a specified period, + * applicable to statuses like `PAUSED` or `CLOSED`. + * - `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious transactions or activities + * that require review. This can involve prompting the cardholder to confirm legitimate + * use or report confirmed fraud. + * - `INTERNAL_REVIEW` - The card is temporarily paused pending further internal review. + * - `EXPIRED` - The card has expired and has been closed without being reissued. + * - `UNDELIVERABLE` - The card cannot be delivered to the cardholder and has been returned. + * - `OTHER` - The reason for the status does not fall into any of the above categories. A + * comment should be provided to specify the reason. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacementSubstatus(): Optional = + replacementSubstatus.getOptional("replacement_substatus") + /** * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1206,6 +1362,16 @@ private constructor( @ExcludeMissing fun _replacementAccountToken(): JsonField = replacementAccountToken + /** + * Returns the raw JSON value of [replacementComment]. + * + * Unlike [replacementComment], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replacement_comment") + @ExcludeMissing + fun _replacementComment(): JsonField = replacementComment + /** * Returns the raw JSON value of [replacementFor]. * @@ -1216,6 +1382,16 @@ private constructor( @ExcludeMissing fun _replacementFor(): JsonField = replacementFor + /** + * Returns the raw JSON value of [replacementSubstatus]. + * + * Unlike [replacementSubstatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("replacement_substatus") + @ExcludeMissing + fun _replacementSubstatus(): JsonField = replacementSubstatus + /** * Returns the raw JSON value of [shippingAddress]. * @@ -1299,7 +1475,9 @@ private constructor( private var pin: JsonField = JsonMissing.of() private var productId: JsonField = JsonMissing.of() private var replacementAccountToken: JsonField = JsonMissing.of() + private var replacementComment: JsonField = JsonMissing.of() private var replacementFor: JsonField = JsonMissing.of() + private var replacementSubstatus: JsonField = JsonMissing.of() private var shippingAddress: JsonField = JsonMissing.of() private var shippingMethod: JsonField = JsonMissing.of() private var spendLimit: JsonField = JsonMissing.of() @@ -1320,7 +1498,9 @@ private constructor( pin = body.pin productId = body.productId replacementAccountToken = body.replacementAccountToken + replacementComment = body.replacementComment replacementFor = body.replacementFor + replacementSubstatus = body.replacementSubstatus shippingAddress = body.shippingAddress shippingMethod = body.shippingMethod spendLimit = body.spendLimit @@ -1521,6 +1701,23 @@ private constructor( this.replacementAccountToken = replacementAccountToken } + /** + * Additional context or information related to the card that this card will replace. + */ + fun replacementComment(replacementComment: String) = + replacementComment(JsonField.of(replacementComment)) + + /** + * Sets [Builder.replacementComment] to an arbitrary JSON value. + * + * You should usually call [Builder.replacementComment] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacementComment(replacementComment: JsonField) = apply { + this.replacementComment = replacementComment + } + /** * 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` @@ -1540,6 +1737,48 @@ private constructor( this.replacementFor = replacementFor } + /** + * Card state substatus values for the card that this card will replace: + * - `LOST` - The physical card is no longer in the cardholder's possession due to being + * lost or never received by the cardholder. + * - `COMPROMISED` - Card information has been exposed, potentially leading to + * unauthorized access. This may involve physical card theft, cloning, or online data + * breaches. + * - `DAMAGED` - The physical card is not functioning properly, such as having chip + * failures or a demagnetized magnetic stripe. + * - `END_USER_REQUEST` - The cardholder requested the closure of the card for reasons + * unrelated to fraud or damage, such as switching to a different product or closing + * the account. + * - `ISSUER_REQUEST` - The issuer closed the card for reasons unrelated to fraud or + * damage, such as account inactivity, product or policy changes, or technology + * upgrades. + * - `NOT_ACTIVE` - The card hasn’t had any transaction activity for a specified period, + * applicable to statuses like `PAUSED` or `CLOSED`. + * - `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious transactions or + * activities that require review. This can involve prompting the cardholder to + * confirm legitimate use or report confirmed fraud. + * - `INTERNAL_REVIEW` - The card is temporarily paused pending further internal review. + * - `EXPIRED` - The card has expired and has been closed without being reissued. + * - `UNDELIVERABLE` - The card cannot be delivered to the cardholder and has been + * returned. + * - `OTHER` - The reason for the status does not fall into any of the above categories. + * A comment should be provided to specify the reason. + */ + fun replacementSubstatus(replacementSubstatus: ReplacementSubstatus) = + replacementSubstatus(JsonField.of(replacementSubstatus)) + + /** + * Sets [Builder.replacementSubstatus] to an arbitrary JSON value. + * + * You should usually call [Builder.replacementSubstatus] with a well-typed + * [ReplacementSubstatus] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun replacementSubstatus(replacementSubstatus: JsonField) = + apply { + this.replacementSubstatus = replacementSubstatus + } + fun shippingAddress(shippingAddress: ShippingAddress) = shippingAddress(JsonField.of(shippingAddress)) @@ -1688,7 +1927,9 @@ private constructor( pin, productId, replacementAccountToken, + replacementComment, replacementFor, + replacementSubstatus, shippingAddress, shippingMethod, spendLimit, @@ -1716,7 +1957,9 @@ private constructor( pin() productId() replacementAccountToken() + replacementComment() replacementFor() + replacementSubstatus().ifPresent { it.validate() } shippingAddress().ifPresent { it.validate() } shippingMethod().ifPresent { it.validate() } spendLimit() @@ -1752,7 +1995,9 @@ private constructor( (if (pin.asKnown().isPresent) 1 else 0) + (if (productId.asKnown().isPresent) 1 else 0) + (if (replacementAccountToken.asKnown().isPresent) 1 else 0) + + (if (replacementComment.asKnown().isPresent) 1 else 0) + (if (replacementFor.asKnown().isPresent) 1 else 0) + + (replacementSubstatus.asKnown().getOrNull()?.validity() ?: 0) + (shippingAddress.asKnown().getOrNull()?.validity() ?: 0) + (shippingMethod.asKnown().getOrNull()?.validity() ?: 0) + (if (spendLimit.asKnown().isPresent) 1 else 0) + @@ -1764,17 +2009,17 @@ private constructor( return true } - return /* spotless:off */ other is Body && type == other.type && accountToken == other.accountToken && cardProgramToken == other.cardProgramToken && carrier == other.carrier && digitalCardArtToken == other.digitalCardArtToken && expMonth == other.expMonth && expYear == other.expYear && memo == other.memo && pin == other.pin && productId == other.productId && replacementAccountToken == other.replacementAccountToken && replacementFor == other.replacementFor && shippingAddress == other.shippingAddress && shippingMethod == other.shippingMethod && spendLimit == other.spendLimit && spendLimitDuration == other.spendLimitDuration && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && type == other.type && accountToken == other.accountToken && cardProgramToken == other.cardProgramToken && carrier == other.carrier && digitalCardArtToken == other.digitalCardArtToken && expMonth == other.expMonth && expYear == other.expYear && memo == other.memo && pin == other.pin && productId == other.productId && replacementAccountToken == other.replacementAccountToken && replacementComment == other.replacementComment && replacementFor == other.replacementFor && replacementSubstatus == other.replacementSubstatus && shippingAddress == other.shippingAddress && shippingMethod == other.shippingMethod && spendLimit == other.spendLimit && spendLimitDuration == other.spendLimitDuration && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, accountToken, cardProgramToken, carrier, digitalCardArtToken, expMonth, expYear, memo, pin, productId, replacementAccountToken, replacementFor, shippingAddress, shippingMethod, spendLimit, spendLimitDuration, state, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(type, accountToken, cardProgramToken, carrier, digitalCardArtToken, expMonth, expYear, memo, pin, productId, replacementAccountToken, replacementComment, replacementFor, replacementSubstatus, shippingAddress, shippingMethod, spendLimit, spendLimitDuration, state, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Body{type=$type, accountToken=$accountToken, cardProgramToken=$cardProgramToken, carrier=$carrier, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, memo=$memo, pin=$pin, productId=$productId, replacementAccountToken=$replacementAccountToken, replacementFor=$replacementFor, shippingAddress=$shippingAddress, shippingMethod=$shippingMethod, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, additionalProperties=$additionalProperties}" + "Body{type=$type, accountToken=$accountToken, cardProgramToken=$cardProgramToken, carrier=$carrier, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, memo=$memo, pin=$pin, productId=$productId, replacementAccountToken=$replacementAccountToken, replacementComment=$replacementComment, replacementFor=$replacementFor, replacementSubstatus=$replacementSubstatus, shippingAddress=$shippingAddress, shippingMethod=$shippingMethod, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, additionalProperties=$additionalProperties}" } /** @@ -1940,6 +2185,214 @@ private constructor( override fun toString() = value.toString() } + /** + * Card state substatus values for the card that this card will replace: + * - `LOST` - The physical card is no longer in the cardholder's possession due to being lost or + * never received by the cardholder. + * - `COMPROMISED` - Card information has been exposed, potentially leading to unauthorized + * access. This may involve physical card theft, cloning, or online data breaches. + * - `DAMAGED` - The physical card is not functioning properly, such as having chip failures or + * a demagnetized magnetic stripe. + * - `END_USER_REQUEST` - The cardholder requested the closure of the card for reasons unrelated + * to fraud or damage, such as switching to a different product or closing the account. + * - `ISSUER_REQUEST` - The issuer closed the card for reasons unrelated to fraud or damage, + * such as account inactivity, product or policy changes, or technology upgrades. + * - `NOT_ACTIVE` - The card hasn’t had any transaction activity for a specified period, + * applicable to statuses like `PAUSED` or `CLOSED`. + * - `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious transactions or activities that + * require review. This can involve prompting the cardholder to confirm legitimate use or + * report confirmed fraud. + * - `INTERNAL_REVIEW` - The card is temporarily paused pending further internal review. + * - `EXPIRED` - The card has expired and has been closed without being reissued. + * - `UNDELIVERABLE` - The card cannot be delivered to the cardholder and has been returned. + * - `OTHER` - The reason for the status does not fall into any of the above categories. A + * comment should be provided to specify the reason. + */ + class ReplacementSubstatus + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LOST = of("LOST") + + @JvmField val COMPROMISED = of("COMPROMISED") + + @JvmField val DAMAGED = of("DAMAGED") + + @JvmField val END_USER_REQUEST = of("END_USER_REQUEST") + + @JvmField val ISSUER_REQUEST = of("ISSUER_REQUEST") + + @JvmField val NOT_ACTIVE = of("NOT_ACTIVE") + + @JvmField val SUSPICIOUS_ACTIVITY = of("SUSPICIOUS_ACTIVITY") + + @JvmField val INTERNAL_REVIEW = of("INTERNAL_REVIEW") + + @JvmField val EXPIRED = of("EXPIRED") + + @JvmField val UNDELIVERABLE = of("UNDELIVERABLE") + + @JvmField val OTHER = of("OTHER") + + @JvmStatic fun of(value: String) = ReplacementSubstatus(JsonField.of(value)) + } + + /** An enum containing [ReplacementSubstatus]'s known values. */ + enum class Known { + LOST, + COMPROMISED, + DAMAGED, + END_USER_REQUEST, + ISSUER_REQUEST, + NOT_ACTIVE, + SUSPICIOUS_ACTIVITY, + INTERNAL_REVIEW, + EXPIRED, + UNDELIVERABLE, + OTHER, + } + + /** + * An enum containing [ReplacementSubstatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReplacementSubstatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LOST, + COMPROMISED, + DAMAGED, + END_USER_REQUEST, + ISSUER_REQUEST, + NOT_ACTIVE, + SUSPICIOUS_ACTIVITY, + INTERNAL_REVIEW, + EXPIRED, + UNDELIVERABLE, + OTHER, + /** + * An enum member indicating that [ReplacementSubstatus] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LOST -> Value.LOST + COMPROMISED -> Value.COMPROMISED + DAMAGED -> Value.DAMAGED + END_USER_REQUEST -> Value.END_USER_REQUEST + ISSUER_REQUEST -> Value.ISSUER_REQUEST + NOT_ACTIVE -> Value.NOT_ACTIVE + SUSPICIOUS_ACTIVITY -> Value.SUSPICIOUS_ACTIVITY + INTERNAL_REVIEW -> Value.INTERNAL_REVIEW + EXPIRED -> Value.EXPIRED + UNDELIVERABLE -> Value.UNDELIVERABLE + OTHER -> Value.OTHER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LOST -> Known.LOST + COMPROMISED -> Known.COMPROMISED + DAMAGED -> Known.DAMAGED + END_USER_REQUEST -> Known.END_USER_REQUEST + ISSUER_REQUEST -> Known.ISSUER_REQUEST + NOT_ACTIVE -> Known.NOT_ACTIVE + SUSPICIOUS_ACTIVITY -> Known.SUSPICIOUS_ACTIVITY + INTERNAL_REVIEW -> Known.INTERNAL_REVIEW + EXPIRED -> Known.EXPIRED + UNDELIVERABLE -> Known.UNDELIVERABLE + OTHER -> Known.OTHER + else -> throw LithicInvalidDataException("Unknown ReplacementSubstatus: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): ReplacementSubstatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ReplacementSubstatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** * Shipping method for the card. Only applies to cards of type PHYSICAL. Use of options besides * `STANDARD` require additional permissions. diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardProgram.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardProgram.kt index 7fe71f0b5..41ad2b4dd 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardProgram.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardProgram.kt @@ -27,6 +27,7 @@ private constructor( private val name: JsonField, private val panRangeEnd: JsonField, private val panRangeStart: JsonField, + private val accountLevelManagementEnabled: JsonField, private val cardholderCurrency: JsonField, private val settlementCurrencies: JsonField>, private val additionalProperties: MutableMap, @@ -45,6 +46,9 @@ private constructor( @JsonProperty("pan_range_start") @ExcludeMissing panRangeStart: JsonField = JsonMissing.of(), + @JsonProperty("account_level_management_enabled") + @ExcludeMissing + accountLevelManagementEnabled: JsonField = JsonMissing.of(), @JsonProperty("cardholder_currency") @ExcludeMissing cardholderCurrency: JsonField = JsonMissing.of(), @@ -57,6 +61,7 @@ private constructor( name, panRangeEnd, panRangeStart, + accountLevelManagementEnabled, cardholderCurrency, settlementCurrencies, mutableMapOf(), @@ -102,6 +107,16 @@ private constructor( */ fun panRangeStart(): String = panRangeStart.getRequired("pan_range_start") + /** + * Whether the card program is participating in Account Level Management. Currently applicable + * to Visa card programs only. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountLevelManagementEnabled(): Optional = + accountLevelManagementEnabled.getOptional("account_level_management_enabled") + /** * 3-character alphabetic ISO 4217 code for the currency of the cardholder. * @@ -160,6 +175,16 @@ private constructor( @ExcludeMissing fun _panRangeStart(): JsonField = panRangeStart + /** + * Returns the raw JSON value of [accountLevelManagementEnabled]. + * + * Unlike [accountLevelManagementEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("account_level_management_enabled") + @ExcludeMissing + fun _accountLevelManagementEnabled(): JsonField = accountLevelManagementEnabled + /** * Returns the raw JSON value of [cardholderCurrency]. * @@ -217,6 +242,7 @@ private constructor( private var name: JsonField? = null private var panRangeEnd: JsonField? = null private var panRangeStart: JsonField? = null + private var accountLevelManagementEnabled: JsonField = JsonMissing.of() private var cardholderCurrency: JsonField = JsonMissing.of() private var settlementCurrencies: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -228,6 +254,7 @@ private constructor( name = cardProgram.name panRangeEnd = cardProgram.panRangeEnd panRangeStart = cardProgram.panRangeStart + accountLevelManagementEnabled = cardProgram.accountLevelManagementEnabled cardholderCurrency = cardProgram.cardholderCurrency settlementCurrencies = cardProgram.settlementCurrencies.map { it.toMutableList() } additionalProperties = cardProgram.additionalProperties.toMutableMap() @@ -293,6 +320,25 @@ private constructor( this.panRangeStart = panRangeStart } + /** + * Whether the card program is participating in Account Level Management. Currently + * applicable to Visa card programs only. + */ + fun accountLevelManagementEnabled(accountLevelManagementEnabled: Boolean) = + accountLevelManagementEnabled(JsonField.of(accountLevelManagementEnabled)) + + /** + * Sets [Builder.accountLevelManagementEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.accountLevelManagementEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun accountLevelManagementEnabled(accountLevelManagementEnabled: JsonField) = + apply { + this.accountLevelManagementEnabled = accountLevelManagementEnabled + } + /** 3-character alphabetic ISO 4217 code for the currency of the cardholder. */ fun cardholderCurrency(cardholderCurrency: String) = cardholderCurrency(JsonField.of(cardholderCurrency)) @@ -380,6 +426,7 @@ private constructor( checkRequired("name", name), checkRequired("panRangeEnd", panRangeEnd), checkRequired("panRangeStart", panRangeStart), + accountLevelManagementEnabled, cardholderCurrency, (settlementCurrencies ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), @@ -398,6 +445,7 @@ private constructor( name() panRangeEnd() panRangeStart() + accountLevelManagementEnabled() cardholderCurrency() settlementCurrencies() validated = true @@ -423,6 +471,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (panRangeEnd.asKnown().isPresent) 1 else 0) + (if (panRangeStart.asKnown().isPresent) 1 else 0) + + (if (accountLevelManagementEnabled.asKnown().isPresent) 1 else 0) + (if (cardholderCurrency.asKnown().isPresent) 1 else 0) + (settlementCurrencies.asKnown().getOrNull()?.size ?: 0) @@ -431,15 +480,15 @@ private constructor( return true } - return /* spotless:off */ other is CardProgram && token == other.token && created == other.created && name == other.name && panRangeEnd == other.panRangeEnd && panRangeStart == other.panRangeStart && cardholderCurrency == other.cardholderCurrency && settlementCurrencies == other.settlementCurrencies && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CardProgram && token == other.token && created == other.created && name == other.name && panRangeEnd == other.panRangeEnd && panRangeStart == other.panRangeStart && accountLevelManagementEnabled == other.accountLevelManagementEnabled && cardholderCurrency == other.cardholderCurrency && settlementCurrencies == other.settlementCurrencies && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(token, created, name, panRangeEnd, panRangeStart, cardholderCurrency, settlementCurrencies, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(token, created, name, panRangeEnd, panRangeStart, accountLevelManagementEnabled, cardholderCurrency, settlementCurrencies, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "CardProgram{token=$token, created=$created, name=$name, panRangeEnd=$panRangeEnd, panRangeStart=$panRangeStart, cardholderCurrency=$cardholderCurrency, settlementCurrencies=$settlementCurrencies, additionalProperties=$additionalProperties}" + "CardProgram{token=$token, created=$created, name=$name, panRangeEnd=$panRangeEnd, panRangeStart=$panRangeStart, accountLevelManagementEnabled=$accountLevelManagementEnabled, cardholderCurrency=$cardholderCurrency, settlementCurrencies=$settlementCurrencies, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardUpdateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardUpdateParams.kt index bea496442..60a9306ff 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardUpdateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardUpdateParams.kt @@ -35,6 +35,14 @@ private constructor( fun cardToken(): Optional = Optional.ofNullable(cardToken) + /** + * Additional context or information related to the card. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun comment(): Optional = body.comment() + /** * 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. @@ -54,6 +62,15 @@ private constructor( */ fun memo(): Optional = body.memo() + /** + * Globally unique identifier for the card's network program. Currently applicable to Visa cards + * participating in Account Level Management only. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkProgramToken(): Optional = body.networkProgramToken() + /** * Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and `VIRTUAL`. * Changing PIN also resets PIN status to `OK`. See @@ -111,6 +128,41 @@ private constructor( */ fun state(): Optional = body.state() + /** + * Card state substatus values: + * - `LOST` - The physical card is no longer in the cardholder's possession due to being lost or + * never received by the cardholder. + * - `COMPROMISED` - Card information has been exposed, potentially leading to unauthorized + * access. This may involve physical card theft, cloning, or online data breaches. + * - `DAMAGED` - The physical card is not functioning properly, such as having chip failures or + * a demagnetized magnetic stripe. + * - `END_USER_REQUEST` - The cardholder requested the closure of the card for reasons unrelated + * to fraud or damage, such as switching to a different product or closing the account. + * - `ISSUER_REQUEST` - The issuer closed the card for reasons unrelated to fraud or damage, + * such as account inactivity, product or policy changes, or technology upgrades. + * - `NOT_ACTIVE` - The card hasn’t had any transaction activity for a specified period, + * applicable to statuses like `PAUSED` or `CLOSED`. + * - `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious transactions or activities that + * require review. This can involve prompting the cardholder to confirm legitimate use or + * report confirmed fraud. + * - `INTERNAL_REVIEW` - The card is temporarily paused pending further internal review. + * - `EXPIRED` - The card has expired and has been closed without being reissued. + * - `UNDELIVERABLE` - The card cannot be delivered to the cardholder and has been returned. + * - `OTHER` - The reason for the status does not fall into any of the above categories. A + * comment should be provided to specify the reason. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun substatus(): Optional = body.substatus() + + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _comment(): JsonField = body._comment() + /** * Returns the raw JSON value of [digitalCardArtToken]. * @@ -126,6 +178,14 @@ private constructor( */ fun _memo(): JsonField = body._memo() + /** + * Returns the raw JSON value of [networkProgramToken]. + * + * Unlike [networkProgramToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _networkProgramToken(): JsonField = body._networkProgramToken() + /** * Returns the raw JSON value of [pin]. * @@ -162,6 +222,13 @@ private constructor( */ fun _state(): JsonField = body._state() + /** + * Returns the raw JSON value of [substatus]. + * + * Unlike [substatus], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _substatus(): JsonField = body._substatus() + fun _additionalBodyProperties(): Map = body._additionalProperties() fun _additionalHeaders(): Headers = additionalHeaders @@ -204,15 +271,26 @@ private constructor( * * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: + * - [comment] * - [digitalCardArtToken] * - [memo] + * - [networkProgramToken] * - [pin] - * - [pinStatus] - * - [spendLimit] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** Additional context or information related to the card. */ + fun comment(comment: String) = apply { body.comment(comment) } + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun comment(comment: JsonField) = apply { body.comment(comment) } + /** * 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 @@ -245,6 +323,25 @@ private constructor( */ fun memo(memo: JsonField) = apply { body.memo(memo) } + /** + * Globally unique identifier for the card's network program. Currently applicable to Visa + * cards participating in Account Level Management only. + */ + fun networkProgramToken(networkProgramToken: String) = apply { + body.networkProgramToken(networkProgramToken) + } + + /** + * Sets [Builder.networkProgramToken] to an arbitrary JSON value. + * + * You should usually call [Builder.networkProgramToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun networkProgramToken(networkProgramToken: JsonField) = apply { + body.networkProgramToken(networkProgramToken) + } + /** * Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and `VIRTUAL`. * Changing PIN also resets PIN status to `OK`. See @@ -335,6 +432,41 @@ private constructor( */ fun state(state: JsonField) = apply { body.state(state) } + /** + * Card state substatus values: + * - `LOST` - The physical card is no longer in the cardholder's possession due to being + * lost or never received by the cardholder. + * - `COMPROMISED` - Card information has been exposed, potentially leading to unauthorized + * access. This may involve physical card theft, cloning, or online data breaches. + * - `DAMAGED` - The physical card is not functioning properly, such as having chip failures + * or a demagnetized magnetic stripe. + * - `END_USER_REQUEST` - The cardholder requested the closure of the card for reasons + * unrelated to fraud or damage, such as switching to a different product or closing the + * account. + * - `ISSUER_REQUEST` - The issuer closed the card for reasons unrelated to fraud or damage, + * such as account inactivity, product or policy changes, or technology upgrades. + * - `NOT_ACTIVE` - The card hasn’t had any transaction activity for a specified period, + * applicable to statuses like `PAUSED` or `CLOSED`. + * - `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious transactions or activities + * that require review. This can involve prompting the cardholder to confirm legitimate + * use or report confirmed fraud. + * - `INTERNAL_REVIEW` - The card is temporarily paused pending further internal review. + * - `EXPIRED` - The card has expired and has been closed without being reissued. + * - `UNDELIVERABLE` - The card cannot be delivered to the cardholder and has been returned. + * - `OTHER` - The reason for the status does not fall into any of the above categories. A + * comment should be provided to specify the reason. + */ + fun substatus(substatus: Substatus) = apply { body.substatus(substatus) } + + /** + * Sets [Builder.substatus] to an arbitrary JSON value. + * + * You should usually call [Builder.substatus] with a well-typed [Substatus] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun substatus(substatus: JsonField) = apply { body.substatus(substatus) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -480,22 +612,29 @@ private constructor( class Body private constructor( + private val comment: JsonField, private val digitalCardArtToken: JsonField, private val memo: JsonField, + private val networkProgramToken: JsonField, private val pin: JsonField, private val pinStatus: JsonField, private val spendLimit: JsonField, private val spendLimitDuration: JsonField, private val state: JsonField, + private val substatus: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("comment") @ExcludeMissing comment: JsonField = JsonMissing.of(), @JsonProperty("digital_card_art_token") @ExcludeMissing digitalCardArtToken: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("network_program_token") + @ExcludeMissing + networkProgramToken: JsonField = JsonMissing.of(), @JsonProperty("pin") @ExcludeMissing pin: JsonField = JsonMissing.of(), @JsonProperty("pin_status") @ExcludeMissing @@ -507,17 +646,31 @@ private constructor( @ExcludeMissing spendLimitDuration: JsonField = JsonMissing.of(), @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), + @JsonProperty("substatus") + @ExcludeMissing + substatus: JsonField = JsonMissing.of(), ) : this( + comment, digitalCardArtToken, memo, + networkProgramToken, pin, pinStatus, spendLimit, spendLimitDuration, state, + substatus, mutableMapOf(), ) + /** + * Additional context or information related to the card. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun comment(): Optional = comment.getOptional("comment") + /** * 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 @@ -538,6 +691,16 @@ private constructor( */ fun memo(): Optional = memo.getOptional("memo") + /** + * Globally unique identifier for the card's network program. Currently applicable to Visa + * cards participating in Account Level Management only. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkProgramToken(): Optional = + networkProgramToken.getOptional("network_program_token") + /** * Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and `VIRTUAL`. * Changing PIN also resets PIN status to `OK`. See @@ -598,6 +761,42 @@ private constructor( */ fun state(): Optional = state.getOptional("state") + /** + * Card state substatus values: + * - `LOST` - The physical card is no longer in the cardholder's possession due to being + * lost or never received by the cardholder. + * - `COMPROMISED` - Card information has been exposed, potentially leading to unauthorized + * access. This may involve physical card theft, cloning, or online data breaches. + * - `DAMAGED` - The physical card is not functioning properly, such as having chip failures + * or a demagnetized magnetic stripe. + * - `END_USER_REQUEST` - The cardholder requested the closure of the card for reasons + * unrelated to fraud or damage, such as switching to a different product or closing the + * account. + * - `ISSUER_REQUEST` - The issuer closed the card for reasons unrelated to fraud or damage, + * such as account inactivity, product or policy changes, or technology upgrades. + * - `NOT_ACTIVE` - The card hasn’t had any transaction activity for a specified period, + * applicable to statuses like `PAUSED` or `CLOSED`. + * - `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious transactions or activities + * that require review. This can involve prompting the cardholder to confirm legitimate + * use or report confirmed fraud. + * - `INTERNAL_REVIEW` - The card is temporarily paused pending further internal review. + * - `EXPIRED` - The card has expired and has been closed without being reissued. + * - `UNDELIVERABLE` - The card cannot be delivered to the cardholder and has been returned. + * - `OTHER` - The reason for the status does not fall into any of the above categories. A + * comment should be provided to specify the reason. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun substatus(): Optional = substatus.getOptional("substatus") + + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment + /** * Returns the raw JSON value of [digitalCardArtToken]. * @@ -615,6 +814,16 @@ private constructor( */ @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + /** + * Returns the raw JSON value of [networkProgramToken]. + * + * Unlike [networkProgramToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("network_program_token") + @ExcludeMissing + fun _networkProgramToken(): JsonField = networkProgramToken + /** * Returns the raw JSON value of [pin]. * @@ -655,6 +864,15 @@ private constructor( */ @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + /** + * Returns the raw JSON value of [substatus]. + * + * Unlike [substatus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("substatus") + @ExcludeMissing + fun _substatus(): JsonField = substatus + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -676,27 +894,45 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var comment: JsonField = JsonMissing.of() private var digitalCardArtToken: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() + private var networkProgramToken: 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 substatus: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { + comment = body.comment digitalCardArtToken = body.digitalCardArtToken memo = body.memo + networkProgramToken = body.networkProgramToken pin = body.pin pinStatus = body.pinStatus spendLimit = body.spendLimit spendLimitDuration = body.spendLimitDuration state = body.state + substatus = body.substatus additionalProperties = body.additionalProperties.toMutableMap() } + /** Additional context or information related to the card. */ + fun comment(comment: String) = comment(JsonField.of(comment)) + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun comment(comment: JsonField) = apply { this.comment = comment } + /** * 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 @@ -729,6 +965,24 @@ private constructor( */ fun memo(memo: JsonField) = apply { this.memo = memo } + /** + * Globally unique identifier for the card's network program. Currently applicable to + * Visa cards participating in Account Level Management only. + */ + fun networkProgramToken(networkProgramToken: String) = + networkProgramToken(JsonField.of(networkProgramToken)) + + /** + * Sets [Builder.networkProgramToken] to an arbitrary JSON value. + * + * You should usually call [Builder.networkProgramToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun networkProgramToken(networkProgramToken: JsonField) = apply { + this.networkProgramToken = networkProgramToken + } + /** * Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and * `VIRTUAL`. Changing PIN also resets PIN status to `OK`. See @@ -824,6 +1078,44 @@ private constructor( */ fun state(state: JsonField) = apply { this.state = state } + /** + * Card state substatus values: + * - `LOST` - The physical card is no longer in the cardholder's possession due to being + * lost or never received by the cardholder. + * - `COMPROMISED` - Card information has been exposed, potentially leading to + * unauthorized access. This may involve physical card theft, cloning, or online data + * breaches. + * - `DAMAGED` - The physical card is not functioning properly, such as having chip + * failures or a demagnetized magnetic stripe. + * - `END_USER_REQUEST` - The cardholder requested the closure of the card for reasons + * unrelated to fraud or damage, such as switching to a different product or closing + * the account. + * - `ISSUER_REQUEST` - The issuer closed the card for reasons unrelated to fraud or + * damage, such as account inactivity, product or policy changes, or technology + * upgrades. + * - `NOT_ACTIVE` - The card hasn’t had any transaction activity for a specified period, + * applicable to statuses like `PAUSED` or `CLOSED`. + * - `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious transactions or + * activities that require review. This can involve prompting the cardholder to + * confirm legitimate use or report confirmed fraud. + * - `INTERNAL_REVIEW` - The card is temporarily paused pending further internal review. + * - `EXPIRED` - The card has expired and has been closed without being reissued. + * - `UNDELIVERABLE` - The card cannot be delivered to the cardholder and has been + * returned. + * - `OTHER` - The reason for the status does not fall into any of the above categories. + * A comment should be provided to specify the reason. + */ + fun substatus(substatus: Substatus) = substatus(JsonField.of(substatus)) + + /** + * Sets [Builder.substatus] to an arbitrary JSON value. + * + * You should usually call [Builder.substatus] with a well-typed [Substatus] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun substatus(substatus: JsonField) = apply { this.substatus = substatus } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -850,13 +1142,16 @@ private constructor( */ fun build(): Body = Body( + comment, digitalCardArtToken, memo, + networkProgramToken, pin, pinStatus, spendLimit, spendLimitDuration, state, + substatus, additionalProperties.toMutableMap(), ) } @@ -868,13 +1163,16 @@ private constructor( return@apply } + comment() digitalCardArtToken() memo() + networkProgramToken() pin() pinStatus().ifPresent { it.validate() } spendLimit() spendLimitDuration().ifPresent { it.validate() } state().ifPresent { it.validate() } + substatus().ifPresent { it.validate() } validated = true } @@ -894,30 +1192,33 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (digitalCardArtToken.asKnown().isPresent) 1 else 0) + + (if (comment.asKnown().isPresent) 1 else 0) + + (if (digitalCardArtToken.asKnown().isPresent) 1 else 0) + (if (memo.asKnown().isPresent) 1 else 0) + + (if (networkProgramToken.asKnown().isPresent) 1 else 0) + (if (pin.asKnown().isPresent) 1 else 0) + (pinStatus.asKnown().getOrNull()?.validity() ?: 0) + (if (spendLimit.asKnown().isPresent) 1 else 0) + (spendLimitDuration.asKnown().getOrNull()?.validity() ?: 0) + - (state.asKnown().getOrNull()?.validity() ?: 0) + (state.asKnown().getOrNull()?.validity() ?: 0) + + (substatus.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Body && digitalCardArtToken == other.digitalCardArtToken && memo == other.memo && pin == other.pin && pinStatus == other.pinStatus && spendLimit == other.spendLimit && spendLimitDuration == other.spendLimitDuration && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && comment == other.comment && digitalCardArtToken == other.digitalCardArtToken && memo == other.memo && networkProgramToken == other.networkProgramToken && pin == other.pin && pinStatus == other.pinStatus && spendLimit == other.spendLimit && spendLimitDuration == other.spendLimitDuration && state == other.state && substatus == other.substatus && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(digitalCardArtToken, memo, pin, pinStatus, spendLimit, spendLimitDuration, state, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(comment, digitalCardArtToken, memo, networkProgramToken, pin, pinStatus, spendLimit, spendLimitDuration, state, substatus, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Body{digitalCardArtToken=$digitalCardArtToken, memo=$memo, pin=$pin, pinStatus=$pinStatus, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, additionalProperties=$additionalProperties}" + "Body{comment=$comment, digitalCardArtToken=$digitalCardArtToken, memo=$memo, networkProgramToken=$networkProgramToken, pin=$pin, pinStatus=$pinStatus, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, substatus=$substatus, additionalProperties=$additionalProperties}" } /** @@ -1182,6 +1483,210 @@ private constructor( override fun toString() = value.toString() } + /** + * Card state substatus values: + * - `LOST` - The physical card is no longer in the cardholder's possession due to being lost or + * never received by the cardholder. + * - `COMPROMISED` - Card information has been exposed, potentially leading to unauthorized + * access. This may involve physical card theft, cloning, or online data breaches. + * - `DAMAGED` - The physical card is not functioning properly, such as having chip failures or + * a demagnetized magnetic stripe. + * - `END_USER_REQUEST` - The cardholder requested the closure of the card for reasons unrelated + * to fraud or damage, such as switching to a different product or closing the account. + * - `ISSUER_REQUEST` - The issuer closed the card for reasons unrelated to fraud or damage, + * such as account inactivity, product or policy changes, or technology upgrades. + * - `NOT_ACTIVE` - The card hasn’t had any transaction activity for a specified period, + * applicable to statuses like `PAUSED` or `CLOSED`. + * - `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious transactions or activities that + * require review. This can involve prompting the cardholder to confirm legitimate use or + * report confirmed fraud. + * - `INTERNAL_REVIEW` - The card is temporarily paused pending further internal review. + * - `EXPIRED` - The card has expired and has been closed without being reissued. + * - `UNDELIVERABLE` - The card cannot be delivered to the cardholder and has been returned. + * - `OTHER` - The reason for the status does not fall into any of the above categories. A + * comment should be provided to specify the reason. + */ + class Substatus @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LOST = of("LOST") + + @JvmField val COMPROMISED = of("COMPROMISED") + + @JvmField val DAMAGED = of("DAMAGED") + + @JvmField val END_USER_REQUEST = of("END_USER_REQUEST") + + @JvmField val ISSUER_REQUEST = of("ISSUER_REQUEST") + + @JvmField val NOT_ACTIVE = of("NOT_ACTIVE") + + @JvmField val SUSPICIOUS_ACTIVITY = of("SUSPICIOUS_ACTIVITY") + + @JvmField val INTERNAL_REVIEW = of("INTERNAL_REVIEW") + + @JvmField val EXPIRED = of("EXPIRED") + + @JvmField val UNDELIVERABLE = of("UNDELIVERABLE") + + @JvmField val OTHER = of("OTHER") + + @JvmStatic fun of(value: String) = Substatus(JsonField.of(value)) + } + + /** An enum containing [Substatus]'s known values. */ + enum class Known { + LOST, + COMPROMISED, + DAMAGED, + END_USER_REQUEST, + ISSUER_REQUEST, + NOT_ACTIVE, + SUSPICIOUS_ACTIVITY, + INTERNAL_REVIEW, + EXPIRED, + UNDELIVERABLE, + OTHER, + } + + /** + * An enum containing [Substatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Substatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LOST, + COMPROMISED, + DAMAGED, + END_USER_REQUEST, + ISSUER_REQUEST, + NOT_ACTIVE, + SUSPICIOUS_ACTIVITY, + INTERNAL_REVIEW, + EXPIRED, + UNDELIVERABLE, + OTHER, + /** + * An enum member indicating that [Substatus] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LOST -> Value.LOST + COMPROMISED -> Value.COMPROMISED + DAMAGED -> Value.DAMAGED + END_USER_REQUEST -> Value.END_USER_REQUEST + ISSUER_REQUEST -> Value.ISSUER_REQUEST + NOT_ACTIVE -> Value.NOT_ACTIVE + SUSPICIOUS_ACTIVITY -> Value.SUSPICIOUS_ACTIVITY + INTERNAL_REVIEW -> Value.INTERNAL_REVIEW + EXPIRED -> Value.EXPIRED + UNDELIVERABLE -> Value.UNDELIVERABLE + OTHER -> Value.OTHER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LOST -> Known.LOST + COMPROMISED -> Known.COMPROMISED + DAMAGED -> Known.DAMAGED + END_USER_REQUEST -> Known.END_USER_REQUEST + ISSUER_REQUEST -> Known.ISSUER_REQUEST + NOT_ACTIVE -> Known.NOT_ACTIVE + SUSPICIOUS_ACTIVITY -> Known.SUSPICIOUS_ACTIVITY + INTERNAL_REVIEW -> Known.INTERNAL_REVIEW + EXPIRED -> Known.EXPIRED + UNDELIVERABLE -> Known.UNDELIVERABLE + OTHER -> Known.OTHER + else -> throw LithicInvalidDataException("Unknown Substatus: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Substatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Substatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Conditional3dsActionParameters.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Conditional3dsActionParameters.kt index 7d53bd088..0648ba26d 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Conditional3dsActionParameters.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Conditional3dsActionParameters.kt @@ -385,10 +385,8 @@ private constructor( * 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 - * authentication. 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. + * - `RISK_SCORE`: Mastercard only: Assessment by the network of the authentication risk + * level, with a higher value indicating a higher amount of risk. * - `MESSAGE_CATEGORY`: The category of the authentication being processed. * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -489,11 +487,8 @@ private constructor( * 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 - * authentication. 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. + * - `RISK_SCORE`: Mastercard only: Assessment by the network of the authentication risk + * level, with a higher value indicating a higher amount of risk. * - `MESSAGE_CATEGORY`: The category of the authentication being processed. */ fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) @@ -618,10 +613,8 @@ private constructor( * 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 - * authentication. 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. + * - `RISK_SCORE`: Mastercard only: Assessment by the network of the authentication risk + * level, with a higher value indicating a higher amount of risk. * - `MESSAGE_CATEGORY`: The category of the authentication being processed. */ class Attribute @JsonCreator private constructor(private val value: JsonField) : diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalResource.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalResource.kt new file mode 100644 index 000000000..ff163ef57 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalResource.kt @@ -0,0 +1,275 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.checkRequired +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** External resource associated with the management operation */ +class ExternalResource +private constructor( + private val externalResourceToken: JsonField, + private val externalResourceType: JsonField, + private val externalResourceSubToken: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("external_resource_token") + @ExcludeMissing + externalResourceToken: JsonField = JsonMissing.of(), + @JsonProperty("external_resource_type") + @ExcludeMissing + externalResourceType: JsonField = JsonMissing.of(), + @JsonProperty("external_resource_sub_token") + @ExcludeMissing + externalResourceSubToken: JsonField = JsonMissing.of(), + ) : this(externalResourceToken, externalResourceType, externalResourceSubToken, mutableMapOf()) + + /** + * Token identifying the external resource + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalResourceToken(): String = + externalResourceToken.getRequired("external_resource_token") + + /** + * Type of external resource associated with the management operation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun externalResourceType(): ExternalResourceType = + externalResourceType.getRequired("external_resource_type") + + /** + * Token identifying the external resource sub-resource + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalResourceSubToken(): Optional = + externalResourceSubToken.getOptional("external_resource_sub_token") + + /** + * Returns the raw JSON value of [externalResourceToken]. + * + * Unlike [externalResourceToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_resource_token") + @ExcludeMissing + fun _externalResourceToken(): JsonField = externalResourceToken + + /** + * Returns the raw JSON value of [externalResourceType]. + * + * Unlike [externalResourceType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_resource_type") + @ExcludeMissing + fun _externalResourceType(): JsonField = externalResourceType + + /** + * Returns the raw JSON value of [externalResourceSubToken]. + * + * Unlike [externalResourceSubToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_resource_sub_token") + @ExcludeMissing + fun _externalResourceSubToken(): JsonField = externalResourceSubToken + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ExternalResource]. + * + * The following fields are required: + * ```java + * .externalResourceToken() + * .externalResourceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExternalResource]. */ + class Builder internal constructor() { + + private var externalResourceToken: JsonField? = null + private var externalResourceType: JsonField? = null + private var externalResourceSubToken: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalResource: ExternalResource) = apply { + externalResourceToken = externalResource.externalResourceToken + externalResourceType = externalResource.externalResourceType + externalResourceSubToken = externalResource.externalResourceSubToken + additionalProperties = externalResource.additionalProperties.toMutableMap() + } + + /** Token identifying the external resource */ + fun externalResourceToken(externalResourceToken: String) = + externalResourceToken(JsonField.of(externalResourceToken)) + + /** + * Sets [Builder.externalResourceToken] to an arbitrary JSON value. + * + * You should usually call [Builder.externalResourceToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalResourceToken(externalResourceToken: JsonField) = apply { + this.externalResourceToken = externalResourceToken + } + + /** Type of external resource associated with the management operation */ + fun externalResourceType(externalResourceType: ExternalResourceType) = + externalResourceType(JsonField.of(externalResourceType)) + + /** + * Sets [Builder.externalResourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.externalResourceType] with a well-typed + * [ExternalResourceType] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun externalResourceType(externalResourceType: JsonField) = apply { + this.externalResourceType = externalResourceType + } + + /** Token identifying the external resource sub-resource */ + fun externalResourceSubToken(externalResourceSubToken: String) = + externalResourceSubToken(JsonField.of(externalResourceSubToken)) + + /** + * Sets [Builder.externalResourceSubToken] to an arbitrary JSON value. + * + * You should usually call [Builder.externalResourceSubToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun externalResourceSubToken(externalResourceSubToken: JsonField) = apply { + this.externalResourceSubToken = externalResourceSubToken + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ExternalResource]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .externalResourceToken() + * .externalResourceType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExternalResource = + ExternalResource( + checkRequired("externalResourceToken", externalResourceToken), + checkRequired("externalResourceType", externalResourceType), + externalResourceSubToken, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExternalResource = apply { + if (validated) { + return@apply + } + + externalResourceToken() + externalResourceType().validate() + externalResourceSubToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (externalResourceToken.asKnown().isPresent) 1 else 0) + + (externalResourceType.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalResourceSubToken.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExternalResource && externalResourceToken == other.externalResourceToken && externalResourceType == other.externalResourceType && externalResourceSubToken == other.externalResourceSubToken && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(externalResourceToken, externalResourceType, externalResourceSubToken, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExternalResource{externalResourceToken=$externalResourceToken, externalResourceType=$externalResourceType, externalResourceSubToken=$externalResourceSubToken, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalResourceType.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalResourceType.kt new file mode 100644 index 000000000..c85cbcdc3 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalResourceType.kt @@ -0,0 +1,147 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonCreator +import com.lithic.api.core.Enum +import com.lithic.api.core.JsonField +import com.lithic.api.errors.LithicInvalidDataException + +/** Type of external resource associated with the management operation */ +class ExternalResourceType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val STATEMENT = of("STATEMENT") + + @JvmField val COLLECTION = of("COLLECTION") + + @JvmField val DISPUTE = of("DISPUTE") + + @JvmField val UNKNOWN = of("UNKNOWN") + + @JvmStatic fun of(value: String) = ExternalResourceType(JsonField.of(value)) + } + + /** An enum containing [ExternalResourceType]'s known values. */ + enum class Known { + STATEMENT, + COLLECTION, + DISPUTE, + UNKNOWN, + } + + /** + * An enum containing [ExternalResourceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ExternalResourceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + STATEMENT, + COLLECTION, + DISPUTE, + UNKNOWN, + /** + * An enum member indicating that [ExternalResourceType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + STATEMENT -> Value.STATEMENT + COLLECTION -> Value.COLLECTION + DISPUTE -> Value.DISPUTE + UNKNOWN -> Value.UNKNOWN + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + STATEMENT -> Known.STATEMENT + COLLECTION -> Known.COLLECTION + DISPUTE -> Known.DISPUTE + UNKNOWN -> Known.UNKNOWN + else -> throw LithicInvalidDataException("Unknown ExternalResourceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): ExternalResourceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ExternalResourceType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountListParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountListParams.kt index 803a368a7..b1e1b42b3 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountListParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountListParams.kt @@ -236,6 +236,8 @@ private constructor( @JvmField val RESERVE = of("RESERVE") + @JvmField val SECURITY = of("SECURITY") + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } @@ -244,6 +246,7 @@ private constructor( ISSUING, OPERATING, RESERVE, + SECURITY, } /** @@ -259,6 +262,7 @@ private constructor( ISSUING, OPERATING, RESERVE, + SECURITY, /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -275,6 +279,7 @@ private constructor( ISSUING -> Value.ISSUING OPERATING -> Value.OPERATING RESERVE -> Value.RESERVE + SECURITY -> Value.SECURITY else -> Value._UNKNOWN } @@ -292,6 +297,7 @@ private constructor( ISSUING -> Known.ISSUING OPERATING -> Known.OPERATING RESERVE -> Known.RESERVE + SECURITY -> Known.SECURITY else -> throw LithicInvalidDataException("Unknown Type: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreateParams.kt index f2fe8765d..9c69ce8dd 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreateParams.kt @@ -78,6 +78,14 @@ private constructor( */ fun memo(): Optional = body.memo() + /** + * What to do if the financial account is closed when posting an operation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun onClosedAccount(): Optional = body.onClosedAccount() + /** * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -147,6 +155,13 @@ private constructor( */ fun _memo(): JsonField = body._memo() + /** + * Returns the raw JSON value of [onClosedAccount]. + * + * Unlike [onClosedAccount], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _onClosedAccount(): JsonField = body._onClosedAccount() + /** * Returns the raw JSON value of [subtype]. * @@ -316,6 +331,22 @@ private constructor( */ fun memo(memo: JsonField) = apply { body.memo(memo) } + /** What to do if the financial account is closed when posting an operation */ + fun onClosedAccount(onClosedAccount: OnClosedAccount) = apply { + body.onClosedAccount(onClosedAccount) + } + + /** + * Sets [Builder.onClosedAccount] to an arbitrary JSON value. + * + * You should usually call [Builder.onClosedAccount] with a well-typed [OnClosedAccount] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun onClosedAccount(onClosedAccount: JsonField) = apply { + body.onClosedAccount(onClosedAccount) + } + fun subtype(subtype: String) = apply { body.subtype(subtype) } /** @@ -497,6 +528,7 @@ private constructor( private val financialAccountToken: JsonField, private val token: JsonField, private val memo: JsonField, + private val onClosedAccount: JsonField, private val subtype: JsonField, private val userDefinedId: JsonField, private val additionalProperties: MutableMap, @@ -522,6 +554,9 @@ private constructor( financialAccountToken: JsonField = JsonMissing.of(), @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("on_closed_account") + @ExcludeMissing + onClosedAccount: JsonField = JsonMissing.of(), @JsonProperty("subtype") @ExcludeMissing subtype: JsonField = JsonMissing.of(), @JsonProperty("user_defined_id") @ExcludeMissing @@ -535,6 +570,7 @@ private constructor( financialAccountToken, token, memo, + onClosedAccount, subtype, userDefinedId, mutableMapOf(), @@ -589,6 +625,15 @@ private constructor( */ fun memo(): Optional = memo.getOptional("memo") + /** + * What to do if the financial account is closed when posting an operation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun onClosedAccount(): Optional = + onClosedAccount.getOptional("on_closed_account") + /** * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -669,6 +714,16 @@ private constructor( */ @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + /** + * Returns the raw JSON value of [onClosedAccount]. + * + * Unlike [onClosedAccount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("on_closed_account") + @ExcludeMissing + fun _onClosedAccount(): JsonField = onClosedAccount + /** * Returns the raw JSON value of [subtype]. * @@ -728,6 +783,7 @@ private constructor( private var financialAccountToken: JsonField? = null private var token: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() + private var onClosedAccount: JsonField = JsonMissing.of() private var subtype: JsonField = JsonMissing.of() private var userDefinedId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -743,6 +799,7 @@ private constructor( financialAccountToken = createManagementOperationRequest.financialAccountToken token = createManagementOperationRequest.token memo = createManagementOperationRequest.memo + onClosedAccount = createManagementOperationRequest.onClosedAccount subtype = createManagementOperationRequest.subtype userDefinedId = createManagementOperationRequest.userDefinedId additionalProperties = @@ -850,6 +907,21 @@ private constructor( */ fun memo(memo: JsonField) = apply { this.memo = memo } + /** What to do if the financial account is closed when posting an operation */ + fun onClosedAccount(onClosedAccount: OnClosedAccount) = + onClosedAccount(JsonField.of(onClosedAccount)) + + /** + * Sets [Builder.onClosedAccount] to an arbitrary JSON value. + * + * You should usually call [Builder.onClosedAccount] with a well-typed [OnClosedAccount] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun onClosedAccount(onClosedAccount: JsonField) = apply { + this.onClosedAccount = onClosedAccount + } + fun subtype(subtype: String) = subtype(JsonField.of(subtype)) /** @@ -920,6 +992,7 @@ private constructor( checkRequired("financialAccountToken", financialAccountToken), token, memo, + onClosedAccount, subtype, userDefinedId, additionalProperties.toMutableMap(), @@ -941,6 +1014,7 @@ private constructor( financialAccountToken() token() memo() + onClosedAccount().ifPresent { it.validate() } subtype() userDefinedId() validated = true @@ -970,6 +1044,7 @@ private constructor( (if (financialAccountToken.asKnown().isPresent) 1 else 0) + (if (token.asKnown().isPresent) 1 else 0) + (if (memo.asKnown().isPresent) 1 else 0) + + (onClosedAccount.asKnown().getOrNull()?.validity() ?: 0) + (if (subtype.asKnown().isPresent) 1 else 0) + (if (userDefinedId.asKnown().isPresent) 1 else 0) @@ -978,17 +1053,17 @@ private constructor( return true } - return /* spotless:off */ other is CreateManagementOperationRequest && amount == other.amount && category == other.category && direction == other.direction && effectiveDate == other.effectiveDate && eventType == other.eventType && financialAccountToken == other.financialAccountToken && token == other.token && memo == other.memo && subtype == other.subtype && userDefinedId == other.userDefinedId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CreateManagementOperationRequest && amount == other.amount && category == other.category && direction == other.direction && effectiveDate == other.effectiveDate && eventType == other.eventType && financialAccountToken == other.financialAccountToken && token == other.token && memo == other.memo && onClosedAccount == other.onClosedAccount && subtype == other.subtype && userDefinedId == other.userDefinedId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, category, direction, effectiveDate, eventType, financialAccountToken, token, memo, subtype, userDefinedId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(amount, category, direction, effectiveDate, eventType, financialAccountToken, token, memo, onClosedAccount, subtype, userDefinedId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "CreateManagementOperationRequest{amount=$amount, category=$category, direction=$direction, effectiveDate=$effectiveDate, eventType=$eventType, financialAccountToken=$financialAccountToken, token=$token, memo=$memo, subtype=$subtype, userDefinedId=$userDefinedId, additionalProperties=$additionalProperties}" + "CreateManagementOperationRequest{amount=$amount, category=$category, direction=$direction, effectiveDate=$effectiveDate, eventType=$eventType, financialAccountToken=$financialAccountToken, token=$token, memo=$memo, onClosedAccount=$onClosedAccount, subtype=$subtype, userDefinedId=$userDefinedId, additionalProperties=$additionalProperties}" } class ManagementOperationCategory @@ -1510,6 +1585,136 @@ private constructor( override fun toString() = value.toString() } + /** What to do if the financial account is closed when posting an operation */ + class OnClosedAccount @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val FAIL = of("FAIL") + + @JvmField val USE_SUSPENSE = of("USE_SUSPENSE") + + @JvmStatic fun of(value: String) = OnClosedAccount(JsonField.of(value)) + } + + /** An enum containing [OnClosedAccount]'s known values. */ + enum class Known { + FAIL, + USE_SUSPENSE, + } + + /** + * An enum containing [OnClosedAccount]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [OnClosedAccount] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FAIL, + USE_SUSPENSE, + /** + * An enum member indicating that [OnClosedAccount] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FAIL -> Value.FAIL + USE_SUSPENSE -> Value.USE_SUSPENSE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FAIL -> Known.FAIL + USE_SUSPENSE -> Known.USE_SUSPENSE + else -> throw LithicInvalidDataException("Unknown OnClosedAccount: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): OnClosedAccount = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is OnClosedAccount && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt index aaa6ee269..5f343f3c6 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt @@ -37,6 +37,7 @@ private constructor( private val status: JsonField, private val transactionSeries: JsonField, private val updated: JsonField, + private val externalResource: JsonField, private val userDefinedId: JsonField, private val additionalProperties: MutableMap, ) { @@ -78,6 +79,9 @@ private constructor( @JsonProperty("updated") @ExcludeMissing updated: JsonField = JsonMissing.of(), + @JsonProperty("external_resource") + @ExcludeMissing + externalResource: JsonField = JsonMissing.of(), @JsonProperty("user_defined_id") @ExcludeMissing userDefinedId: JsonField = JsonMissing.of(), @@ -95,6 +99,7 @@ private constructor( status, transactionSeries, updated, + externalResource, userDefinedId, mutableMapOf(), ) @@ -179,6 +184,15 @@ private constructor( */ fun updated(): OffsetDateTime = updated.getRequired("updated") + /** + * External resource associated with the management operation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalResource(): Optional = + externalResource.getOptional("external_resource") + /** * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -292,6 +306,16 @@ private constructor( */ @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + /** + * Returns the raw JSON value of [externalResource]. + * + * Unlike [externalResource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_resource") + @ExcludeMissing + fun _externalResource(): JsonField = externalResource + /** * Returns the raw JSON value of [userDefinedId]. * @@ -355,6 +379,7 @@ private constructor( private var status: JsonField? = null private var transactionSeries: JsonField? = null private var updated: JsonField? = null + private var externalResource: JsonField = JsonMissing.of() private var userDefinedId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -373,6 +398,7 @@ private constructor( status = managementOperationTransaction.status transactionSeries = managementOperationTransaction.transactionSeries updated = managementOperationTransaction.updated + externalResource = managementOperationTransaction.externalResource userDefinedId = managementOperationTransaction.userDefinedId additionalProperties = managementOperationTransaction.additionalProperties.toMutableMap() @@ -551,6 +577,25 @@ private constructor( */ fun updated(updated: JsonField) = apply { this.updated = updated } + /** External resource associated with the management operation */ + fun externalResource(externalResource: ExternalResource?) = + externalResource(JsonField.ofNullable(externalResource)) + + /** Alias for calling [Builder.externalResource] with `externalResource.orElse(null)`. */ + fun externalResource(externalResource: Optional) = + externalResource(externalResource.getOrNull()) + + /** + * Sets [Builder.externalResource] to an arbitrary JSON value. + * + * You should usually call [Builder.externalResource] with a well-typed [ExternalResource] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun externalResource(externalResource: JsonField) = apply { + this.externalResource = externalResource + } + fun userDefinedId(userDefinedId: String) = userDefinedId(JsonField.of(userDefinedId)) /** @@ -622,6 +667,7 @@ private constructor( checkRequired("status", status), checkRequired("transactionSeries", transactionSeries), checkRequired("updated", updated), + externalResource, userDefinedId, additionalProperties.toMutableMap(), ) @@ -647,6 +693,7 @@ private constructor( status().validate() transactionSeries().ifPresent { it.validate() } updated() + externalResource().ifPresent { it.validate() } userDefinedId() validated = true } @@ -679,6 +726,7 @@ private constructor( (status.asKnown().getOrNull()?.validity() ?: 0) + (transactionSeries.asKnown().getOrNull()?.validity() ?: 0) + (if (updated.asKnown().isPresent) 1 else 0) + + (externalResource.asKnown().getOrNull()?.validity() ?: 0) + (if (userDefinedId.asKnown().isPresent) 1 else 0) class ManagementOperationCategory @@ -2467,15 +2515,15 @@ private constructor( return true } - return /* spotless:off */ other is ManagementOperationTransaction && token == other.token && category == other.category && created == other.created && currency == other.currency && direction == other.direction && events == other.events && financialAccountToken == other.financialAccountToken && pendingAmount == other.pendingAmount && result == other.result && settledAmount == other.settledAmount && status == other.status && transactionSeries == other.transactionSeries && updated == other.updated && userDefinedId == other.userDefinedId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ManagementOperationTransaction && token == other.token && category == other.category && created == other.created && currency == other.currency && direction == other.direction && events == other.events && financialAccountToken == other.financialAccountToken && pendingAmount == other.pendingAmount && result == other.result && settledAmount == other.settledAmount && status == other.status && transactionSeries == other.transactionSeries && updated == other.updated && externalResource == other.externalResource && userDefinedId == other.userDefinedId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(token, category, created, currency, direction, events, financialAccountToken, pendingAmount, result, settledAmount, status, transactionSeries, updated, userDefinedId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(token, category, created, currency, direction, events, financialAccountToken, pendingAmount, result, settledAmount, status, transactionSeries, updated, externalResource, userDefinedId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "ManagementOperationTransaction{token=$token, category=$category, created=$created, currency=$currency, direction=$direction, events=$events, financialAccountToken=$financialAccountToken, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, status=$status, transactionSeries=$transactionSeries, updated=$updated, userDefinedId=$userDefinedId, additionalProperties=$additionalProperties}" + "ManagementOperationTransaction{token=$token, category=$category, created=$created, currency=$currency, direction=$direction, events=$events, financialAccountToken=$financialAccountToken, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, status=$status, transactionSeries=$transactionSeries, updated=$updated, externalResource=$externalResource, userDefinedId=$userDefinedId, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgram.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgram.kt new file mode 100644 index 000000000..30a249e9d --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgram.kt @@ -0,0 +1,309 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.checkRequired +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Collections +import java.util.Objects + +class NetworkProgram +private constructor( + private val token: JsonField, + private val defaultProductCode: JsonField, + private val name: JsonField, + private val registeredProgramIdentificationNumber: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("default_product_code") + @ExcludeMissing + defaultProductCode: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("registered_program_identification_number") + @ExcludeMissing + registeredProgramIdentificationNumber: JsonField = JsonMissing.of(), + ) : this(token, defaultProductCode, name, registeredProgramIdentificationNumber, mutableMapOf()) + + /** + * Lithic-generated unique identifier for the program + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * Network product ID associated with this program. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun defaultProductCode(): String = defaultProductCode.getRequired("default_product_code") + + /** + * The name of the network program. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * RPIN value assigned by the network. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun registeredProgramIdentificationNumber(): String = + registeredProgramIdentificationNumber.getRequired( + "registered_program_identification_number" + ) + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [defaultProductCode]. + * + * Unlike [defaultProductCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_product_code") + @ExcludeMissing + fun _defaultProductCode(): JsonField = defaultProductCode + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [registeredProgramIdentificationNumber]. + * + * Unlike [registeredProgramIdentificationNumber], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("registered_program_identification_number") + @ExcludeMissing + fun _registeredProgramIdentificationNumber(): JsonField = + registeredProgramIdentificationNumber + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NetworkProgram]. + * + * The following fields are required: + * ```java + * .token() + * .defaultProductCode() + * .name() + * .registeredProgramIdentificationNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NetworkProgram]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var defaultProductCode: JsonField? = null + private var name: JsonField? = null + private var registeredProgramIdentificationNumber: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(networkProgram: NetworkProgram) = apply { + token = networkProgram.token + defaultProductCode = networkProgram.defaultProductCode + name = networkProgram.name + registeredProgramIdentificationNumber = + networkProgram.registeredProgramIdentificationNumber + additionalProperties = networkProgram.additionalProperties.toMutableMap() + } + + /** Lithic-generated unique identifier for the program */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Network product ID associated with this program. */ + fun defaultProductCode(defaultProductCode: String) = + defaultProductCode(JsonField.of(defaultProductCode)) + + /** + * Sets [Builder.defaultProductCode] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultProductCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun defaultProductCode(defaultProductCode: JsonField) = apply { + this.defaultProductCode = defaultProductCode + } + + /** The name of the network program. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** RPIN value assigned by the network. */ + fun registeredProgramIdentificationNumber(registeredProgramIdentificationNumber: String) = + registeredProgramIdentificationNumber( + JsonField.of(registeredProgramIdentificationNumber) + ) + + /** + * Sets [Builder.registeredProgramIdentificationNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.registeredProgramIdentificationNumber] with a well-typed + * [String] value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun registeredProgramIdentificationNumber( + registeredProgramIdentificationNumber: JsonField + ) = apply { + this.registeredProgramIdentificationNumber = registeredProgramIdentificationNumber + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [NetworkProgram]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .defaultProductCode() + * .name() + * .registeredProgramIdentificationNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NetworkProgram = + NetworkProgram( + checkRequired("token", token), + checkRequired("defaultProductCode", defaultProductCode), + checkRequired("name", name), + checkRequired( + "registeredProgramIdentificationNumber", + registeredProgramIdentificationNumber, + ), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NetworkProgram = apply { + if (validated) { + return@apply + } + + token() + defaultProductCode() + name() + registeredProgramIdentificationNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (token.asKnown().isPresent) 1 else 0) + + (if (defaultProductCode.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (registeredProgramIdentificationNumber.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NetworkProgram && token == other.token && defaultProductCode == other.defaultProductCode && name == other.name && registeredProgramIdentificationNumber == other.registeredProgramIdentificationNumber && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(token, defaultProductCode, name, registeredProgramIdentificationNumber, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NetworkProgram{token=$token, defaultProductCode=$defaultProductCode, name=$name, registeredProgramIdentificationNumber=$registeredProgramIdentificationNumber, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListPage.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListPage.kt new file mode 100644 index 000000000..b0ca240d2 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListPage.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.AutoPager +import com.lithic.api.core.Page +import com.lithic.api.core.checkRequired +import com.lithic.api.services.blocking.NetworkProgramService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see [NetworkProgramService.list] */ +class NetworkProgramListPage +private constructor( + private val service: NetworkProgramService, + private val params: NetworkProgramListParams, + private val response: NetworkProgramListPageResponse, +) : Page { + + /** + * Delegates to [NetworkProgramListPageResponse], but gracefully handles missing data. + * + * @see [NetworkProgramListPageResponse.data] + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [NetworkProgramListPageResponse], but gracefully handles missing data. + * + * @see [NetworkProgramListPageResponse.hasMore] + */ + fun hasMore(): Optional = response._hasMore().getOptional("has_more") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = false + + fun nextPageParams(): NetworkProgramListParams = + throw IllegalStateException("Cannot construct next page params") + + override fun nextPage(): NetworkProgramListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): NetworkProgramListParams = params + + /** The response that this page was parsed from. */ + fun response(): NetworkProgramListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NetworkProgramListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NetworkProgramListPage]. */ + class Builder internal constructor() { + + private var service: NetworkProgramService? = null + private var params: NetworkProgramListParams? = null + private var response: NetworkProgramListPageResponse? = null + + @JvmSynthetic + internal fun from(networkProgramListPage: NetworkProgramListPage) = apply { + service = networkProgramListPage.service + params = networkProgramListPage.params + response = networkProgramListPage.response + } + + fun service(service: NetworkProgramService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: NetworkProgramListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: NetworkProgramListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [NetworkProgramListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NetworkProgramListPage = + NetworkProgramListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NetworkProgramListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "NetworkProgramListPage{service=$service, params=$params, response=$response}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListPageAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListPageAsync.kt new file mode 100644 index 000000000..fce61ac76 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListPageAsync.kt @@ -0,0 +1,140 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.AutoPagerAsync +import com.lithic.api.core.PageAsync +import com.lithic.api.core.checkRequired +import com.lithic.api.services.async.NetworkProgramServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see [NetworkProgramServiceAsync.list] */ +class NetworkProgramListPageAsync +private constructor( + private val service: NetworkProgramServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: NetworkProgramListParams, + private val response: NetworkProgramListPageResponse, +) : PageAsync { + + /** + * Delegates to [NetworkProgramListPageResponse], but gracefully handles missing data. + * + * @see [NetworkProgramListPageResponse.data] + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [NetworkProgramListPageResponse], but gracefully handles missing data. + * + * @see [NetworkProgramListPageResponse.hasMore] + */ + fun hasMore(): Optional = response._hasMore().getOptional("has_more") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = false + + fun nextPageParams(): NetworkProgramListParams = + throw IllegalStateException("Cannot construct next page params") + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): NetworkProgramListParams = params + + /** The response that this page was parsed from. */ + fun response(): NetworkProgramListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NetworkProgramListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NetworkProgramListPageAsync]. */ + class Builder internal constructor() { + + private var service: NetworkProgramServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: NetworkProgramListParams? = null + private var response: NetworkProgramListPageResponse? = null + + @JvmSynthetic + internal fun from(networkProgramListPageAsync: NetworkProgramListPageAsync) = apply { + service = networkProgramListPageAsync.service + streamHandlerExecutor = networkProgramListPageAsync.streamHandlerExecutor + params = networkProgramListPageAsync.params + response = networkProgramListPageAsync.response + } + + fun service(service: NetworkProgramServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: NetworkProgramListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: NetworkProgramListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [NetworkProgramListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NetworkProgramListPageAsync = + NetworkProgramListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NetworkProgramListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ + + override fun toString() = + "NetworkProgramListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListPageResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListPageResponse.kt new file mode 100644 index 000000000..c8b9e533d --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListPageResponse.kt @@ -0,0 +1,228 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.checkKnown +import com.lithic.api.core.checkRequired +import com.lithic.api.core.toImmutable +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class NetworkProgramListPageResponse +private constructor( + private val data: JsonField>, + private val hasMore: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), + ) : this(data, hasMore, mutableMapOf()) + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): List = data.getRequired("data") + + /** + * Whether there are more network programs to be retrieved. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun hasMore(): Boolean = hasMore.getRequired("has_more") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [hasMore]. + * + * Unlike [hasMore], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NetworkProgramListPageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .hasMore() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NetworkProgramListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var hasMore: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(networkProgramListPageResponse: NetworkProgramListPageResponse) = apply { + data = networkProgramListPageResponse.data.map { it.toMutableList() } + hasMore = networkProgramListPageResponse.hasMore + additionalProperties = + networkProgramListPageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [NetworkProgram] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: NetworkProgram) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + /** Whether there are more network programs to be retrieved. */ + fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) + + /** + * Sets [Builder.hasMore] to an arbitrary JSON value. + * + * You should usually call [Builder.hasMore] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [NetworkProgramListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .hasMore() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NetworkProgramListPageResponse = + NetworkProgramListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("hasMore", hasMore), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NetworkProgramListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + hasMore() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hasMore.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NetworkProgramListPageResponse && data == other.data && hasMore == other.hasMore && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(data, hasMore, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NetworkProgramListPageResponse{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListParams.kt new file mode 100644 index 000000000..10e72b19e --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramListParams.kt @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.Params +import com.lithic.api.core.http.Headers +import com.lithic.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List network programs. */ +class NetworkProgramListParams +private constructor( + private val begin: OffsetDateTime?, + private val end: OffsetDateTime?, + private val pageSize: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Date string in RFC 3339 format. Only entries created after the specified time will be + * included. UTC time zone. + */ + fun begin(): Optional = Optional.ofNullable(begin) + + /** + * Date string in RFC 3339 format. Only entries created before the specified time will be + * included. UTC time zone. + */ + fun end(): Optional = Optional.ofNullable(end) + + /** Page size (for pagination). */ + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): NetworkProgramListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [NetworkProgramListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NetworkProgramListParams]. */ + class Builder internal constructor() { + + private var begin: OffsetDateTime? = null + private var end: OffsetDateTime? = null + private var pageSize: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(networkProgramListParams: NetworkProgramListParams) = apply { + begin = networkProgramListParams.begin + end = networkProgramListParams.end + pageSize = networkProgramListParams.pageSize + additionalHeaders = networkProgramListParams.additionalHeaders.toBuilder() + additionalQueryParams = networkProgramListParams.additionalQueryParams.toBuilder() + } + + /** + * Date string in RFC 3339 format. Only entries created after the specified time will be + * included. UTC time zone. + */ + fun begin(begin: OffsetDateTime?) = apply { this.begin = begin } + + /** Alias for calling [Builder.begin] with `begin.orElse(null)`. */ + fun begin(begin: Optional) = begin(begin.getOrNull()) + + /** + * Date string in RFC 3339 format. Only entries created before the specified time will be + * included. UTC time zone. + */ + fun end(end: OffsetDateTime?) = apply { this.end = end } + + /** Alias for calling [Builder.end] with `end.orElse(null)`. */ + fun end(end: Optional) = end(end.getOrNull()) + + /** Page size (for pagination). */ + fun pageSize(pageSize: Long?) = apply { this.pageSize = pageSize } + + /** + * Alias for [Builder.pageSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageSize(pageSize: Long) = pageSize(pageSize as Long?) + + /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ + fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [NetworkProgramListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): NetworkProgramListParams = + NetworkProgramListParams( + begin, + end, + pageSize, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + begin?.let { put("begin", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + end?.let { put("end", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + pageSize?.let { put("page_size", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NetworkProgramListParams && begin == other.begin && end == other.end && pageSize == other.pageSize && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(begin, end, pageSize, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "NetworkProgramListParams{begin=$begin, end=$end, pageSize=$pageSize, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramRetrieveParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramRetrieveParams.kt new file mode 100644 index 000000000..4734230d4 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkProgramRetrieveParams.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.Params +import com.lithic.api.core.http.Headers +import com.lithic.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get network program. */ +class NetworkProgramRetrieveParams +private constructor( + private val networkProgramToken: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun networkProgramToken(): Optional = Optional.ofNullable(networkProgramToken) + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): NetworkProgramRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [NetworkProgramRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NetworkProgramRetrieveParams]. */ + class Builder internal constructor() { + + private var networkProgramToken: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(networkProgramRetrieveParams: NetworkProgramRetrieveParams) = apply { + networkProgramToken = networkProgramRetrieveParams.networkProgramToken + additionalHeaders = networkProgramRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = networkProgramRetrieveParams.additionalQueryParams.toBuilder() + } + + fun networkProgramToken(networkProgramToken: String?) = apply { + this.networkProgramToken = networkProgramToken + } + + /** + * Alias for calling [Builder.networkProgramToken] with `networkProgramToken.orElse(null)`. + */ + fun networkProgramToken(networkProgramToken: Optional) = + networkProgramToken(networkProgramToken.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [NetworkProgramRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): NetworkProgramRetrieveParams = + NetworkProgramRetrieveParams( + networkProgramToken, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> networkProgramToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NetworkProgramRetrieveParams && networkProgramToken == other.networkProgramToken && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(networkProgramToken, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "NetworkProgramRetrieveParams{networkProgramToken=$networkProgramToken, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NonPciCard.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NonPciCard.kt index 7e1bc9ffd..096632b81 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NonPciCard.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NonPciCard.kt @@ -37,14 +37,17 @@ private constructor( private val type: JsonField, private val authRuleTokens: JsonField>, private val cardholderCurrency: JsonField, + private val comment: JsonField, private val digitalCardArtToken: JsonField, private val expMonth: JsonField, private val expYear: JsonField, private val hostname: JsonField, private val memo: JsonField, + private val networkProgramToken: JsonField, private val pendingCommands: JsonField>, private val productId: JsonField, private val replacementFor: JsonField, + private val substatus: JsonField, private val additionalProperties: MutableMap, ) { @@ -79,6 +82,7 @@ private constructor( @JsonProperty("cardholder_currency") @ExcludeMissing cardholderCurrency: JsonField = JsonMissing.of(), + @JsonProperty("comment") @ExcludeMissing comment: JsonField = JsonMissing.of(), @JsonProperty("digital_card_art_token") @ExcludeMissing digitalCardArtToken: JsonField = JsonMissing.of(), @@ -86,6 +90,9 @@ private constructor( @JsonProperty("exp_year") @ExcludeMissing expYear: JsonField = JsonMissing.of(), @JsonProperty("hostname") @ExcludeMissing hostname: JsonField = JsonMissing.of(), @JsonProperty("memo") @ExcludeMissing memo: JsonField = JsonMissing.of(), + @JsonProperty("network_program_token") + @ExcludeMissing + networkProgramToken: JsonField = JsonMissing.of(), @JsonProperty("pending_commands") @ExcludeMissing pendingCommands: JsonField> = JsonMissing.of(), @@ -93,6 +100,9 @@ private constructor( @JsonProperty("replacement_for") @ExcludeMissing replacementFor: JsonField = JsonMissing.of(), + @JsonProperty("substatus") + @ExcludeMissing + substatus: JsonField = JsonMissing.of(), ) : this( token, accountToken, @@ -107,14 +117,17 @@ private constructor( type, authRuleTokens, cardholderCurrency, + comment, digitalCardArtToken, expMonth, expYear, hostname, memo, + networkProgramToken, pendingCommands, productId, replacementFor, + substatus, mutableMapOf(), ) @@ -255,6 +268,14 @@ private constructor( fun cardholderCurrency(): Optional = cardholderCurrency.getOptional("cardholder_currency") + /** + * Additional context or information related to the card. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun comment(): Optional = comment.getOptional("comment") + /** * 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. @@ -297,6 +318,17 @@ private constructor( */ fun memo(): Optional = memo.getOptional("memo") + /** + * Globally unique identifier for the card's network program. Null if the card is not associated + * with a network program. Currently applicable to Visa cards participating in Account Level + * Management only + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkProgramToken(): Optional = + networkProgramToken.getOptional("network_program_token") + /** * 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 @@ -326,6 +358,30 @@ private constructor( */ fun replacementFor(): Optional = replacementFor.getOptional("replacement_for") + /** + * Card state substatus values: _ `LOST` - The physical card is no longer in the cardholder's + * possession due to being lost or never received by the cardholder. _ `COMPROMISED` - Card + * information has been exposed, potentially leading to unauthorized access. This may involve + * physical card theft, cloning, or online data breaches. _ `DAMAGED` - The physical card is not + * functioning properly, such as having chip failures or a demagnetized magnetic stripe. _ + * `END_USER_REQUEST` - The cardholder requested the closure of the card for reasons unrelated + * to fraud or damage, such as switching to a different product or closing the account. _ + * `ISSUER_REQUEST` - The issuer closed the card for reasons unrelated to fraud or damage, such + * as account inactivity, product or policy changes, or technology upgrades. _ `NOT_ACTIVE` - + * The card hasn’t had any transaction activity for a specified period, applicable to statuses + * like `PAUSED` or `CLOSED`. _ `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious + * transactions or activities that require review. This can involve prompting the cardholder to + * confirm legitimate use or report confirmed fraud. _ `INTERNAL_REVIEW` - The card is + * temporarily paused pending further internal review. _ `EXPIRED` - The card has expired and + * has been closed without being reissued. _ `UNDELIVERABLE` - The card cannot be delivered to + * the cardholder and has been returned. \* `OTHER` - The reason for the status does not fall + * into any of the above categories. A comment can be provided to specify the reason. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun substatus(): Optional = substatus.getOptional("substatus") + /** * Returns the raw JSON value of [token]. * @@ -431,6 +487,13 @@ private constructor( @ExcludeMissing fun _cardholderCurrency(): JsonField = cardholderCurrency + /** + * Returns the raw JSON value of [comment]. + * + * Unlike [comment], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("comment") @ExcludeMissing fun _comment(): JsonField = comment + /** * Returns the raw JSON value of [digitalCardArtToken]. * @@ -469,6 +532,16 @@ private constructor( */ @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + /** + * Returns the raw JSON value of [networkProgramToken]. + * + * Unlike [networkProgramToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("network_program_token") + @ExcludeMissing + fun _networkProgramToken(): JsonField = networkProgramToken + /** * Returns the raw JSON value of [pendingCommands]. * @@ -494,6 +567,13 @@ private constructor( @ExcludeMissing fun _replacementFor(): JsonField = replacementFor + /** + * Returns the raw JSON value of [substatus]. + * + * Unlike [substatus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("substatus") @ExcludeMissing fun _substatus(): JsonField = substatus + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -545,14 +625,17 @@ private constructor( private var type: JsonField? = null private var authRuleTokens: JsonField>? = null private var cardholderCurrency: JsonField = JsonMissing.of() + private var comment: JsonField = JsonMissing.of() private var digitalCardArtToken: JsonField = JsonMissing.of() private var expMonth: JsonField = JsonMissing.of() private var expYear: JsonField = JsonMissing.of() private var hostname: JsonField = JsonMissing.of() private var memo: JsonField = JsonMissing.of() + private var networkProgramToken: JsonField = JsonMissing.of() private var pendingCommands: JsonField>? = null private var productId: JsonField = JsonMissing.of() private var replacementFor: JsonField = JsonMissing.of() + private var substatus: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -570,14 +653,17 @@ private constructor( type = nonPciCard.type authRuleTokens = nonPciCard.authRuleTokens.map { it.toMutableList() } cardholderCurrency = nonPciCard.cardholderCurrency + comment = nonPciCard.comment digitalCardArtToken = nonPciCard.digitalCardArtToken expMonth = nonPciCard.expMonth expYear = nonPciCard.expYear hostname = nonPciCard.hostname memo = nonPciCard.memo + networkProgramToken = nonPciCard.networkProgramToken pendingCommands = nonPciCard.pendingCommands.map { it.toMutableList() } productId = nonPciCard.productId replacementFor = nonPciCard.replacementFor + substatus = nonPciCard.substatus additionalProperties = nonPciCard.additionalProperties.toMutableMap() } @@ -807,6 +893,17 @@ private constructor( this.cardholderCurrency = cardholderCurrency } + /** Additional context or information related to the card. */ + fun comment(comment: String) = comment(JsonField.of(comment)) + + /** + * Sets [Builder.comment] to an arbitrary JSON value. + * + * You should usually call [Builder.comment] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun comment(comment: JsonField) = apply { this.comment = comment } + /** * 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 @@ -870,6 +967,31 @@ private constructor( */ fun memo(memo: JsonField) = apply { this.memo = memo } + /** + * Globally unique identifier for the card's network program. Null if the card is not + * associated with a network program. Currently applicable to Visa cards participating in + * Account Level Management only + */ + fun networkProgramToken(networkProgramToken: String?) = + networkProgramToken(JsonField.ofNullable(networkProgramToken)) + + /** + * Alias for calling [Builder.networkProgramToken] with `networkProgramToken.orElse(null)`. + */ + fun networkProgramToken(networkProgramToken: Optional) = + networkProgramToken(networkProgramToken.getOrNull()) + + /** + * Sets [Builder.networkProgramToken] to an arbitrary JSON value. + * + * You should usually call [Builder.networkProgramToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun networkProgramToken(networkProgramToken: JsonField) = apply { + this.networkProgramToken = networkProgramToken + } + /** * 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 @@ -939,6 +1061,37 @@ private constructor( this.replacementFor = replacementFor } + /** + * Card state substatus values: _ `LOST` - The physical card is no longer in the + * cardholder's possession due to being lost or never received by the cardholder. _ + * `COMPROMISED` - Card information has been exposed, potentially leading to unauthorized + * access. This may involve physical card theft, cloning, or online data breaches. _ + * `DAMAGED` - The physical card is not functioning properly, such as having chip failures + * or a demagnetized magnetic stripe. _ `END_USER_REQUEST` - The cardholder requested the + * closure of the card for reasons unrelated to fraud or damage, such as switching to a + * different product or closing the account. _ `ISSUER_REQUEST` - The issuer closed the card + * for reasons unrelated to fraud or damage, such as account inactivity, product or policy + * changes, or technology upgrades. _ `NOT_ACTIVE` - The card hasn’t had any transaction + * activity for a specified period, applicable to statuses like `PAUSED` or `CLOSED`. _ + * `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious transactions or activities + * that require review. This can involve prompting the cardholder to confirm legitimate use + * or report confirmed fraud. _ `INTERNAL_REVIEW` - The card is temporarily paused pending + * further internal review. _ `EXPIRED` - The card has expired and has been closed without + * being reissued. _ `UNDELIVERABLE` - The card cannot be delivered to the cardholder and + * has been returned. \* `OTHER` - The reason for the status does not fall into any of the + * above categories. A comment can be provided to specify the reason. + */ + fun substatus(substatus: Substatus) = substatus(JsonField.of(substatus)) + + /** + * Sets [Builder.substatus] to an arbitrary JSON value. + * + * You should usually call [Builder.substatus] with a well-typed [Substatus] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun substatus(substatus: JsonField) = apply { this.substatus = substatus } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -995,14 +1148,17 @@ private constructor( checkRequired("type", type), (authRuleTokens ?: JsonMissing.of()).map { it.toImmutable() }, cardholderCurrency, + comment, digitalCardArtToken, expMonth, expYear, hostname, memo, + networkProgramToken, (pendingCommands ?: JsonMissing.of()).map { it.toImmutable() }, productId, replacementFor, + substatus, additionalProperties.toMutableMap(), ) } @@ -1027,14 +1183,17 @@ private constructor( type().validate() authRuleTokens() cardholderCurrency() + comment() digitalCardArtToken() expMonth() expYear() hostname() memo() + networkProgramToken() pendingCommands() productId() replacementFor() + substatus().ifPresent { it.validate() } validated = true } @@ -1066,14 +1225,17 @@ private constructor( (type.asKnown().getOrNull()?.validity() ?: 0) + (authRuleTokens.asKnown().getOrNull()?.size ?: 0) + (if (cardholderCurrency.asKnown().isPresent) 1 else 0) + + (if (comment.asKnown().isPresent) 1 else 0) + (if (digitalCardArtToken.asKnown().isPresent) 1 else 0) + (if (expMonth.asKnown().isPresent) 1 else 0) + (if (expYear.asKnown().isPresent) 1 else 0) + (if (hostname.asKnown().isPresent) 1 else 0) + (if (memo.asKnown().isPresent) 1 else 0) + + (if (networkProgramToken.asKnown().isPresent) 1 else 0) + (pendingCommands.asKnown().getOrNull()?.size ?: 0) + (if (productId.asKnown().isPresent) 1 else 0) + - (if (replacementFor.asKnown().isPresent) 1 else 0) + (if (replacementFor.asKnown().isPresent) 1 else 0) + + (substatus.asKnown().getOrNull()?.validity() ?: 0) /** Deprecated: Funding account for the card. */ class FundingAccount @@ -2202,20 +2364,220 @@ private constructor( override fun toString() = value.toString() } + /** + * Card state substatus values: _ `LOST` - The physical card is no longer in the cardholder's + * possession due to being lost or never received by the cardholder. _ `COMPROMISED` - Card + * information has been exposed, potentially leading to unauthorized access. This may involve + * physical card theft, cloning, or online data breaches. _ `DAMAGED` - The physical card is not + * functioning properly, such as having chip failures or a demagnetized magnetic stripe. _ + * `END_USER_REQUEST` - The cardholder requested the closure of the card for reasons unrelated + * to fraud or damage, such as switching to a different product or closing the account. _ + * `ISSUER_REQUEST` - The issuer closed the card for reasons unrelated to fraud or damage, such + * as account inactivity, product or policy changes, or technology upgrades. _ `NOT_ACTIVE` - + * The card hasn’t had any transaction activity for a specified period, applicable to statuses + * like `PAUSED` or `CLOSED`. _ `SUSPICIOUS_ACTIVITY` - The card has one or more suspicious + * transactions or activities that require review. This can involve prompting the cardholder to + * confirm legitimate use or report confirmed fraud. _ `INTERNAL_REVIEW` - The card is + * temporarily paused pending further internal review. _ `EXPIRED` - The card has expired and + * has been closed without being reissued. _ `UNDELIVERABLE` - The card cannot be delivered to + * the cardholder and has been returned. \* `OTHER` - The reason for the status does not fall + * into any of the above categories. A comment can be provided to specify the reason. + */ + class Substatus @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LOST = of("LOST") + + @JvmField val COMPROMISED = of("COMPROMISED") + + @JvmField val DAMAGED = of("DAMAGED") + + @JvmField val END_USER_REQUEST = of("END_USER_REQUEST") + + @JvmField val ISSUER_REQUEST = of("ISSUER_REQUEST") + + @JvmField val NOT_ACTIVE = of("NOT_ACTIVE") + + @JvmField val SUSPICIOUS_ACTIVITY = of("SUSPICIOUS_ACTIVITY") + + @JvmField val INTERNAL_REVIEW = of("INTERNAL_REVIEW") + + @JvmField val EXPIRED = of("EXPIRED") + + @JvmField val UNDELIVERABLE = of("UNDELIVERABLE") + + @JvmField val OTHER = of("OTHER") + + @JvmStatic fun of(value: String) = Substatus(JsonField.of(value)) + } + + /** An enum containing [Substatus]'s known values. */ + enum class Known { + LOST, + COMPROMISED, + DAMAGED, + END_USER_REQUEST, + ISSUER_REQUEST, + NOT_ACTIVE, + SUSPICIOUS_ACTIVITY, + INTERNAL_REVIEW, + EXPIRED, + UNDELIVERABLE, + OTHER, + } + + /** + * An enum containing [Substatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Substatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LOST, + COMPROMISED, + DAMAGED, + END_USER_REQUEST, + ISSUER_REQUEST, + NOT_ACTIVE, + SUSPICIOUS_ACTIVITY, + INTERNAL_REVIEW, + EXPIRED, + UNDELIVERABLE, + OTHER, + /** + * An enum member indicating that [Substatus] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LOST -> Value.LOST + COMPROMISED -> Value.COMPROMISED + DAMAGED -> Value.DAMAGED + END_USER_REQUEST -> Value.END_USER_REQUEST + ISSUER_REQUEST -> Value.ISSUER_REQUEST + NOT_ACTIVE -> Value.NOT_ACTIVE + SUSPICIOUS_ACTIVITY -> Value.SUSPICIOUS_ACTIVITY + INTERNAL_REVIEW -> Value.INTERNAL_REVIEW + EXPIRED -> Value.EXPIRED + UNDELIVERABLE -> Value.UNDELIVERABLE + OTHER -> Value.OTHER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LOST -> Known.LOST + COMPROMISED -> Known.COMPROMISED + DAMAGED -> Known.DAMAGED + END_USER_REQUEST -> Known.END_USER_REQUEST + ISSUER_REQUEST -> Known.ISSUER_REQUEST + NOT_ACTIVE -> Known.NOT_ACTIVE + SUSPICIOUS_ACTIVITY -> Known.SUSPICIOUS_ACTIVITY + INTERNAL_REVIEW -> Known.INTERNAL_REVIEW + EXPIRED -> Known.EXPIRED + UNDELIVERABLE -> Known.UNDELIVERABLE + OTHER -> Known.OTHER + else -> throw LithicInvalidDataException("Unknown Substatus: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Substatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Substatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NonPciCard && token == other.token && accountToken == other.accountToken && cardProgramToken == other.cardProgramToken && created == other.created && funding == other.funding && lastFour == other.lastFour && pinStatus == other.pinStatus && spendLimit == other.spendLimit && spendLimitDuration == other.spendLimitDuration && state == other.state && type == other.type && authRuleTokens == other.authRuleTokens && cardholderCurrency == other.cardholderCurrency && digitalCardArtToken == other.digitalCardArtToken && expMonth == other.expMonth && expYear == other.expYear && hostname == other.hostname && memo == other.memo && pendingCommands == other.pendingCommands && productId == other.productId && replacementFor == other.replacementFor && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is NonPciCard && token == other.token && accountToken == other.accountToken && cardProgramToken == other.cardProgramToken && created == other.created && funding == other.funding && lastFour == other.lastFour && pinStatus == other.pinStatus && spendLimit == other.spendLimit && spendLimitDuration == other.spendLimitDuration && state == other.state && type == other.type && authRuleTokens == other.authRuleTokens && cardholderCurrency == other.cardholderCurrency && comment == other.comment && digitalCardArtToken == other.digitalCardArtToken && expMonth == other.expMonth && expYear == other.expYear && hostname == other.hostname && memo == other.memo && networkProgramToken == other.networkProgramToken && pendingCommands == other.pendingCommands && productId == other.productId && replacementFor == other.replacementFor && substatus == other.substatus && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(token, accountToken, cardProgramToken, created, funding, lastFour, pinStatus, spendLimit, spendLimitDuration, state, type, authRuleTokens, cardholderCurrency, digitalCardArtToken, expMonth, expYear, hostname, memo, pendingCommands, productId, replacementFor, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(token, accountToken, cardProgramToken, created, funding, lastFour, pinStatus, spendLimit, spendLimitDuration, state, type, authRuleTokens, cardholderCurrency, comment, digitalCardArtToken, expMonth, expYear, hostname, memo, networkProgramToken, pendingCommands, productId, replacementFor, substatus, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "NonPciCard{token=$token, accountToken=$accountToken, cardProgramToken=$cardProgramToken, created=$created, funding=$funding, lastFour=$lastFour, pinStatus=$pinStatus, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, type=$type, authRuleTokens=$authRuleTokens, cardholderCurrency=$cardholderCurrency, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, hostname=$hostname, memo=$memo, pendingCommands=$pendingCommands, productId=$productId, replacementFor=$replacementFor, additionalProperties=$additionalProperties}" + "NonPciCard{token=$token, accountToken=$accountToken, cardProgramToken=$cardProgramToken, created=$created, funding=$funding, lastFour=$lastFour, pinStatus=$pinStatus, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, type=$type, authRuleTokens=$authRuleTokens, cardholderCurrency=$cardholderCurrency, comment=$comment, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, hostname=$hostname, memo=$memo, networkProgramToken=$networkProgramToken, pendingCommands=$pendingCommands, productId=$productId, replacementFor=$replacementFor, substatus=$substatus, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateActionParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateActionParams.kt index c6ffd9a6c..98bed8ecd 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateActionParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentSimulateActionParams.kt @@ -607,6 +607,8 @@ private constructor( @JvmField val ACH_RECEIPT_SETTLED = of("ACH_RECEIPT_SETTLED") + @JvmField val ACH_RECEIPT_RELEASED = of("ACH_RECEIPT_RELEASED") + @JvmField val ACH_RETURN_INITIATED = of("ACH_RETURN_INITIATED") @JvmField val ACH_RETURN_PROCESSED = of("ACH_RETURN_PROCESSED") @@ -623,6 +625,7 @@ private constructor( ACH_ORIGINATION_PROCESSED, ACH_ORIGINATION_SETTLED, ACH_RECEIPT_SETTLED, + ACH_RECEIPT_RELEASED, ACH_RETURN_INITIATED, ACH_RETURN_PROCESSED, ACH_RETURN_SETTLED, @@ -645,6 +648,7 @@ private constructor( ACH_ORIGINATION_PROCESSED, ACH_ORIGINATION_SETTLED, ACH_RECEIPT_SETTLED, + ACH_RECEIPT_RELEASED, ACH_RETURN_INITIATED, ACH_RETURN_PROCESSED, ACH_RETURN_SETTLED, @@ -669,6 +673,7 @@ private constructor( ACH_ORIGINATION_PROCESSED -> Value.ACH_ORIGINATION_PROCESSED ACH_ORIGINATION_SETTLED -> Value.ACH_ORIGINATION_SETTLED ACH_RECEIPT_SETTLED -> Value.ACH_RECEIPT_SETTLED + ACH_RECEIPT_RELEASED -> Value.ACH_RECEIPT_RELEASED ACH_RETURN_INITIATED -> Value.ACH_RETURN_INITIATED ACH_RETURN_PROCESSED -> Value.ACH_RETURN_PROCESSED ACH_RETURN_SETTLED -> Value.ACH_RETURN_SETTLED @@ -691,6 +696,7 @@ private constructor( ACH_ORIGINATION_PROCESSED -> Known.ACH_ORIGINATION_PROCESSED ACH_ORIGINATION_SETTLED -> Known.ACH_ORIGINATION_SETTLED ACH_RECEIPT_SETTLED -> Known.ACH_RECEIPT_SETTLED + ACH_RECEIPT_RELEASED -> Known.ACH_RECEIPT_RELEASED ACH_RETURN_INITIATED -> Known.ACH_RETURN_INITIATED ACH_RETURN_PROCESSED -> Known.ACH_RETURN_PROCESSED ACH_RETURN_SETTLED -> Known.ACH_RETURN_SETTLED diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Transaction.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Transaction.kt index 9d9e10227..edce1b29f 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Transaction.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Transaction.kt @@ -2681,19 +2681,22 @@ private constructor( * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ + @Deprecated("deprecated") fun threeDSVersion(): Optional = threeDSVersion.getOptional("3ds_version") /** - * Whether an acquirer exemption applied to the transaction. + * Whether an acquirer exemption applied to the transaction. Not currently populated and + * will be removed in the future. * * @throws LithicInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ + @Deprecated("deprecated") fun acquirerExemption(): AcquirerExemption = acquirerExemption.getRequired("acquirer_exemption") /** - * Indicates what the outcome of the 3DS authentication process is. + * Indicates the outcome of the 3DS authentication process. * * @throws LithicInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -2712,10 +2715,10 @@ private constructor( /** * Indicates whether chargeback liability shift applies to the transaction. Possible enum * values: - * - * * `3DS_AUTHENTICATED`: The transaction was fully authenticated through a 3-D Secure flow, chargeback liability shift applies. - * * `ACQUIRER_EXEMPTION`: The acquirer utilised an exemption to bypass Strong Customer Authentication (`transStatus = N`, or `transStatus = I`). Liability remains with the acquirer and in this case the `acquirer_exemption` field is expected to be not `NONE`. - * * `NONE`: Chargeback liability shift has not shifted to the issuer, i.e. the merchant is liable. + * - `3DS_AUTHENTICATED`: The transaction was fully authenticated through a 3-D Secure flow, + * chargeback liability shift applies. + * - `NONE`: Chargeback liability shift has not shifted to the issuer, i.e. the merchant is + * liable. * - `TOKEN_AUTHENTICATED`: The transaction was a tokenized payment with validated * cryptography, possibly recurring. Chargeback liability shift to the issuer applies. * @@ -2743,6 +2746,7 @@ private constructor( * @throws LithicInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ + @Deprecated("deprecated") fun verificationAttempted(): VerificationAttempted = verificationAttempted.getRequired("verification_attempted") @@ -2753,6 +2757,7 @@ private constructor( * @throws LithicInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ + @Deprecated("deprecated") fun verificationResult(): VerificationResult = verificationResult.getRequired("verification_result") @@ -2771,6 +2776,7 @@ private constructor( * Unlike [threeDSVersion], this method doesn't throw if the JSON field has an unexpected * type. */ + @Deprecated("deprecated") @JsonProperty("3ds_version") @ExcludeMissing fun _threeDSVersion(): JsonField = threeDSVersion @@ -2781,6 +2787,7 @@ private constructor( * Unlike [acquirerExemption], this method doesn't throw if the JSON field has an unexpected * type. */ + @Deprecated("deprecated") @JsonProperty("acquirer_exemption") @ExcludeMissing fun _acquirerExemption(): JsonField = acquirerExemption @@ -2831,6 +2838,7 @@ private constructor( * Unlike [verificationAttempted], this method doesn't throw if the JSON field has an * unexpected type. */ + @Deprecated("deprecated") @JsonProperty("verification_attempted") @ExcludeMissing fun _verificationAttempted(): JsonField = verificationAttempted @@ -2841,6 +2849,7 @@ private constructor( * Unlike [verificationResult], this method doesn't throw if the JSON field has an * unexpected type. */ + @Deprecated("deprecated") @JsonProperty("verification_result") @ExcludeMissing fun _verificationResult(): JsonField = verificationResult @@ -2916,10 +2925,12 @@ private constructor( } /** The 3DS version used for the authentication */ + @Deprecated("deprecated") fun threeDSVersion(threeDSVersion: String?) = threeDSVersion(JsonField.ofNullable(threeDSVersion)) /** Alias for calling [Builder.threeDSVersion] with `threeDSVersion.orElse(null)`. */ + @Deprecated("deprecated") fun threeDSVersion(threeDSVersion: Optional) = threeDSVersion(threeDSVersion.getOrNull()) @@ -2930,11 +2941,16 @@ private constructor( * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ + @Deprecated("deprecated") fun threeDSVersion(threeDSVersion: JsonField) = apply { this.threeDSVersion = threeDSVersion } - /** Whether an acquirer exemption applied to the transaction. */ + /** + * Whether an acquirer exemption applied to the transaction. Not currently populated and + * will be removed in the future. + */ + @Deprecated("deprecated") fun acquirerExemption(acquirerExemption: AcquirerExemption) = acquirerExemption(JsonField.of(acquirerExemption)) @@ -2945,11 +2961,12 @@ private constructor( * [AcquirerExemption] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ + @Deprecated("deprecated") fun acquirerExemption(acquirerExemption: JsonField) = apply { this.acquirerExemption = acquirerExemption } - /** Indicates what the outcome of the 3DS authentication process is. */ + /** Indicates the outcome of the 3DS authentication process. */ fun authenticationResult(authenticationResult: AuthenticationResult) = authenticationResult(JsonField.of(authenticationResult)) @@ -2983,10 +3000,10 @@ private constructor( /** * Indicates whether chargeback liability shift applies to the transaction. Possible * enum values: - * - * * `3DS_AUTHENTICATED`: The transaction was fully authenticated through a 3-D Secure flow, chargeback liability shift applies. - * * `ACQUIRER_EXEMPTION`: The acquirer utilised an exemption to bypass Strong Customer Authentication (`transStatus = N`, or `transStatus = I`). Liability remains with the acquirer and in this case the `acquirer_exemption` field is expected to be not `NONE`. - * * `NONE`: Chargeback liability shift has not shifted to the issuer, i.e. the merchant is liable. + * - `3DS_AUTHENTICATED`: The transaction was fully authenticated through a 3-D Secure + * flow, chargeback liability shift applies. + * - `NONE`: Chargeback liability shift has not shifted to the issuer, i.e. the merchant + * is liable. * - `TOKEN_AUTHENTICATED`: The transaction was a tokenized payment with validated * cryptography, possibly recurring. Chargeback liability shift to the issuer applies. */ @@ -3035,6 +3052,7 @@ private constructor( * Indicates whether a 3DS challenge flow was used, and if so, what the verification * method was. (deprecated, use `authentication_result`) */ + @Deprecated("deprecated") fun verificationAttempted(verificationAttempted: VerificationAttempted) = verificationAttempted(JsonField.of(verificationAttempted)) @@ -3045,6 +3063,7 @@ private constructor( * [VerificationAttempted] value instead. This method is primarily for setting the field * to an undocumented or not yet supported value. */ + @Deprecated("deprecated") fun verificationAttempted(verificationAttempted: JsonField) = apply { this.verificationAttempted = verificationAttempted @@ -3054,6 +3073,7 @@ private constructor( * Indicates whether a transaction is considered 3DS authenticated. (deprecated, use * `authentication_result`) */ + @Deprecated("deprecated") fun verificationResult(verificationResult: VerificationResult) = verificationResult(JsonField.of(verificationResult)) @@ -3064,6 +3084,7 @@ private constructor( * [VerificationResult] value instead. This method is primarily for setting the field to * an undocumented or not yet supported value. */ + @Deprecated("deprecated") fun verificationResult(verificationResult: JsonField) = apply { this.verificationResult = verificationResult } @@ -3182,7 +3203,11 @@ private constructor( (verificationResult.asKnown().getOrNull()?.validity() ?: 0) + (authenticationMethod.asKnown().getOrNull()?.validity() ?: 0) - /** Whether an acquirer exemption applied to the transaction. */ + /** + * Whether an acquirer exemption applied to the transaction. Not currently populated and + * will be removed in the future. + */ + @Deprecated("deprecated") class AcquirerExemption @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3357,7 +3382,7 @@ private constructor( override fun toString() = value.toString() } - /** Indicates what the outcome of the 3DS authentication process is. */ + /** Indicates the outcome of the 3DS authentication process. */ class AuthenticationResult @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3664,10 +3689,10 @@ private constructor( /** * Indicates whether chargeback liability shift applies to the transaction. Possible enum * values: - * - * * `3DS_AUTHENTICATED`: The transaction was fully authenticated through a 3-D Secure flow, chargeback liability shift applies. - * * `ACQUIRER_EXEMPTION`: The acquirer utilised an exemption to bypass Strong Customer Authentication (`transStatus = N`, or `transStatus = I`). Liability remains with the acquirer and in this case the `acquirer_exemption` field is expected to be not `NONE`. - * * `NONE`: Chargeback liability shift has not shifted to the issuer, i.e. the merchant is liable. + * - `3DS_AUTHENTICATED`: The transaction was fully authenticated through a 3-D Secure flow, + * chargeback liability shift applies. + * - `NONE`: Chargeback liability shift has not shifted to the issuer, i.e. the merchant is + * liable. * - `TOKEN_AUTHENTICATED`: The transaction was a tokenized payment with validated * cryptography, possibly recurring. Chargeback liability shift to the issuer applies. */ @@ -3689,21 +3714,18 @@ private constructor( @JvmField val _3DS_AUTHENTICATED = of("3DS_AUTHENTICATED") - @JvmField val ACQUIRER_EXEMPTION = of("ACQUIRER_EXEMPTION") + @JvmField val TOKEN_AUTHENTICATED = of("TOKEN_AUTHENTICATED") @JvmField val NONE = of("NONE") - @JvmField val TOKEN_AUTHENTICATED = of("TOKEN_AUTHENTICATED") - @JvmStatic fun of(value: String) = LiabilityShift(JsonField.of(value)) } /** An enum containing [LiabilityShift]'s known values. */ enum class Known { _3DS_AUTHENTICATED, - ACQUIRER_EXEMPTION, - NONE, TOKEN_AUTHENTICATED, + NONE, } /** @@ -3717,9 +3739,8 @@ private constructor( */ enum class Value { _3DS_AUTHENTICATED, - ACQUIRER_EXEMPTION, - NONE, TOKEN_AUTHENTICATED, + NONE, /** * An enum member indicating that [LiabilityShift] was instantiated with an unknown * value. @@ -3737,9 +3758,8 @@ private constructor( fun value(): Value = when (this) { _3DS_AUTHENTICATED -> Value._3DS_AUTHENTICATED - ACQUIRER_EXEMPTION -> Value.ACQUIRER_EXEMPTION - NONE -> Value.NONE TOKEN_AUTHENTICATED -> Value.TOKEN_AUTHENTICATED + NONE -> Value.NONE else -> Value._UNKNOWN } @@ -3755,9 +3775,8 @@ private constructor( fun known(): Known = when (this) { _3DS_AUTHENTICATED -> Known._3DS_AUTHENTICATED - ACQUIRER_EXEMPTION -> Known.ACQUIRER_EXEMPTION - NONE -> Known.NONE TOKEN_AUTHENTICATED -> Known.TOKEN_AUTHENTICATED + NONE -> Known.NONE else -> throw LithicInvalidDataException("Unknown LiabilityShift: $value") } @@ -3819,6 +3838,7 @@ private constructor( * Indicates whether a 3DS challenge flow was used, and if so, what the verification method * was. (deprecated, use `authentication_result`) */ + @Deprecated("deprecated") class VerificationAttempted @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3958,6 +3978,7 @@ private constructor( * Indicates whether a transaction is considered 3DS authenticated. (deprecated, use * `authentication_result`) */ + @Deprecated("deprecated") class VerificationResult @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/VelocityLimitParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/VelocityLimitParams.kt index 4b4512896..99735c3f5 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/VelocityLimitParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/VelocityLimitParams.kt @@ -6,24 +6,13 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.lithic.api.core.BaseDeserializer -import com.lithic.api.core.BaseSerializer import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue -import com.lithic.api.core.allMaxBy import com.lithic.api.core.checkKnown import com.lithic.api.core.checkRequired -import com.lithic.api.core.getOrThrow import com.lithic.api.core.toImmutable import com.lithic.api.errors.LithicInvalidDataException import java.util.Collections @@ -34,7 +23,7 @@ import kotlin.jvm.optionals.getOrNull class VelocityLimitParams private constructor( private val filters: JsonField, - private val period: JsonField, + private val period: JsonField, private val scope: JsonField, private val limitAmount: JsonField, private val limitCount: JsonField, @@ -44,7 +33,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("filters") @ExcludeMissing filters: JsonField = JsonMissing.of(), - @JsonProperty("period") @ExcludeMissing period: JsonField = JsonMissing.of(), + @JsonProperty("period") + @ExcludeMissing + period: JsonField = JsonMissing.of(), @JsonProperty("scope") @ExcludeMissing scope: JsonField = JsonMissing.of(), @JsonProperty("limit_amount") @ExcludeMissing @@ -65,7 +56,7 @@ private constructor( * @throws LithicInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun period(): Period = period.getRequired("period") + fun period(): VelocityLimitParamsPeriodWindow = period.getRequired("period") /** * @throws LithicInvalidDataException if the JSON field has an unexpected type or is @@ -105,7 +96,9 @@ private constructor( * * Unlike [period], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("period") @ExcludeMissing fun _period(): JsonField = period + @JsonProperty("period") + @ExcludeMissing + fun _period(): JsonField = period /** * Returns the raw JSON value of [scope]. @@ -159,7 +152,7 @@ private constructor( class Builder internal constructor() { private var filters: JsonField? = null - private var period: JsonField? = null + private var period: JsonField? = null private var scope: JsonField? = null private var limitAmount: JsonField = JsonMissing.of() private var limitCount: JsonField = JsonMissing.of() @@ -189,25 +182,62 @@ private constructor( * 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 (31 days). */ - fun period(period: Period) = period(JsonField.of(period)) + fun period(period: VelocityLimitParamsPeriodWindow) = period(JsonField.of(period)) /** * Sets [Builder.period] to an arbitrary JSON value. * - * You should usually call [Builder.period] with a well-typed [Period] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.period] with a well-typed + * [VelocityLimitParamsPeriodWindow] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun period(period: JsonField) = apply { + this.period = period + } + + /** + * Alias for calling [period] with `VelocityLimitParamsPeriodWindow.ofTrailing(trailing)`. + */ + fun period(trailing: Long) = period(VelocityLimitParamsPeriodWindow.ofTrailing(trailing)) + + /** Alias for calling [period] with `VelocityLimitParamsPeriodWindow.ofFixed(fixed)`. */ + fun period(fixed: VelocityLimitParamsPeriodWindow.FixedWindow) = + period(VelocityLimitParamsPeriodWindow.ofFixed(fixed)) + + /** + * Alias for calling [period] with + * `VelocityLimitParamsPeriodWindow.ofTrailingWindowObject(trailingWindowObject)`. */ - fun period(period: JsonField) = apply { this.period = period } + fun period(trailingWindowObject: VelocityLimitParamsPeriodWindow.TrailingWindowObject) = + period(VelocityLimitParamsPeriodWindow.ofTrailingWindowObject(trailingWindowObject)) - /** Alias for calling [period] with `Period.ofTrailingWindow(trailingWindow)`. */ - fun period(trailingWindow: Long) = period(Period.ofTrailingWindow(trailingWindow)) + /** + * Alias for calling [period] with + * `VelocityLimitParamsPeriodWindow.ofFixedWindowDay(fixedWindowDay)`. + */ + fun period(fixedWindowDay: VelocityLimitParamsPeriodWindow.FixedWindowDay) = + period(VelocityLimitParamsPeriodWindow.ofFixedWindowDay(fixedWindowDay)) /** * Alias for calling [period] with - * `Period.ofVelocityLimitParamsPeriodWindow(velocityLimitParamsPeriodWindow)`. + * `VelocityLimitParamsPeriodWindow.ofFixedWindowWeek(fixedWindowWeek)`. */ - fun period(velocityLimitParamsPeriodWindow: VelocityLimitParamsPeriodWindow) = - period(Period.ofVelocityLimitParamsPeriodWindow(velocityLimitParamsPeriodWindow)) + fun period(fixedWindowWeek: VelocityLimitParamsPeriodWindow.FixedWindowWeek) = + period(VelocityLimitParamsPeriodWindow.ofFixedWindowWeek(fixedWindowWeek)) + + /** + * Alias for calling [period] with + * `VelocityLimitParamsPeriodWindow.ofFixedWindowMonth(fixedWindowMonth)`. + */ + fun period(fixedWindowMonth: VelocityLimitParamsPeriodWindow.FixedWindowMonth) = + period(VelocityLimitParamsPeriodWindow.ofFixedWindowMonth(fixedWindowMonth)) + + /** + * Alias for calling [period] with + * `VelocityLimitParamsPeriodWindow.ofFixedWindowYear(fixedWindowYear)`. + */ + fun period(fixedWindowYear: VelocityLimitParamsPeriodWindow.FixedWindowYear) = + period(VelocityLimitParamsPeriodWindow.ofFixedWindowYear(fixedWindowYear)) fun scope(scope: Scope) = scope(JsonField.of(scope)) @@ -716,249 +746,6 @@ private constructor( "Filters{excludeCountries=$excludeCountries, excludeMccs=$excludeMccs, includeCountries=$includeCountries, includeMccs=$includeMccs, additionalProperties=$additionalProperties}" } - /** - * 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 (31 days). - */ - @JsonDeserialize(using = Period.Deserializer::class) - @JsonSerialize(using = Period.Serializer::class) - class Period - private constructor( - private val trailingWindow: Long? = null, - private val velocityLimitParamsPeriodWindow: VelocityLimitParamsPeriodWindow? = null, - private val _json: JsonValue? = null, - ) { - - /** - * 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 (31 days). - */ - fun trailingWindow(): Optional = Optional.ofNullable(trailingWindow) - - /** - * The window of time to calculate Spend Velocity over. - * - `DAY`: Velocity over the current day since midnight Eastern Time. - * - `WEEK`: Velocity over the current week since 00:00 / 12 AM on Monday in Eastern Time. - * - `MONTH`: Velocity over the current month since 00:00 / 12 AM on the first of the month - * in Eastern Time. - * - `YEAR`: Velocity over the current year since 00:00 / 12 AM on January 1st in Eastern - * Time. - */ - fun velocityLimitParamsPeriodWindow(): Optional = - Optional.ofNullable(velocityLimitParamsPeriodWindow) - - fun isTrailingWindow(): Boolean = trailingWindow != null - - fun isVelocityLimitParamsPeriodWindow(): Boolean = velocityLimitParamsPeriodWindow != null - - /** - * 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 (31 days). - */ - fun asTrailingWindow(): Long = trailingWindow.getOrThrow("trailingWindow") - - /** - * The window of time to calculate Spend Velocity over. - * - `DAY`: Velocity over the current day since midnight Eastern Time. - * - `WEEK`: Velocity over the current week since 00:00 / 12 AM on Monday in Eastern Time. - * - `MONTH`: Velocity over the current month since 00:00 / 12 AM on the first of the month - * in Eastern Time. - * - `YEAR`: Velocity over the current year since 00:00 / 12 AM on January 1st in Eastern - * Time. - */ - fun asVelocityLimitParamsPeriodWindow(): VelocityLimitParamsPeriodWindow = - velocityLimitParamsPeriodWindow.getOrThrow("velocityLimitParamsPeriodWindow") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - trailingWindow != null -> visitor.visitTrailingWindow(trailingWindow) - velocityLimitParamsPeriodWindow != null -> - visitor.visitVelocityLimitParamsPeriodWindow(velocityLimitParamsPeriodWindow) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Period = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitTrailingWindow(trailingWindow: Long) {} - - override fun visitVelocityLimitParamsPeriodWindow( - velocityLimitParamsPeriodWindow: VelocityLimitParamsPeriodWindow - ) { - velocityLimitParamsPeriodWindow.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitTrailingWindow(trailingWindow: Long) = 1 - - override fun visitVelocityLimitParamsPeriodWindow( - velocityLimitParamsPeriodWindow: VelocityLimitParamsPeriodWindow - ) = velocityLimitParamsPeriodWindow.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Period && trailingWindow == other.trailingWindow && velocityLimitParamsPeriodWindow == other.velocityLimitParamsPeriodWindow /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(trailingWindow, velocityLimitParamsPeriodWindow) /* spotless:on */ - - override fun toString(): String = - when { - trailingWindow != null -> "Period{trailingWindow=$trailingWindow}" - velocityLimitParamsPeriodWindow != null -> - "Period{velocityLimitParamsPeriodWindow=$velocityLimitParamsPeriodWindow}" - _json != null -> "Period{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Period") - } - - companion object { - - /** - * 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 (31 days). - */ - @JvmStatic - fun ofTrailingWindow(trailingWindow: Long) = Period(trailingWindow = trailingWindow) - - /** - * The window of time to calculate Spend Velocity over. - * - `DAY`: Velocity over the current day since midnight Eastern Time. - * - `WEEK`: Velocity over the current week since 00:00 / 12 AM on Monday in Eastern - * Time. - * - `MONTH`: Velocity over the current month since 00:00 / 12 AM on the first of the - * month in Eastern Time. - * - `YEAR`: Velocity over the current year since 00:00 / 12 AM on January 1st in - * Eastern Time. - */ - @JvmStatic - fun ofVelocityLimitParamsPeriodWindow( - velocityLimitParamsPeriodWindow: VelocityLimitParamsPeriodWindow - ) = Period(velocityLimitParamsPeriodWindow = velocityLimitParamsPeriodWindow) - } - - /** An interface that defines how to map each variant of [Period] to a value of type [T]. */ - interface Visitor { - - /** - * 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 (31 days). - */ - fun visitTrailingWindow(trailingWindow: Long): T - - /** - * The window of time to calculate Spend Velocity over. - * - `DAY`: Velocity over the current day since midnight Eastern Time. - * - `WEEK`: Velocity over the current week since 00:00 / 12 AM on Monday in Eastern - * Time. - * - `MONTH`: Velocity over the current month since 00:00 / 12 AM on the first of the - * month in Eastern Time. - * - `YEAR`: Velocity over the current year since 00:00 / 12 AM on January 1st in - * Eastern Time. - */ - fun visitVelocityLimitParamsPeriodWindow( - velocityLimitParamsPeriodWindow: VelocityLimitParamsPeriodWindow - ): T - - /** - * Maps an unknown variant of [Period] to a value of type [T]. - * - * An instance of [Period] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws LithicInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LithicInvalidDataException("Unknown Period: $json") - } - } - - internal class Deserializer : BaseDeserializer(Period::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Period { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { - Period(velocityLimitParamsPeriodWindow = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Period(trailingWindow = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). - 0 -> Period(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Period::class) { - - override fun serialize( - value: Period, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.trailingWindow != null -> generator.writeObject(value.trailingWindow) - value.velocityLimitParamsPeriodWindow != null -> - generator.writeObject(value.velocityLimitParamsPeriodWindow) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Period") - } - } - } - } - class Scope @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/VelocityLimitParamsPeriodWindow.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/VelocityLimitParamsPeriodWindow.kt index 419968bd9..2f98394c9 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/VelocityLimitParamsPeriodWindow.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/VelocityLimitParamsPeriodWindow.kt @@ -2,121 +2,159 @@ package com.lithic.api.models +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.allMaxBy +import com.lithic.api.core.getOrThrow import com.lithic.api.errors.LithicInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** - * The window of time to calculate Spend Velocity over. - * - `DAY`: Velocity over the current day since midnight Eastern Time. - * - `WEEK`: Velocity over the current week since 00:00 / 12 AM on Monday in Eastern Time. - * - `MONTH`: Velocity over the current month since 00:00 / 12 AM on the first of the month in - * Eastern Time. - * - `YEAR`: Velocity over the current year since 00:00 / 12 AM on January 1st in Eastern Time. + * 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 (31 days). */ +@JsonDeserialize(using = VelocityLimitParamsPeriodWindow.Deserializer::class) +@JsonSerialize(using = VelocityLimitParamsPeriodWindow.Serializer::class) class VelocityLimitParamsPeriodWindow -@JsonCreator -private constructor(private val value: JsonField) : Enum { +private constructor( + private val trailing: Long? = null, + private val fixed: FixedWindow? = null, + private val trailingWindowObject: TrailingWindowObject? = null, + private val fixedWindowDay: FixedWindowDay? = null, + private val fixedWindowWeek: FixedWindowWeek? = null, + private val fixedWindowMonth: FixedWindowMonth? = null, + private val fixedWindowYear: FixedWindowYear? = null, + private val _json: JsonValue? = null, +) { /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't match - * any known member, and you want to know that value. For example, if the SDK is on an older - * version than the API, then the API may respond with new members that the SDK is unaware of. + * 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 (31 days). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun trailing(): Optional = Optional.ofNullable(trailing) - companion object { + /** + * The window of time to calculate Spend Velocity over. + * - `DAY`: Velocity over the current day since midnight Eastern Time. + * - `WEEK`: Velocity over the current week since 00:00 / 12 AM on Monday in Eastern Time. + * - `MONTH`: Velocity over the current month since 00:00 / 12 AM on the first of the month in + * Eastern Time. + * - `YEAR`: Velocity over the current year since 00:00 / 12 AM on January 1st in Eastern Time. + */ + fun fixed(): Optional = Optional.ofNullable(fixed) + + fun trailingWindowObject(): Optional = + Optional.ofNullable(trailingWindowObject) + + /** Velocity over the current day since 00:00 / 12 AM in Eastern Time */ + fun fixedWindowDay(): Optional = Optional.ofNullable(fixedWindowDay) + + /** + * Velocity over the current week since 00:00 / 12 AM in Eastern Time on specified `day_of_week` + */ + fun fixedWindowWeek(): Optional = Optional.ofNullable(fixedWindowWeek) + + /** + * Velocity over the current month since 00:00 / 12 AM in Eastern Time on specified + * `day_of_month`. + */ + fun fixedWindowMonth(): Optional = Optional.ofNullable(fixedWindowMonth) - @JvmField val DAY = of("DAY") + /** + * Velocity over the current year since 00:00 / 12 AM in Eastern Time on specified `month` and + * `day_of_month`. This validates the month and day of the year to start from is a real date. In + * the event that February 29th is selected, in non-leap years, the window will start from + * February 28th. + */ + fun fixedWindowYear(): Optional = Optional.ofNullable(fixedWindowYear) - @JvmField val WEEK = of("WEEK") + fun isTrailing(): Boolean = trailing != null - @JvmField val MONTH = of("MONTH") + fun isFixed(): Boolean = fixed != null - @JvmField val YEAR = of("YEAR") + fun isTrailingWindowObject(): Boolean = trailingWindowObject != null - @JvmStatic fun of(value: String) = VelocityLimitParamsPeriodWindow(JsonField.of(value)) - } + fun isFixedWindowDay(): Boolean = fixedWindowDay != null - /** An enum containing [VelocityLimitParamsPeriodWindow]'s known values. */ - enum class Known { - DAY, - WEEK, - MONTH, - YEAR, - } + fun isFixedWindowWeek(): Boolean = fixedWindowWeek != null + + fun isFixedWindowMonth(): Boolean = fixedWindowMonth != null + + fun isFixedWindowYear(): Boolean = fixedWindowYear != null /** - * An enum containing [VelocityLimitParamsPeriodWindow]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [VelocityLimitParamsPeriodWindow] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if the SDK - * is on an older version than the API, then the API may respond with new members that the SDK - * is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DAY, - WEEK, - MONTH, - YEAR, - /** - * An enum member indicating that [VelocityLimitParamsPeriodWindow] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + * 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 (31 days). + */ + fun asTrailing(): Long = trailing.getOrThrow("trailing") /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if - * the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want to - * throw for the unknown case. + * The window of time to calculate Spend Velocity over. + * - `DAY`: Velocity over the current day since midnight Eastern Time. + * - `WEEK`: Velocity over the current week since 00:00 / 12 AM on Monday in Eastern Time. + * - `MONTH`: Velocity over the current month since 00:00 / 12 AM on the first of the month in + * Eastern Time. + * - `YEAR`: Velocity over the current year since 00:00 / 12 AM on January 1st in Eastern Time. */ - fun value(): Value = - when (this) { - DAY -> Value.DAY - WEEK -> Value.WEEK - MONTH -> Value.MONTH - YEAR -> Value.YEAR - else -> Value._UNKNOWN - } + fun asFixed(): FixedWindow = fixed.getOrThrow("fixed") + + fun asTrailingWindowObject(): TrailingWindowObject = + trailingWindowObject.getOrThrow("trailingWindowObject") + + /** Velocity over the current day since 00:00 / 12 AM in Eastern Time */ + fun asFixedWindowDay(): FixedWindowDay = fixedWindowDay.getOrThrow("fixedWindowDay") /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't want - * to throw for the unknown case. - * - * @throws LithicInvalidDataException if this class instance's value is a not a known member. + * Velocity over the current week since 00:00 / 12 AM in Eastern Time on specified `day_of_week` */ - fun known(): Known = - when (this) { - DAY -> Known.DAY - WEEK -> Known.WEEK - MONTH -> Known.MONTH - YEAR -> Known.YEAR - else -> - throw LithicInvalidDataException("Unknown VelocityLimitParamsPeriodWindow: $value") - } + fun asFixedWindowWeek(): FixedWindowWeek = fixedWindowWeek.getOrThrow("fixedWindowWeek") /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging and - * generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the expected - * primitive type. + * Velocity over the current month since 00:00 / 12 AM in Eastern Time on specified + * `day_of_month`. */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + fun asFixedWindowMonth(): FixedWindowMonth = fixedWindowMonth.getOrThrow("fixedWindowMonth") + + /** + * Velocity over the current year since 00:00 / 12 AM in Eastern Time on specified `month` and + * `day_of_month`. This validates the month and day of the year to start from is a real date. In + * the event that February 29th is selected, in non-leap years, the window will start from + * February 28th. + */ + fun asFixedWindowYear(): FixedWindowYear = fixedWindowYear.getOrThrow("fixedWindowYear") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + trailing != null -> visitor.visitTrailing(trailing) + fixed != null -> visitor.visitFixed(fixed) + trailingWindowObject != null -> visitor.visitTrailingWindowObject(trailingWindowObject) + fixedWindowDay != null -> visitor.visitFixedWindowDay(fixedWindowDay) + fixedWindowWeek != null -> visitor.visitFixedWindowWeek(fixedWindowWeek) + fixedWindowMonth != null -> visitor.visitFixedWindowMonth(fixedWindowMonth) + fixedWindowYear != null -> visitor.visitFixedWindowYear(fixedWindowYear) + else -> visitor.unknown(_json) + } private var validated: Boolean = false @@ -125,7 +163,35 @@ private constructor(private val value: JsonField) : Enum { return@apply } - known() + accept( + object : Visitor { + override fun visitTrailing(trailing: Long) {} + + override fun visitFixed(fixed: FixedWindow) { + fixed.validate() + } + + override fun visitTrailingWindowObject(trailingWindowObject: TrailingWindowObject) { + trailingWindowObject.validate() + } + + override fun visitFixedWindowDay(fixedWindowDay: FixedWindowDay) { + fixedWindowDay.validate() + } + + override fun visitFixedWindowWeek(fixedWindowWeek: FixedWindowWeek) { + fixedWindowWeek.validate() + } + + override fun visitFixedWindowMonth(fixedWindowMonth: FixedWindowMonth) { + fixedWindowMonth.validate() + } + + override fun visitFixedWindowYear(fixedWindowYear: FixedWindowYear) { + fixedWindowYear.validate() + } + } + ) validated = true } @@ -142,17 +208,1905 @@ private constructor(private val value: JsonField) : Enum { * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitTrailing(trailing: Long) = 1 + + override fun visitFixed(fixed: FixedWindow) = fixed.validity() + + override fun visitTrailingWindowObject(trailingWindowObject: TrailingWindowObject) = + trailingWindowObject.validity() + + override fun visitFixedWindowDay(fixedWindowDay: FixedWindowDay) = + fixedWindowDay.validity() + + override fun visitFixedWindowWeek(fixedWindowWeek: FixedWindowWeek) = + fixedWindowWeek.validity() + + override fun visitFixedWindowMonth(fixedWindowMonth: FixedWindowMonth) = + fixedWindowMonth.validity() + + override fun visitFixedWindowYear(fixedWindowYear: FixedWindowYear) = + fixedWindowYear.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is VelocityLimitParamsPeriodWindow && value == other.value /* spotless:on */ + return /* spotless:off */ other is VelocityLimitParamsPeriodWindow && trailing == other.trailing && fixed == other.fixed && trailingWindowObject == other.trailingWindowObject && fixedWindowDay == other.fixedWindowDay && fixedWindowWeek == other.fixedWindowWeek && fixedWindowMonth == other.fixedWindowMonth && fixedWindowYear == other.fixedWindowYear /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(trailing, fixed, trailingWindowObject, fixedWindowDay, fixedWindowWeek, fixedWindowMonth, fixedWindowYear) /* spotless:on */ + + override fun toString(): String = + when { + trailing != null -> "VelocityLimitParamsPeriodWindow{trailing=$trailing}" + fixed != null -> "VelocityLimitParamsPeriodWindow{fixed=$fixed}" + trailingWindowObject != null -> + "VelocityLimitParamsPeriodWindow{trailingWindowObject=$trailingWindowObject}" + fixedWindowDay != null -> + "VelocityLimitParamsPeriodWindow{fixedWindowDay=$fixedWindowDay}" + fixedWindowWeek != null -> + "VelocityLimitParamsPeriodWindow{fixedWindowWeek=$fixedWindowWeek}" + fixedWindowMonth != null -> + "VelocityLimitParamsPeriodWindow{fixedWindowMonth=$fixedWindowMonth}" + fixedWindowYear != null -> + "VelocityLimitParamsPeriodWindow{fixedWindowYear=$fixedWindowYear}" + _json != null -> "VelocityLimitParamsPeriodWindow{_unknown=$_json}" + else -> throw IllegalStateException("Invalid VelocityLimitParamsPeriodWindow") + } + + companion object { + + /** + * 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 (31 days). + */ + @JvmStatic + fun ofTrailing(trailing: Long) = VelocityLimitParamsPeriodWindow(trailing = trailing) + + /** + * The window of time to calculate Spend Velocity over. + * - `DAY`: Velocity over the current day since midnight Eastern Time. + * - `WEEK`: Velocity over the current week since 00:00 / 12 AM on Monday in Eastern Time. + * - `MONTH`: Velocity over the current month since 00:00 / 12 AM on the first of the month + * in Eastern Time. + * - `YEAR`: Velocity over the current year since 00:00 / 12 AM on January 1st in Eastern + * Time. + */ + @JvmStatic fun ofFixed(fixed: FixedWindow) = VelocityLimitParamsPeriodWindow(fixed = fixed) + + @JvmStatic + fun ofTrailingWindowObject(trailingWindowObject: TrailingWindowObject) = + VelocityLimitParamsPeriodWindow(trailingWindowObject = trailingWindowObject) + + /** Velocity over the current day since 00:00 / 12 AM in Eastern Time */ + @JvmStatic + fun ofFixedWindowDay(fixedWindowDay: FixedWindowDay) = + VelocityLimitParamsPeriodWindow(fixedWindowDay = fixedWindowDay) + + /** + * Velocity over the current week since 00:00 / 12 AM in Eastern Time on specified + * `day_of_week` + */ + @JvmStatic + fun ofFixedWindowWeek(fixedWindowWeek: FixedWindowWeek) = + VelocityLimitParamsPeriodWindow(fixedWindowWeek = fixedWindowWeek) + + /** + * Velocity over the current month since 00:00 / 12 AM in Eastern Time on specified + * `day_of_month`. + */ + @JvmStatic + fun ofFixedWindowMonth(fixedWindowMonth: FixedWindowMonth) = + VelocityLimitParamsPeriodWindow(fixedWindowMonth = fixedWindowMonth) + + /** + * Velocity over the current year since 00:00 / 12 AM in Eastern Time on specified `month` + * and `day_of_month`. This validates the month and day of the year to start from is a real + * date. In the event that February 29th is selected, in non-leap years, the window will + * start from February 28th. + */ + @JvmStatic + fun ofFixedWindowYear(fixedWindowYear: FixedWindowYear) = + VelocityLimitParamsPeriodWindow(fixedWindowYear = fixedWindowYear) + } + + /** + * An interface that defines how to map each variant of [VelocityLimitParamsPeriodWindow] to a + * value of type [T]. + */ + interface Visitor { + + /** + * 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 (31 days). + */ + fun visitTrailing(trailing: Long): T + + /** + * The window of time to calculate Spend Velocity over. + * - `DAY`: Velocity over the current day since midnight Eastern Time. + * - `WEEK`: Velocity over the current week since 00:00 / 12 AM on Monday in Eastern Time. + * - `MONTH`: Velocity over the current month since 00:00 / 12 AM on the first of the month + * in Eastern Time. + * - `YEAR`: Velocity over the current year since 00:00 / 12 AM on January 1st in Eastern + * Time. + */ + fun visitFixed(fixed: FixedWindow): T + + fun visitTrailingWindowObject(trailingWindowObject: TrailingWindowObject): T + + /** Velocity over the current day since 00:00 / 12 AM in Eastern Time */ + fun visitFixedWindowDay(fixedWindowDay: FixedWindowDay): T + + /** + * Velocity over the current week since 00:00 / 12 AM in Eastern Time on specified + * `day_of_week` + */ + fun visitFixedWindowWeek(fixedWindowWeek: FixedWindowWeek): T + + /** + * Velocity over the current month since 00:00 / 12 AM in Eastern Time on specified + * `day_of_month`. + */ + fun visitFixedWindowMonth(fixedWindowMonth: FixedWindowMonth): T + + /** + * Velocity over the current year since 00:00 / 12 AM in Eastern Time on specified `month` + * and `day_of_month`. This validates the month and day of the year to start from is a real + * date. In the event that February 29th is selected, in non-leap years, the window will + * start from February 28th. + */ + fun visitFixedWindowYear(fixedWindowYear: FixedWindowYear): T + + /** + * Maps an unknown variant of [VelocityLimitParamsPeriodWindow] to a value of type [T]. + * + * An instance of [VelocityLimitParamsPeriodWindow] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LithicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown VelocityLimitParamsPeriodWindow: $json") + } + } + + internal class Deserializer : + BaseDeserializer(VelocityLimitParamsPeriodWindow::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): VelocityLimitParamsPeriodWindow { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + VelocityLimitParamsPeriodWindow(fixed = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + VelocityLimitParamsPeriodWindow(trailingWindowObject = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + VelocityLimitParamsPeriodWindow(fixedWindowDay = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + VelocityLimitParamsPeriodWindow(fixedWindowWeek = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + VelocityLimitParamsPeriodWindow(fixedWindowMonth = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + VelocityLimitParamsPeriodWindow(fixedWindowYear = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + VelocityLimitParamsPeriodWindow(trailing = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from array). + 0 -> VelocityLimitParamsPeriodWindow(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(VelocityLimitParamsPeriodWindow::class) { + + override fun serialize( + value: VelocityLimitParamsPeriodWindow, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.trailing != null -> generator.writeObject(value.trailing) + value.fixed != null -> generator.writeObject(value.fixed) + value.trailingWindowObject != null -> + generator.writeObject(value.trailingWindowObject) + value.fixedWindowDay != null -> generator.writeObject(value.fixedWindowDay) + value.fixedWindowWeek != null -> generator.writeObject(value.fixedWindowWeek) + value.fixedWindowMonth != null -> generator.writeObject(value.fixedWindowMonth) + value.fixedWindowYear != null -> generator.writeObject(value.fixedWindowYear) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid VelocityLimitParamsPeriodWindow") + } + } + } + + /** + * The window of time to calculate Spend Velocity over. + * - `DAY`: Velocity over the current day since midnight Eastern Time. + * - `WEEK`: Velocity over the current week since 00:00 / 12 AM on Monday in Eastern Time. + * - `MONTH`: Velocity over the current month since 00:00 / 12 AM on the first of the month in + * Eastern Time. + * - `YEAR`: Velocity over the current year since 00:00 / 12 AM on January 1st in Eastern Time. + */ + class FixedWindow @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DAY = of("DAY") + + @JvmField val WEEK = of("WEEK") + + @JvmField val MONTH = of("MONTH") + + @JvmField val YEAR = of("YEAR") + + @JvmStatic fun of(value: String) = FixedWindow(JsonField.of(value)) + } + + /** An enum containing [FixedWindow]'s known values. */ + enum class Known { + DAY, + WEEK, + MONTH, + YEAR, + } + + /** + * An enum containing [FixedWindow]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FixedWindow] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DAY, + WEEK, + MONTH, + YEAR, + /** + * An enum member indicating that [FixedWindow] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DAY -> Value.DAY + WEEK -> Value.WEEK + MONTH -> Value.MONTH + YEAR -> Value.YEAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DAY -> Known.DAY + WEEK -> Known.WEEK + MONTH -> Known.MONTH + YEAR -> Known.YEAR + else -> throw LithicInvalidDataException("Unknown FixedWindow: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): FixedWindow = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedWindow && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TrailingWindowObject + private constructor( + private val duration: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(duration, type, mutableMapOf()) + + /** + * 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 (31 days). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [TrailingWindowObject]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TrailingWindowObject]. */ + class Builder internal constructor() { + + private var duration: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(trailingWindowObject: TrailingWindowObject) = apply { + duration = trailingWindowObject.duration + type = trailingWindowObject.type + additionalProperties = trailingWindowObject.additionalProperties.toMutableMap() + } + + /** + * 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 (31 days). + */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TrailingWindowObject]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TrailingWindowObject = + TrailingWindowObject(duration, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): TrailingWindowObject = apply { + if (validated) { + return@apply + } + + duration() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CUSTOM = of("CUSTOM") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CUSTOM + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CUSTOM, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CUSTOM -> Known.CUSTOM + else -> throw LithicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TrailingWindowObject && duration == other.duration && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(duration, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TrailingWindowObject{duration=$duration, type=$type, additionalProperties=$additionalProperties}" + } + + /** Velocity over the current day since 00:00 / 12 AM in Eastern Time */ + class FixedWindowDay + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FixedWindowDay]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FixedWindowDay]. */ + class Builder internal constructor() { + + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedWindowDay: FixedWindowDay) = apply { + type = fixedWindowDay.type + additionalProperties = fixedWindowDay.additionalProperties.toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FixedWindowDay]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FixedWindowDay = FixedWindowDay(type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FixedWindowDay = apply { + if (validated) { + return@apply + } + + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DAY = of("DAY") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + DAY + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DAY, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DAY -> Value.DAY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DAY -> Known.DAY + else -> throw LithicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedWindowDay && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FixedWindowDay{type=$type, additionalProperties=$additionalProperties}" + } + + /** + * Velocity over the current week since 00:00 / 12 AM in Eastern Time on specified `day_of_week` + */ + class FixedWindowWeek + private constructor( + private val dayOfWeek: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("day_of_week") + @ExcludeMissing + dayOfWeek: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(dayOfWeek, type, mutableMapOf()) + + /** + * The day of the week to start the week from. Following ISO-8601, 1 is Monday and 7 is + * Sunday. Defaults to Monday if not specified. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dayOfWeek(): Optional = dayOfWeek.getOptional("day_of_week") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [dayOfWeek]. + * + * Unlike [dayOfWeek], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("day_of_week") @ExcludeMissing fun _dayOfWeek(): JsonField = dayOfWeek + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FixedWindowWeek]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FixedWindowWeek]. */ + class Builder internal constructor() { + + private var dayOfWeek: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedWindowWeek: FixedWindowWeek) = apply { + dayOfWeek = fixedWindowWeek.dayOfWeek + type = fixedWindowWeek.type + additionalProperties = fixedWindowWeek.additionalProperties.toMutableMap() + } + + /** + * The day of the week to start the week from. Following ISO-8601, 1 is Monday and 7 is + * Sunday. Defaults to Monday if not specified. + */ + fun dayOfWeek(dayOfWeek: Long) = dayOfWeek(JsonField.of(dayOfWeek)) + + /** + * Sets [Builder.dayOfWeek] to an arbitrary JSON value. + * + * You should usually call [Builder.dayOfWeek] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dayOfWeek(dayOfWeek: JsonField) = apply { this.dayOfWeek = dayOfWeek } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FixedWindowWeek]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FixedWindowWeek = + FixedWindowWeek(dayOfWeek, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FixedWindowWeek = apply { + if (validated) { + return@apply + } + + dayOfWeek() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dayOfWeek.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val WEEK = of("WEEK") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WEEK + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + WEEK, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + WEEK -> Value.WEEK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + WEEK -> Known.WEEK + else -> throw LithicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedWindowWeek && dayOfWeek == other.dayOfWeek && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(dayOfWeek, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FixedWindowWeek{dayOfWeek=$dayOfWeek, type=$type, additionalProperties=$additionalProperties}" } - override fun hashCode() = value.hashCode() + /** + * Velocity over the current month since 00:00 / 12 AM in Eastern Time on specified + * `day_of_month`. + */ + class FixedWindowMonth + private constructor( + private val dayOfMonth: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("day_of_month") + @ExcludeMissing + dayOfMonth: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(dayOfMonth, type, mutableMapOf()) + + /** + * The day of the month to start from. Accepts values from 1 to 31, and will reset at the + * end of the month if the day exceeds the number of days in the month. Defaults to the 1st + * of the month if not specified. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dayOfMonth(): Optional = dayOfMonth.getOptional("day_of_month") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [dayOfMonth]. + * + * Unlike [dayOfMonth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("day_of_month") + @ExcludeMissing + fun _dayOfMonth(): JsonField = dayOfMonth + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FixedWindowMonth]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FixedWindowMonth]. */ + class Builder internal constructor() { + + private var dayOfMonth: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedWindowMonth: FixedWindowMonth) = apply { + dayOfMonth = fixedWindowMonth.dayOfMonth + type = fixedWindowMonth.type + additionalProperties = fixedWindowMonth.additionalProperties.toMutableMap() + } - override fun toString() = value.toString() + /** + * The day of the month to start from. Accepts values from 1 to 31, and will reset at + * the end of the month if the day exceeds the number of days in the month. Defaults to + * the 1st of the month if not specified. + */ + fun dayOfMonth(dayOfMonth: Long) = dayOfMonth(JsonField.of(dayOfMonth)) + + /** + * Sets [Builder.dayOfMonth] to an arbitrary JSON value. + * + * You should usually call [Builder.dayOfMonth] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dayOfMonth(dayOfMonth: JsonField) = apply { this.dayOfMonth = dayOfMonth } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FixedWindowMonth]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FixedWindowMonth = + FixedWindowMonth(dayOfMonth, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FixedWindowMonth = apply { + if (validated) { + return@apply + } + + dayOfMonth() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dayOfMonth.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MONTH = of("MONTH") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + MONTH + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MONTH, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MONTH -> Value.MONTH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + MONTH -> Known.MONTH + else -> throw LithicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedWindowMonth && dayOfMonth == other.dayOfMonth && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(dayOfMonth, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FixedWindowMonth{dayOfMonth=$dayOfMonth, type=$type, additionalProperties=$additionalProperties}" + } + + /** + * Velocity over the current year since 00:00 / 12 AM in Eastern Time on specified `month` and + * `day_of_month`. This validates the month and day of the year to start from is a real date. In + * the event that February 29th is selected, in non-leap years, the window will start from + * February 28th. + */ + class FixedWindowYear + private constructor( + private val dayOfMonth: JsonField, + private val month: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("day_of_month") + @ExcludeMissing + dayOfMonth: JsonField = JsonMissing.of(), + @JsonProperty("month") @ExcludeMissing month: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(dayOfMonth, month, type, mutableMapOf()) + + /** + * The day of the month to start from. Defaults to the 1st of the month if not specified. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dayOfMonth(): Optional = dayOfMonth.getOptional("day_of_month") + + /** + * The month to start from. 1 is January and 12 is December. Defaults to January if not + * specified. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun month(): Optional = month.getOptional("month") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [dayOfMonth]. + * + * Unlike [dayOfMonth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("day_of_month") + @ExcludeMissing + fun _dayOfMonth(): JsonField = dayOfMonth + + /** + * Returns the raw JSON value of [month]. + * + * Unlike [month], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FixedWindowYear]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FixedWindowYear]. */ + class Builder internal constructor() { + + private var dayOfMonth: JsonField = JsonMissing.of() + private var month: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fixedWindowYear: FixedWindowYear) = apply { + dayOfMonth = fixedWindowYear.dayOfMonth + month = fixedWindowYear.month + type = fixedWindowYear.type + additionalProperties = fixedWindowYear.additionalProperties.toMutableMap() + } + + /** + * The day of the month to start from. Defaults to the 1st of the month if not + * specified. + */ + fun dayOfMonth(dayOfMonth: Long) = dayOfMonth(JsonField.of(dayOfMonth)) + + /** + * Sets [Builder.dayOfMonth] to an arbitrary JSON value. + * + * You should usually call [Builder.dayOfMonth] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dayOfMonth(dayOfMonth: JsonField) = apply { this.dayOfMonth = dayOfMonth } + + /** + * The month to start from. 1 is January and 12 is December. Defaults to January if not + * specified. + */ + fun month(month: Long) = month(JsonField.of(month)) + + /** + * Sets [Builder.month] to an arbitrary JSON value. + * + * You should usually call [Builder.month] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun month(month: JsonField) = apply { this.month = month } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FixedWindowYear]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FixedWindowYear = + FixedWindowYear(dayOfMonth, month, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FixedWindowYear = apply { + if (validated) { + return@apply + } + + dayOfMonth() + month() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dayOfMonth.asKnown().isPresent) 1 else 0) + + (if (month.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val YEAR = of("YEAR") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + YEAR + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + YEAR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + YEAR -> Value.YEAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + YEAR -> Known.YEAR + else -> throw LithicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FixedWindowYear && dayOfMonth == other.dayOfMonth && month == other.month && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(dayOfMonth, month, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FixedWindowYear{dayOfMonth=$dayOfMonth, month=$month, type=$type, additionalProperties=$additionalProperties}" + } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsync.kt new file mode 100644 index 000000000..7c504f404 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsync.kt @@ -0,0 +1,173 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.models.NetworkProgram +import com.lithic.api.models.NetworkProgramListPageAsync +import com.lithic.api.models.NetworkProgramListParams +import com.lithic.api.models.NetworkProgramRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface NetworkProgramServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): NetworkProgramServiceAsync + + /** Get network program. */ + fun retrieve(networkProgramToken: String): CompletableFuture = + retrieve(networkProgramToken, NetworkProgramRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + networkProgramToken: String, + params: NetworkProgramRetrieveParams = NetworkProgramRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve( + params.toBuilder().networkProgramToken(networkProgramToken).build(), + requestOptions, + ) + + /** @see [retrieve] */ + fun retrieve( + networkProgramToken: String, + params: NetworkProgramRetrieveParams = NetworkProgramRetrieveParams.none(), + ): CompletableFuture = + retrieve(networkProgramToken, params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + params: NetworkProgramRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see [retrieve] */ + fun retrieve(params: NetworkProgramRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + networkProgramToken: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(networkProgramToken, NetworkProgramRetrieveParams.none(), requestOptions) + + /** List network programs. */ + fun list(): CompletableFuture = + list(NetworkProgramListParams.none()) + + /** @see [list] */ + fun list( + params: NetworkProgramListParams = NetworkProgramListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see [list] */ + fun list( + params: NetworkProgramListParams = NetworkProgramListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(NetworkProgramListParams.none(), requestOptions) + + /** + * A view of [NetworkProgramServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): NetworkProgramServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/network_programs/{network_program_token}`, but + * is otherwise the same as [NetworkProgramServiceAsync.retrieve]. + */ + fun retrieve( + networkProgramToken: String + ): CompletableFuture> = + retrieve(networkProgramToken, NetworkProgramRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + networkProgramToken: String, + params: NetworkProgramRetrieveParams = NetworkProgramRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve( + params.toBuilder().networkProgramToken(networkProgramToken).build(), + requestOptions, + ) + + /** @see [retrieve] */ + fun retrieve( + networkProgramToken: String, + params: NetworkProgramRetrieveParams = NetworkProgramRetrieveParams.none(), + ): CompletableFuture> = + retrieve(networkProgramToken, params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + params: NetworkProgramRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [retrieve] */ + fun retrieve( + params: NetworkProgramRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + networkProgramToken: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(networkProgramToken, NetworkProgramRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/network_programs`, but is otherwise the same as + * [NetworkProgramServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(NetworkProgramListParams.none()) + + /** @see [list] */ + fun list( + params: NetworkProgramListParams = NetworkProgramListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + fun list( + params: NetworkProgramListParams = NetworkProgramListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(NetworkProgramListParams.none(), requestOptions) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsyncImpl.kt new file mode 100644 index 000000000..4c9da290c --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsyncImpl.kt @@ -0,0 +1,139 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.JsonValue +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorHandler +import com.lithic.api.core.handlers.jsonHandler +import com.lithic.api.core.handlers.withErrorHandler +import com.lithic.api.core.http.HttpMethod +import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse.Handler +import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.core.http.parseable +import com.lithic.api.core.prepareAsync +import com.lithic.api.models.NetworkProgram +import com.lithic.api.models.NetworkProgramListPageAsync +import com.lithic.api.models.NetworkProgramListPageResponse +import com.lithic.api.models.NetworkProgramListParams +import com.lithic.api.models.NetworkProgramRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class NetworkProgramServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : NetworkProgramServiceAsync { + + private val withRawResponse: NetworkProgramServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): NetworkProgramServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): NetworkProgramServiceAsync = + NetworkProgramServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: NetworkProgramRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/network_programs/{network_program_token} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: NetworkProgramListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/network_programs + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + NetworkProgramServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + override fun withOptions( + modifier: Consumer + ): NetworkProgramServiceAsync.WithRawResponse = + NetworkProgramServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: NetworkProgramRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("networkProgramToken", params.networkProgramToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "network_programs", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: NetworkProgramListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "network_programs") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + NetworkProgramListPageAsync.builder() + .service(NetworkProgramServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/NetworkProgramService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/NetworkProgramService.kt new file mode 100644 index 000000000..7d7969e15 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/NetworkProgramService.kt @@ -0,0 +1,169 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.models.NetworkProgram +import com.lithic.api.models.NetworkProgramListPage +import com.lithic.api.models.NetworkProgramListParams +import com.lithic.api.models.NetworkProgramRetrieveParams +import java.util.function.Consumer + +interface NetworkProgramService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): NetworkProgramService + + /** Get network program. */ + fun retrieve(networkProgramToken: String): NetworkProgram = + retrieve(networkProgramToken, NetworkProgramRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + networkProgramToken: String, + params: NetworkProgramRetrieveParams = NetworkProgramRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): NetworkProgram = + retrieve( + params.toBuilder().networkProgramToken(networkProgramToken).build(), + requestOptions, + ) + + /** @see [retrieve] */ + fun retrieve( + networkProgramToken: String, + params: NetworkProgramRetrieveParams = NetworkProgramRetrieveParams.none(), + ): NetworkProgram = retrieve(networkProgramToken, params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + params: NetworkProgramRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): NetworkProgram + + /** @see [retrieve] */ + fun retrieve(params: NetworkProgramRetrieveParams): NetworkProgram = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(networkProgramToken: String, requestOptions: RequestOptions): NetworkProgram = + retrieve(networkProgramToken, NetworkProgramRetrieveParams.none(), requestOptions) + + /** List network programs. */ + fun list(): NetworkProgramListPage = list(NetworkProgramListParams.none()) + + /** @see [list] */ + fun list( + params: NetworkProgramListParams = NetworkProgramListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): NetworkProgramListPage + + /** @see [list] */ + fun list( + params: NetworkProgramListParams = NetworkProgramListParams.none() + ): NetworkProgramListPage = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(requestOptions: RequestOptions): NetworkProgramListPage = + list(NetworkProgramListParams.none(), requestOptions) + + /** + * A view of [NetworkProgramService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): NetworkProgramService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /v1/network_programs/{network_program_token}`, but + * is otherwise the same as [NetworkProgramService.retrieve]. + */ + @MustBeClosed + fun retrieve(networkProgramToken: String): HttpResponseFor = + retrieve(networkProgramToken, NetworkProgramRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + networkProgramToken: String, + params: NetworkProgramRetrieveParams = NetworkProgramRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve( + params.toBuilder().networkProgramToken(networkProgramToken).build(), + requestOptions, + ) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + networkProgramToken: String, + params: NetworkProgramRetrieveParams = NetworkProgramRetrieveParams.none(), + ): HttpResponseFor = + retrieve(networkProgramToken, params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: NetworkProgramRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: NetworkProgramRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + networkProgramToken: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(networkProgramToken, NetworkProgramRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /v1/network_programs`, but is otherwise the same as + * [NetworkProgramService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(NetworkProgramListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: NetworkProgramListParams = NetworkProgramListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list( + params: NetworkProgramListParams = NetworkProgramListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(NetworkProgramListParams.none(), requestOptions) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/NetworkProgramServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/NetworkProgramServiceImpl.kt new file mode 100644 index 000000000..ca3cc96e8 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/NetworkProgramServiceImpl.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.JsonValue +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorHandler +import com.lithic.api.core.handlers.jsonHandler +import com.lithic.api.core.handlers.withErrorHandler +import com.lithic.api.core.http.HttpMethod +import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse.Handler +import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.core.http.parseable +import com.lithic.api.core.prepare +import com.lithic.api.models.NetworkProgram +import com.lithic.api.models.NetworkProgramListPage +import com.lithic.api.models.NetworkProgramListPageResponse +import com.lithic.api.models.NetworkProgramListParams +import com.lithic.api.models.NetworkProgramRetrieveParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class NetworkProgramServiceImpl internal constructor(private val clientOptions: ClientOptions) : + NetworkProgramService { + + private val withRawResponse: NetworkProgramService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): NetworkProgramService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): NetworkProgramService = + NetworkProgramServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: NetworkProgramRetrieveParams, + requestOptions: RequestOptions, + ): NetworkProgram = + // get /v1/network_programs/{network_program_token} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: NetworkProgramListParams, + requestOptions: RequestOptions, + ): NetworkProgramListPage = + // get /v1/network_programs + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + NetworkProgramService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + override fun withOptions( + modifier: Consumer + ): NetworkProgramService.WithRawResponse = + NetworkProgramServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun retrieve( + params: NetworkProgramRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("networkProgramToken", params.networkProgramToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "network_programs", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: NetworkProgramListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "network_programs") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + NetworkProgramListPage.builder() + .service(NetworkProgramServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountListPageResponseTest.kt index eca93223f..fc4eabdbb 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountListPageResponseTest.kt @@ -36,6 +36,8 @@ internal class AccountListPageResponseTest { ) .addAuthRuleToken("string") .cardholderCurrency("USD") + .comment("comment") + .substatus(Account.Substatus.FRAUD_IDENTIFIED) .verificationAddress( Account.VerificationAddress.builder() .address1("124 Old Forest Way") @@ -74,6 +76,8 @@ internal class AccountListPageResponseTest { ) .addAuthRuleToken("string") .cardholderCurrency("USD") + .comment("comment") + .substatus(Account.Substatus.FRAUD_IDENTIFIED) .verificationAddress( Account.VerificationAddress.builder() .address1("124 Old Forest Way") @@ -116,6 +120,8 @@ internal class AccountListPageResponseTest { ) .addAuthRuleToken("string") .cardholderCurrency("USD") + .comment("comment") + .substatus(Account.Substatus.FRAUD_IDENTIFIED) .verificationAddress( Account.VerificationAddress.builder() .address1("124 Old Forest Way") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountTest.kt index e0f53f8fd..7e1d1a3de 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountTest.kt @@ -35,6 +35,8 @@ internal class AccountTest { ) .addAuthRuleToken("string") .cardholderCurrency("USD") + .comment("comment") + .substatus(Account.Substatus.FRAUD_IDENTIFIED) .verificationAddress( Account.VerificationAddress.builder() .address1("124 Old Forest Way") @@ -65,6 +67,8 @@ internal class AccountTest { ) assertThat(account.authRuleTokens().getOrNull()).containsExactly("string") assertThat(account.cardholderCurrency()).contains("USD") + assertThat(account.comment()).contains("comment") + assertThat(account.substatus()).contains(Account.Substatus.FRAUD_IDENTIFIED) assertThat(account.verificationAddress()) .contains( Account.VerificationAddress.builder() @@ -103,6 +107,8 @@ internal class AccountTest { ) .addAuthRuleToken("string") .cardholderCurrency("USD") + .comment("comment") + .substatus(Account.Substatus.FRAUD_IDENTIFIED) .verificationAddress( Account.VerificationAddress.builder() .address1("124 Old Forest Way") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountUpdateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountUpdateParamsTest.kt index 79a7b748c..9975690c7 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountUpdateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountUpdateParamsTest.kt @@ -11,10 +11,12 @@ internal class AccountUpdateParamsTest { fun create() { AccountUpdateParams.builder() .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") .dailySpendLimit(1000L) .lifetimeSpendLimit(0L) .monthlySpendLimit(0L) .state(AccountUpdateParams.State.ACTIVE) + .substatus(AccountUpdateParams.Substatus.FRAUD_IDENTIFIED) .verificationAddress( AccountUpdateParams.VerificationAddress.builder() .address1("address1") @@ -45,10 +47,12 @@ internal class AccountUpdateParamsTest { val params = AccountUpdateParams.builder() .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") .dailySpendLimit(1000L) .lifetimeSpendLimit(0L) .monthlySpendLimit(0L) .state(AccountUpdateParams.State.ACTIVE) + .substatus(AccountUpdateParams.Substatus.FRAUD_IDENTIFIED) .verificationAddress( AccountUpdateParams.VerificationAddress.builder() .address1("address1") @@ -63,10 +67,12 @@ internal class AccountUpdateParamsTest { val body = params._body() + assertThat(body.comment()).contains("comment") assertThat(body.dailySpendLimit()).contains(1000L) assertThat(body.lifetimeSpendLimit()).contains(0L) assertThat(body.monthlySpendLimit()).contains(0L) assertThat(body.state()).contains(AccountUpdateParams.State.ACTIVE) + assertThat(body.substatus()).contains(AccountUpdateParams.Substatus.FRAUD_IDENTIFIED) assertThat(body.verificationAddress()) .contains( AccountUpdateParams.VerificationAddress.builder() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreateParamsTest.kt index 190e2ee58..af4278789 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreateParamsTest.kt @@ -21,7 +21,9 @@ internal class CardCreateParamsTest { .pin("pin") .productId("1") .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() .address1("5 Broad Street") @@ -59,7 +61,9 @@ internal class CardCreateParamsTest { .pin("pin") .productId("1") .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() .address1("5 Broad Street") @@ -94,7 +98,9 @@ internal class CardCreateParamsTest { assertThat(body.pin()).contains("pin") assertThat(body.productId()).contains("1") assertThat(body.replacementAccountToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.replacementComment()).contains("replacement_comment") assertThat(body.replacementFor()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.replacementSubstatus()).contains(CardCreateParams.ReplacementSubstatus.LOST) assertThat(body.shippingAddress()) .contains( ShippingAddress.builder() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardListPageResponseTest.kt index 93bc562c1..2630da9d1 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardListPageResponseTest.kt @@ -39,14 +39,17 @@ internal class CardListPageResponseTest { .type(NonPciCard.Type.MERCHANT_LOCKED) .addAuthRuleToken("string") .cardholderCurrency("USD") + .comment("comment") .digitalCardArtToken("00000000-0000-0000-1000-000000000000") .expMonth("06") .expYear("2027") .hostname("hostname") .memo("New Card") + .networkProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .addPendingCommand("string") .productId("1") .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") + .substatus(NonPciCard.Substatus.LOST) .build() ) .hasMore(true) @@ -78,14 +81,17 @@ internal class CardListPageResponseTest { .type(NonPciCard.Type.MERCHANT_LOCKED) .addAuthRuleToken("string") .cardholderCurrency("USD") + .comment("comment") .digitalCardArtToken("00000000-0000-0000-1000-000000000000") .expMonth("06") .expYear("2027") .hostname("hostname") .memo("New Card") + .networkProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .addPendingCommand("string") .productId("1") .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") + .substatus(NonPciCard.Substatus.LOST) .build() ) assertThat(cardListPageResponse.hasMore()).isEqualTo(true) @@ -121,14 +127,17 @@ internal class CardListPageResponseTest { .type(NonPciCard.Type.MERCHANT_LOCKED) .addAuthRuleToken("string") .cardholderCurrency("USD") + .comment("comment") .digitalCardArtToken("00000000-0000-0000-1000-000000000000") .expMonth("06") .expYear("2027") .hostname("hostname") .memo("New Card") + .networkProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .addPendingCommand("string") .productId("1") .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") + .substatus(NonPciCard.Substatus.LOST) .build() ) .hasMore(true) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramListPageResponseTest.kt index a4667a655..f7c923dbb 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramListPageResponseTest.kt @@ -21,6 +21,7 @@ internal class CardProgramListPageResponseTest { .name("My Prepaid Program") .panRangeEnd("52304803") .panRangeStart("52304803") + .accountLevelManagementEnabled(true) .cardholderCurrency("USD") .addSettlementCurrency("USD") .addSettlementCurrency("CAD") @@ -37,6 +38,7 @@ internal class CardProgramListPageResponseTest { .name("My Prepaid Program") .panRangeEnd("52304803") .panRangeStart("52304803") + .accountLevelManagementEnabled(true) .cardholderCurrency("USD") .addSettlementCurrency("USD") .addSettlementCurrency("CAD") @@ -57,6 +59,7 @@ internal class CardProgramListPageResponseTest { .name("My Prepaid Program") .panRangeEnd("52304803") .panRangeStart("52304803") + .accountLevelManagementEnabled(true) .cardholderCurrency("USD") .addSettlementCurrency("USD") .addSettlementCurrency("CAD") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramTest.kt index 4ab4c2850..8abf7716e 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramTest.kt @@ -20,6 +20,7 @@ internal class CardProgramTest { .name("My Prepaid Program") .panRangeEnd("52304803") .panRangeStart("52304803") + .accountLevelManagementEnabled(true) .cardholderCurrency("USD") .addSettlementCurrency("USD") .addSettlementCurrency("CAD") @@ -31,6 +32,7 @@ internal class CardProgramTest { assertThat(cardProgram.name()).isEqualTo("My Prepaid Program") assertThat(cardProgram.panRangeEnd()).isEqualTo("52304803") assertThat(cardProgram.panRangeStart()).isEqualTo("52304803") + assertThat(cardProgram.accountLevelManagementEnabled()).contains(true) assertThat(cardProgram.cardholderCurrency()).contains("USD") assertThat(cardProgram.settlementCurrencies().getOrNull()).containsExactly("USD", "CAD") } @@ -45,6 +47,7 @@ internal class CardProgramTest { .name("My Prepaid Program") .panRangeEnd("52304803") .panRangeStart("52304803") + .accountLevelManagementEnabled(true) .cardholderCurrency("USD") .addSettlementCurrency("USD") .addSettlementCurrency("CAD") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTest.kt index 61b68468f..f676e77f8 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTest.kt @@ -38,14 +38,17 @@ internal class CardTest { .type(NonPciCard.Type.MERCHANT_LOCKED) .addAuthRuleToken("string") .cardholderCurrency("USD") + .comment("comment") .digitalCardArtToken("00000000-0000-0000-1000-000000000000") .expMonth("06") .expYear("2027") .hostname("hostname") .memo("New Card") + .networkProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .addPendingCommand("string") .productId("1") .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") + .substatus(NonPciCard.Substatus.LOST) .cvv("776") .pan("4111111289144142") .build() @@ -74,14 +77,17 @@ internal class CardTest { assertThat(card.type()).isEqualTo(NonPciCard.Type.MERCHANT_LOCKED) assertThat(card.authRuleTokens().getOrNull()).containsExactly("string") assertThat(card.cardholderCurrency()).contains("USD") + assertThat(card.comment()).contains("comment") assertThat(card.digitalCardArtToken()).contains("00000000-0000-0000-1000-000000000000") assertThat(card.expMonth()).contains("06") assertThat(card.expYear()).contains("2027") assertThat(card.hostname()).contains("hostname") assertThat(card.memo()).contains("New Card") + assertThat(card.networkProgramToken()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") assertThat(card.pendingCommands().getOrNull()).containsExactly("string") assertThat(card.productId()).contains("1") assertThat(card.replacementFor()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") + assertThat(card.substatus()).contains(NonPciCard.Substatus.LOST) assertThat(card.cvv()).contains("776") assertThat(card.pan()).contains("4111111289144142") } @@ -114,14 +120,17 @@ internal class CardTest { .type(NonPciCard.Type.MERCHANT_LOCKED) .addAuthRuleToken("string") .cardholderCurrency("USD") + .comment("comment") .digitalCardArtToken("00000000-0000-0000-1000-000000000000") .expMonth("06") .expYear("2027") .hostname("hostname") .memo("New Card") + .networkProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .addPendingCommand("string") .productId("1") .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") + .substatus(NonPciCard.Substatus.LOST) .cvv("776") .pan("4111111289144142") .build() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardUpdateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardUpdateParamsTest.kt index 64f8421ed..5d229f8b0 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardUpdateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardUpdateParamsTest.kt @@ -11,13 +11,16 @@ internal class CardUpdateParamsTest { fun create() { CardUpdateParams.builder() .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .memo("Updated Name") + .networkProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pin("pin") .pinStatus(CardUpdateParams.PinStatus.OK) .spendLimit(100L) .spendLimitDuration(SpendLimitDuration.FOREVER) .state(CardUpdateParams.State.OPEN) + .substatus(CardUpdateParams.Substatus.LOST) .build() } @@ -36,24 +39,30 @@ internal class CardUpdateParamsTest { val params = CardUpdateParams.builder() .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .memo("Updated Name") + .networkProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pin("pin") .pinStatus(CardUpdateParams.PinStatus.OK) .spendLimit(100L) .spendLimitDuration(SpendLimitDuration.FOREVER) .state(CardUpdateParams.State.OPEN) + .substatus(CardUpdateParams.Substatus.LOST) .build() val body = params._body() + assertThat(body.comment()).contains("comment") assertThat(body.digitalCardArtToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.memo()).contains("Updated Name") + assertThat(body.networkProgramToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.pin()).contains("pin") assertThat(body.pinStatus()).contains(CardUpdateParams.PinStatus.OK) assertThat(body.spendLimit()).contains(100L) assertThat(body.spendLimitDuration()).contains(SpendLimitDuration.FOREVER) assertThat(body.state()).contains(CardUpdateParams.State.OPEN) + assertThat(body.substatus()).contains(CardUpdateParams.Substatus.LOST) } @Test diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalResourceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalResourceTest.kt new file mode 100644 index 000000000..fb6751428 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalResourceTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExternalResourceTest { + + @Test + fun create() { + val externalResource = + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + + assertThat(externalResource.externalResourceToken()).isEqualTo("external_resource_token") + assertThat(externalResource.externalResourceType()) + .isEqualTo(ExternalResourceType.STATEMENT) + assertThat(externalResource.externalResourceSubToken()) + .contains("external_resource_sub_token") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val externalResource = + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + + val roundtrippedExternalResource = + jsonMapper.readValue( + jsonMapper.writeValueAsString(externalResource), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExternalResource).isEqualTo(externalResource) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationCreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationCreateParamsTest.kt index af7010761..64ab21ce8 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationCreateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationCreateParamsTest.kt @@ -19,6 +19,7 @@ internal class ManagementOperationCreateParamsTest { .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .memo("memo") + .onClosedAccount(ManagementOperationCreateParams.OnClosedAccount.FAIL) .subtype("subtype") .userDefinedId("user_defined_id") .build() @@ -40,6 +41,7 @@ internal class ManagementOperationCreateParamsTest { .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .memo("memo") + .onClosedAccount(ManagementOperationCreateParams.OnClosedAccount.FAIL) .subtype("subtype") .userDefinedId("user_defined_id") .build() @@ -57,6 +59,8 @@ internal class ManagementOperationCreateParamsTest { assertThat(body.financialAccountToken()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.token()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.memo()).contains("memo") + assertThat(body.onClosedAccount()) + .contains(ManagementOperationCreateParams.OnClosedAccount.FAIL) assertThat(body.subtype()).contains("subtype") assertThat(body.userDefinedId()).contains("user_defined_id") } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationListPageResponseTest.kt index ec0e9d4f1..7c1679e7b 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationListPageResponseTest.kt @@ -67,6 +67,13 @@ internal class ManagementOperationListPageResponseTest { .build() ) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) .userDefinedId("user_defined_id") .build() ) @@ -121,6 +128,13 @@ internal class ManagementOperationListPageResponseTest { .build() ) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) .userDefinedId("user_defined_id") .build() ) @@ -184,6 +198,13 @@ internal class ManagementOperationListPageResponseTest { .build() ) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) .userDefinedId("user_defined_id") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationTransactionTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationTransactionTest.kt index 8df41e9ab..bc1592f8d 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationTransactionTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationTransactionTest.kt @@ -57,6 +57,13 @@ internal class ManagementOperationTransactionTest { .build() ) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) .userDefinedId("user_defined_id") .build() @@ -111,6 +118,14 @@ internal class ManagementOperationTransactionTest { ) assertThat(managementOperationTransaction.updated()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(managementOperationTransaction.externalResource()) + .contains( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) assertThat(managementOperationTransaction.userDefinedId()).contains("user_defined_id") } @@ -161,6 +176,13 @@ internal class ManagementOperationTransactionTest { .build() ) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) .userDefinedId("user_defined_id") .build() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramListPageResponseTest.kt new file mode 100644 index 000000000..405ecc8db --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramListPageResponseTest.kt @@ -0,0 +1,70 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NetworkProgramListPageResponseTest { + + @Test + fun create() { + val networkProgramListPageResponse = + NetworkProgramListPageResponse.builder() + .addData( + NetworkProgram.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultProductCode("default_product_code") + .name("name") + .registeredProgramIdentificationNumber( + "registered_program_identification_number" + ) + .build() + ) + .hasMore(true) + .build() + + assertThat(networkProgramListPageResponse.data()) + .containsExactly( + NetworkProgram.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultProductCode("default_product_code") + .name("name") + .registeredProgramIdentificationNumber( + "registered_program_identification_number" + ) + .build() + ) + assertThat(networkProgramListPageResponse.hasMore()).isEqualTo(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val networkProgramListPageResponse = + NetworkProgramListPageResponse.builder() + .addData( + NetworkProgram.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultProductCode("default_product_code") + .name("name") + .registeredProgramIdentificationNumber( + "registered_program_identification_number" + ) + .build() + ) + .hasMore(true) + .build() + + val roundtrippedNetworkProgramListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(networkProgramListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedNetworkProgramListPageResponse) + .isEqualTo(networkProgramListPageResponse) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramListParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramListParamsTest.kt new file mode 100644 index 000000000..0c8187578 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramListParamsTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NetworkProgramListParamsTest { + + @Test + fun create() { + NetworkProgramListParams.builder() + .begin(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .pageSize(1L) + .build() + } + + @Test + fun queryParams() { + val params = + NetworkProgramListParams.builder() + .begin(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .pageSize(1L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("begin", "2019-12-27T18:11:19.117Z") + .put("end", "2019-12-27T18:11:19.117Z") + .put("page_size", "1") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = NetworkProgramListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramRetrieveParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramRetrieveParamsTest.kt new file mode 100644 index 000000000..f1366c3ea --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NetworkProgramRetrieveParamsTest { + + @Test + fun create() { + NetworkProgramRetrieveParams.builder() + .networkProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + NetworkProgramRetrieveParams.builder() + .networkProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramTest.kt new file mode 100644 index 000000000..e3e022d37 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkProgramTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NetworkProgramTest { + + @Test + fun create() { + val networkProgram = + NetworkProgram.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultProductCode("default_product_code") + .name("name") + .registeredProgramIdentificationNumber("registered_program_identification_number") + .build() + + assertThat(networkProgram.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(networkProgram.defaultProductCode()).isEqualTo("default_product_code") + assertThat(networkProgram.name()).isEqualTo("name") + assertThat(networkProgram.registeredProgramIdentificationNumber()) + .isEqualTo("registered_program_identification_number") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val networkProgram = + NetworkProgram.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .defaultProductCode("default_product_code") + .name("name") + .registeredProgramIdentificationNumber("registered_program_identification_number") + .build() + + val roundtrippedNetworkProgram = + jsonMapper.readValue( + jsonMapper.writeValueAsString(networkProgram), + jacksonTypeRef(), + ) + + assertThat(roundtrippedNetworkProgram).isEqualTo(networkProgram) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NonPciCardTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NonPciCardTest.kt index afbe872c3..222bda14c 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NonPciCardTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NonPciCardTest.kt @@ -38,14 +38,17 @@ internal class NonPciCardTest { .type(NonPciCard.Type.MERCHANT_LOCKED) .addAuthRuleToken("string") .cardholderCurrency("USD") + .comment("comment") .digitalCardArtToken("00000000-0000-0000-1000-000000000000") .expMonth("06") .expYear("2027") .hostname("hostname") .memo("New Card") + .networkProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .addPendingCommand("string") .productId("1") .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") + .substatus(NonPciCard.Substatus.LOST) .build() assertThat(nonPciCard.token()).isEqualTo("7ef7d65c-9023-4da3-b113-3b8583fd7951") @@ -72,15 +75,19 @@ internal class NonPciCardTest { assertThat(nonPciCard.type()).isEqualTo(NonPciCard.Type.MERCHANT_LOCKED) assertThat(nonPciCard.authRuleTokens().getOrNull()).containsExactly("string") assertThat(nonPciCard.cardholderCurrency()).contains("USD") + assertThat(nonPciCard.comment()).contains("comment") assertThat(nonPciCard.digitalCardArtToken()) .contains("00000000-0000-0000-1000-000000000000") assertThat(nonPciCard.expMonth()).contains("06") assertThat(nonPciCard.expYear()).contains("2027") assertThat(nonPciCard.hostname()).contains("hostname") assertThat(nonPciCard.memo()).contains("New Card") + assertThat(nonPciCard.networkProgramToken()) + .contains("5e9483eb-8103-4e16-9794-2106111b2eca") assertThat(nonPciCard.pendingCommands().getOrNull()).containsExactly("string") assertThat(nonPciCard.productId()).contains("1") assertThat(nonPciCard.replacementFor()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") + assertThat(nonPciCard.substatus()).contains(NonPciCard.Substatus.LOST) } @Test @@ -111,14 +118,17 @@ internal class NonPciCardTest { .type(NonPciCard.Type.MERCHANT_LOCKED) .addAuthRuleToken("string") .cardholderCurrency("USD") + .comment("comment") .digitalCardArtToken("00000000-0000-0000-1000-000000000000") .expMonth("06") .expYear("2027") .hostname("hostname") .memo("New Card") + .networkProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .addPendingCommand("string") .productId("1") .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") + .substatus(NonPciCard.Substatus.LOST) .build() val roundtrippedNonPciCard = diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/VelocityLimitParamsPeriodWindowTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/VelocityLimitParamsPeriodWindowTest.kt new file mode 100644 index 000000000..a0ea312ba --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/VelocityLimitParamsPeriodWindowTest.kt @@ -0,0 +1,292 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.JsonValue +import com.lithic.api.core.jsonMapper +import com.lithic.api.errors.LithicInvalidDataException +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows + +internal class VelocityLimitParamsPeriodWindowTest { + + @Test + fun ofTrailing() { + val trailing = 10L + + val velocityLimitParamsPeriodWindow = VelocityLimitParamsPeriodWindow.ofTrailing(trailing) + + assertThat(velocityLimitParamsPeriodWindow.trailing()).contains(trailing) + assertThat(velocityLimitParamsPeriodWindow.fixed()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.trailingWindowObject()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowDay()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowWeek()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowMonth()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowYear()).isEmpty + } + + @Test + fun ofTrailingRoundtrip() { + val jsonMapper = jsonMapper() + val velocityLimitParamsPeriodWindow = VelocityLimitParamsPeriodWindow.ofTrailing(10L) + + val roundtrippedVelocityLimitParamsPeriodWindow = + jsonMapper.readValue( + jsonMapper.writeValueAsString(velocityLimitParamsPeriodWindow), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVelocityLimitParamsPeriodWindow) + .isEqualTo(velocityLimitParamsPeriodWindow) + } + + @Test + fun ofFixed() { + val fixed = VelocityLimitParamsPeriodWindow.FixedWindow.DAY + + val velocityLimitParamsPeriodWindow = VelocityLimitParamsPeriodWindow.ofFixed(fixed) + + assertThat(velocityLimitParamsPeriodWindow.trailing()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixed()).contains(fixed) + assertThat(velocityLimitParamsPeriodWindow.trailingWindowObject()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowDay()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowWeek()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowMonth()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowYear()).isEmpty + } + + @Test + fun ofFixedRoundtrip() { + val jsonMapper = jsonMapper() + val velocityLimitParamsPeriodWindow = + VelocityLimitParamsPeriodWindow.ofFixed(VelocityLimitParamsPeriodWindow.FixedWindow.DAY) + + val roundtrippedVelocityLimitParamsPeriodWindow = + jsonMapper.readValue( + jsonMapper.writeValueAsString(velocityLimitParamsPeriodWindow), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVelocityLimitParamsPeriodWindow) + .isEqualTo(velocityLimitParamsPeriodWindow) + } + + @Test + fun ofTrailingWindowObject() { + val trailingWindowObject = + VelocityLimitParamsPeriodWindow.TrailingWindowObject.builder() + .duration(10L) + .type(VelocityLimitParamsPeriodWindow.TrailingWindowObject.Type.CUSTOM) + .build() + + val velocityLimitParamsPeriodWindow = + VelocityLimitParamsPeriodWindow.ofTrailingWindowObject(trailingWindowObject) + + assertThat(velocityLimitParamsPeriodWindow.trailing()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixed()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.trailingWindowObject()) + .contains(trailingWindowObject) + assertThat(velocityLimitParamsPeriodWindow.fixedWindowDay()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowWeek()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowMonth()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowYear()).isEmpty + } + + @Test + fun ofTrailingWindowObjectRoundtrip() { + val jsonMapper = jsonMapper() + val velocityLimitParamsPeriodWindow = + VelocityLimitParamsPeriodWindow.ofTrailingWindowObject( + VelocityLimitParamsPeriodWindow.TrailingWindowObject.builder() + .duration(10L) + .type(VelocityLimitParamsPeriodWindow.TrailingWindowObject.Type.CUSTOM) + .build() + ) + + val roundtrippedVelocityLimitParamsPeriodWindow = + jsonMapper.readValue( + jsonMapper.writeValueAsString(velocityLimitParamsPeriodWindow), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVelocityLimitParamsPeriodWindow) + .isEqualTo(velocityLimitParamsPeriodWindow) + } + + @Test + fun ofFixedWindowDay() { + val fixedWindowDay = + VelocityLimitParamsPeriodWindow.FixedWindowDay.builder() + .type(VelocityLimitParamsPeriodWindow.FixedWindowDay.Type.DAY) + .build() + + val velocityLimitParamsPeriodWindow = + VelocityLimitParamsPeriodWindow.ofFixedWindowDay(fixedWindowDay) + + assertThat(velocityLimitParamsPeriodWindow.trailing()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixed()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.trailingWindowObject()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowDay()).contains(fixedWindowDay) + assertThat(velocityLimitParamsPeriodWindow.fixedWindowWeek()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowMonth()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowYear()).isEmpty + } + + @Test + fun ofFixedWindowDayRoundtrip() { + val jsonMapper = jsonMapper() + val velocityLimitParamsPeriodWindow = + VelocityLimitParamsPeriodWindow.ofFixedWindowDay( + VelocityLimitParamsPeriodWindow.FixedWindowDay.builder() + .type(VelocityLimitParamsPeriodWindow.FixedWindowDay.Type.DAY) + .build() + ) + + val roundtrippedVelocityLimitParamsPeriodWindow = + jsonMapper.readValue( + jsonMapper.writeValueAsString(velocityLimitParamsPeriodWindow), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVelocityLimitParamsPeriodWindow) + .isEqualTo(velocityLimitParamsPeriodWindow) + } + + @Test + fun ofFixedWindowWeek() { + val fixedWindowWeek = + VelocityLimitParamsPeriodWindow.FixedWindowWeek.builder() + .dayOfWeek(1L) + .type(VelocityLimitParamsPeriodWindow.FixedWindowWeek.Type.WEEK) + .build() + + val velocityLimitParamsPeriodWindow = + VelocityLimitParamsPeriodWindow.ofFixedWindowWeek(fixedWindowWeek) + + assertThat(velocityLimitParamsPeriodWindow.trailing()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixed()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.trailingWindowObject()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowDay()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowWeek()).contains(fixedWindowWeek) + assertThat(velocityLimitParamsPeriodWindow.fixedWindowMonth()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowYear()).isEmpty + } + + @Test + fun ofFixedWindowWeekRoundtrip() { + val jsonMapper = jsonMapper() + val velocityLimitParamsPeriodWindow = + VelocityLimitParamsPeriodWindow.ofFixedWindowWeek( + VelocityLimitParamsPeriodWindow.FixedWindowWeek.builder() + .dayOfWeek(1L) + .type(VelocityLimitParamsPeriodWindow.FixedWindowWeek.Type.WEEK) + .build() + ) + + val roundtrippedVelocityLimitParamsPeriodWindow = + jsonMapper.readValue( + jsonMapper.writeValueAsString(velocityLimitParamsPeriodWindow), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVelocityLimitParamsPeriodWindow) + .isEqualTo(velocityLimitParamsPeriodWindow) + } + + @Test + fun ofFixedWindowMonth() { + val fixedWindowMonth = + VelocityLimitParamsPeriodWindow.FixedWindowMonth.builder() + .dayOfMonth(1L) + .type(VelocityLimitParamsPeriodWindow.FixedWindowMonth.Type.MONTH) + .build() + + val velocityLimitParamsPeriodWindow = + VelocityLimitParamsPeriodWindow.ofFixedWindowMonth(fixedWindowMonth) + + assertThat(velocityLimitParamsPeriodWindow.trailing()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixed()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.trailingWindowObject()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowDay()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowWeek()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowMonth()).contains(fixedWindowMonth) + assertThat(velocityLimitParamsPeriodWindow.fixedWindowYear()).isEmpty + } + + @Test + fun ofFixedWindowMonthRoundtrip() { + val jsonMapper = jsonMapper() + val velocityLimitParamsPeriodWindow = + VelocityLimitParamsPeriodWindow.ofFixedWindowMonth( + VelocityLimitParamsPeriodWindow.FixedWindowMonth.builder() + .dayOfMonth(1L) + .type(VelocityLimitParamsPeriodWindow.FixedWindowMonth.Type.MONTH) + .build() + ) + + val roundtrippedVelocityLimitParamsPeriodWindow = + jsonMapper.readValue( + jsonMapper.writeValueAsString(velocityLimitParamsPeriodWindow), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVelocityLimitParamsPeriodWindow) + .isEqualTo(velocityLimitParamsPeriodWindow) + } + + @Test + fun ofFixedWindowYear() { + val fixedWindowYear = + VelocityLimitParamsPeriodWindow.FixedWindowYear.builder() + .dayOfMonth(1L) + .month(1L) + .type(VelocityLimitParamsPeriodWindow.FixedWindowYear.Type.YEAR) + .build() + + val velocityLimitParamsPeriodWindow = + VelocityLimitParamsPeriodWindow.ofFixedWindowYear(fixedWindowYear) + + assertThat(velocityLimitParamsPeriodWindow.trailing()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixed()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.trailingWindowObject()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowDay()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowWeek()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowMonth()).isEmpty + assertThat(velocityLimitParamsPeriodWindow.fixedWindowYear()).contains(fixedWindowYear) + } + + @Test + fun ofFixedWindowYearRoundtrip() { + val jsonMapper = jsonMapper() + val velocityLimitParamsPeriodWindow = + VelocityLimitParamsPeriodWindow.ofFixedWindowYear( + VelocityLimitParamsPeriodWindow.FixedWindowYear.builder() + .dayOfMonth(1L) + .month(1L) + .type(VelocityLimitParamsPeriodWindow.FixedWindowYear.Type.YEAR) + .build() + ) + + val roundtrippedVelocityLimitParamsPeriodWindow = + jsonMapper.readValue( + jsonMapper.writeValueAsString(velocityLimitParamsPeriodWindow), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVelocityLimitParamsPeriodWindow) + .isEqualTo(velocityLimitParamsPeriodWindow) + } + + @Test + fun incompatibleJsonShapeDeserializesToUnknown() { + val value = JsonValue.from(listOf("invalid", "array")) + val velocityLimitParamsPeriodWindow = + jsonMapper().convertValue(value, jacksonTypeRef()) + + val e = + assertThrows { velocityLimitParamsPeriodWindow.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/VelocityLimitParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/VelocityLimitParamsTest.kt index b112b33b1..455cc706c 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/VelocityLimitParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/VelocityLimitParamsTest.kt @@ -37,7 +37,7 @@ internal class VelocityLimitParamsTest { .build() ) assertThat(velocityLimitParams.period()) - .isEqualTo(VelocityLimitParams.Period.ofTrailingWindow(10L)) + .isEqualTo(VelocityLimitParamsPeriodWindow.ofTrailing(10L)) assertThat(velocityLimitParams.scope()).isEqualTo(VelocityLimitParams.Scope.CARD) assertThat(velocityLimitParams.limitAmount()).contains(10000L) assertThat(velocityLimitParams.limitCount()).contains(0L) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt index e3d84869c..736bd21f9 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt @@ -86,7 +86,9 @@ internal class ErrorHandlingTest { .pin("pin") .productId("1") .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() .address1("5 Broad Street") @@ -140,7 +142,9 @@ internal class ErrorHandlingTest { .pin("pin") .productId("1") .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() .address1("5 Broad Street") @@ -194,7 +198,9 @@ internal class ErrorHandlingTest { .pin("pin") .productId("1") .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() .address1("5 Broad Street") @@ -248,7 +254,9 @@ internal class ErrorHandlingTest { .pin("pin") .productId("1") .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() .address1("5 Broad Street") @@ -302,7 +310,9 @@ internal class ErrorHandlingTest { .pin("pin") .productId("1") .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() .address1("5 Broad Street") @@ -356,7 +366,9 @@ internal class ErrorHandlingTest { .pin("pin") .productId("1") .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() .address1("5 Broad Street") @@ -410,7 +422,9 @@ internal class ErrorHandlingTest { .pin("pin") .productId("1") .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() .address1("5 Broad Street") @@ -464,7 +478,9 @@ internal class ErrorHandlingTest { .pin("pin") .productId("1") .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() .address1("5 Broad Street") @@ -516,7 +532,9 @@ internal class ErrorHandlingTest { .pin("pin") .productId("1") .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() .address1("5 Broad Street") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/ServiceParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/ServiceParamsTest.kt index a136b1459..56ab4c026 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/ServiceParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/ServiceParamsTest.kt @@ -56,7 +56,9 @@ internal class ServiceParamsTest { .pin("pin") .productId("1") .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() .address1("5 Broad Street") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/AccountServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/AccountServiceAsyncTest.kt index 727a4f98a..c5517d3e1 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/AccountServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/AccountServiceAsyncTest.kt @@ -41,10 +41,12 @@ internal class AccountServiceAsyncTest { accountServiceAsync.update( AccountUpdateParams.builder() .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") .dailySpendLimit(1000L) .lifetimeSpendLimit(0L) .monthlySpendLimit(0L) .state(AccountUpdateParams.State.ACTIVE) + .substatus(AccountUpdateParams.Substatus.FRAUD_IDENTIFIED) .verificationAddress( AccountUpdateParams.VerificationAddress.builder() .address1("address1") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt index 7660ff9c4..159c0047c 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt @@ -45,7 +45,9 @@ internal class CardServiceAsyncTest { .pin("pin") .productId("1") .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() .address1("5 Broad Street") @@ -100,13 +102,16 @@ internal class CardServiceAsyncTest { cardServiceAsync.update( CardUpdateParams.builder() .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .memo("Updated Name") + .networkProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pin("pin") .pinStatus(CardUpdateParams.PinStatus.OK) .spendLimit(100L) .spendLimitDuration(SpendLimitDuration.FOREVER) .state(CardUpdateParams.State.OPEN) + .substatus(CardUpdateParams.Substatus.LOST) .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/ManagementOperationServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/ManagementOperationServiceAsyncTest.kt index a6c16bbc1..8162008fa 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/ManagementOperationServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/ManagementOperationServiceAsyncTest.kt @@ -37,6 +37,7 @@ internal class ManagementOperationServiceAsyncTest { .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .memo("memo") + .onClosedAccount(ManagementOperationCreateParams.OnClosedAccount.FAIL) .subtype("subtype") .userDefinedId("user_defined_id") .build() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsyncTest.kt new file mode 100644 index 000000000..839d359ac --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/NetworkProgramServiceAsyncTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClientAsync +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class NetworkProgramServiceAsyncTest { + + @Test + fun retrieve() { + val client = + LithicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val networkProgramServiceAsync = client.networkPrograms() + + val networkProgramFuture = + networkProgramServiceAsync.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val networkProgram = networkProgramFuture.get() + networkProgram.validate() + } + + @Test + fun list() { + val client = + LithicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val networkProgramServiceAsync = client.networkPrograms() + + val pageFuture = networkProgramServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountServiceTest.kt index 709754d03..ea01b8c40 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountServiceTest.kt @@ -40,10 +40,12 @@ internal class AccountServiceTest { accountService.update( AccountUpdateParams.builder() .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") .dailySpendLimit(1000L) .lifetimeSpendLimit(0L) .monthlySpendLimit(0L) .state(AccountUpdateParams.State.ACTIVE) + .substatus(AccountUpdateParams.Substatus.FRAUD_IDENTIFIED) .verificationAddress( AccountUpdateParams.VerificationAddress.builder() .address1("address1") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt index d92c59dce..95f9e2911 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt @@ -45,7 +45,9 @@ internal class CardServiceTest { .pin("pin") .productId("1") .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementComment("replacement_comment") .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() .address1("5 Broad Street") @@ -98,13 +100,16 @@ internal class CardServiceTest { cardService.update( CardUpdateParams.builder() .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .comment("comment") .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .memo("Updated Name") + .networkProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pin("pin") .pinStatus(CardUpdateParams.PinStatus.OK) .spendLimit(100L) .spendLimitDuration(SpendLimitDuration.FOREVER) .state(CardUpdateParams.State.OPEN) + .substatus(CardUpdateParams.Substatus.LOST) .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ManagementOperationServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ManagementOperationServiceTest.kt index 59f4d7e91..9293d3ecf 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ManagementOperationServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ManagementOperationServiceTest.kt @@ -37,6 +37,7 @@ internal class ManagementOperationServiceTest { .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .memo("memo") + .onClosedAccount(ManagementOperationCreateParams.OnClosedAccount.FAIL) .subtype("subtype") .userDefinedId("user_defined_id") .build() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/NetworkProgramServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/NetworkProgramServiceTest.kt new file mode 100644 index 000000000..869c40da8 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/NetworkProgramServiceTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClient +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class NetworkProgramServiceTest { + + @Test + fun retrieve() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val networkProgramService = client.networkPrograms() + + val networkProgram = networkProgramService.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + networkProgram.validate() + } + + @Test + fun list() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val networkProgramService = client.networkPrograms() + + val page = networkProgramService.list() + + page.response().validate() + } +} From c59e95c98f2bfcba62374d39aaf820a6c3d687d2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 21:48:09 +0000 Subject: [PATCH 4/5] chore(ci): bump `actions/setup-java` to v4 --- .github/workflows/publish-sonatype.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 16a7e4270..de66e5945 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: temurin java-version: | From 834ee23bd62ad9092b37d87a540974d735d87d75 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 21:48:37 +0000 Subject: [PATCH 5/5] release: 0.96.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 14 ++++++++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 2292ca706..d486cde74 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.95.0" + ".": "0.96.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c5f786210..c76911aaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.96.0 (2025-07-15) + +Full Changelog: [v0.95.0...v0.96.0](https://github.com/lithic-com/lithic-java/compare/v0.95.0...v0.96.0) + +### Features + +* **api:** adds Network Programs and Account/Card Sub-statuses ([076028b](https://github.com/lithic-com/lithic-java/commit/076028b56cbab680e6e56fd31578009de54ed394)) + + +### Chores + +* **ci:** bump `actions/setup-java` to v4 ([c59e95c](https://github.com/lithic-com/lithic-java/commit/c59e95c98f2bfcba62374d39aaf820a6c3d687d2)) +* **ci:** ensure docs generation always succeeds ([1bf367a](https://github.com/lithic-com/lithic-java/commit/1bf367a7cffe53272387316678edaa89035f2330)) + ## 0.95.0 (2025-07-08) Full Changelog: [v0.94.1...v0.95.0](https://github.com/lithic-com/lithic-java/compare/v0.94.1...v0.95.0) diff --git a/README.md b/README.md index f7901d551..53ba3ec55 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.lithic.api/lithic-java)](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.95.0) -[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.95.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.95.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.lithic.api/lithic-java)](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.96.0) +[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.96.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.96.0) @@ -13,7 +13,7 @@ The Lithic Java SDK is similar to the Lithic Kotlin SDK but with minor differenc -The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.lithic.api/lithic-java/0.95.0). +The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.lithic.api/lithic-java/0.96.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [docs.lithic.com](https://docs.lithic ### Gradle ```kotlin -implementation("com.lithic.api:lithic-java:0.95.0") +implementation("com.lithic.api:lithic-java:0.96.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.lithic.api:lithic-java:0.95.0") com.lithic.api lithic-java - 0.95.0 + 0.96.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 66686cd44..147075849 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.lithic.api" - version = "0.95.0" // x-release-please-version + version = "0.96.0" // x-release-please-version } subprojects {