diff --git a/.stats.yml b/.stats.yml index 97e2fbfc..953d452f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 131 +configured_endpoints: 146 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 8b6d12f2..ecdd5b1e 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 @@ -60,6 +60,8 @@ interface LithicClient { fun creditProducts(): CreditProductService + fun externalPayments(): ExternalPaymentService + /** Status of api */ @JvmOverloads fun 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 63666046..3eb8104c 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 @@ -61,6 +61,8 @@ interface LithicClientAsync { fun creditProducts(): CreditProductServiceAsync + fun externalPayments(): ExternalPaymentServiceAsync + /** Status of api */ @JvmOverloads fun 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 7e56a77a..c383a469 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 @@ -98,6 +98,10 @@ constructor( CreditProductServiceAsyncImpl(clientOptions) } + private val externalPayments: ExternalPaymentServiceAsync by lazy { + ExternalPaymentServiceAsyncImpl(clientOptions) + } + override fun sync(): LithicClient = sync override fun accounts(): AccountServiceAsync = accounts @@ -149,6 +153,8 @@ constructor( override fun creditProducts(): CreditProductServiceAsync = creditProducts + override fun externalPayments(): ExternalPaymentServiceAsync = externalPayments + 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 be16dd5e..acc2ddb1 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 @@ -93,6 +93,10 @@ constructor( CreditProductServiceImpl(clientOptions) } + private val externalPayments: ExternalPaymentService by lazy { + ExternalPaymentServiceImpl(clientOptions) + } + override fun async(): LithicClientAsync = async override fun accounts(): AccountService = accounts @@ -143,6 +147,8 @@ constructor( override fun creditProducts(): CreditProductService = creditProducts + override fun externalPayments(): ExternalPaymentService = externalPayments + private val apiStatusHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountFinancialAccountType.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountFinancialAccountType.kt new file mode 100644 index 00000000..f8bba70e --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountFinancialAccountType.kt @@ -0,0 +1,66 @@ +// 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.core.JsonValue +import com.lithic.api.errors.LithicInvalidDataException + +class AccountFinancialAccountType +@JsonCreator +private constructor( + private val value: JsonField, +) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccountFinancialAccountType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ISSUING = AccountFinancialAccountType(JsonField.of("ISSUING")) + + @JvmField val OPERATING = AccountFinancialAccountType(JsonField.of("OPERATING")) + + @JvmStatic fun of(value: String) = AccountFinancialAccountType(JsonField.of(value)) + } + + enum class Known { + ISSUING, + OPERATING, + } + + enum class Value { + ISSUING, + OPERATING, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ISSUING -> Value.ISSUING + OPERATING -> Value.OPERATING + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ISSUING -> Known.ISSUING + OPERATING -> Known.OPERATING + else -> throw LithicInvalidDataException("Unknown AccountFinancialAccountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolder.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolder.kt index c1de9026..425972f3 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolder.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolder.kt @@ -55,14 +55,14 @@ private constructor( Optional.ofNullable(accountToken.getNullable("account_token")) /** - * Only present when user_type == 'BUSINESS'. List of all entities with >25% ownership in the + * Only present when user_type == "BUSINESS". List of all entities with >25% ownership in the * company. */ fun beneficialOwnerEntities(): Optional> = Optional.ofNullable(beneficialOwnerEntities.getNullable("beneficial_owner_entities")) /** - * Only present when user_type == 'BUSINESS'. List of all individuals with >25% ownership in the + * Only present when user_type == "BUSINESS". List of all individuals with >25% ownership in the * company. */ fun beneficialOwnerIndividuals(): Optional> = @@ -77,14 +77,14 @@ private constructor( Optional.ofNullable(businessAccountToken.getNullable("business_account_token")) /** - * Only present when user_type == 'BUSINESS'. Information about the business for which the + * Only present when user_type == "BUSINESS". Information about the business for which the * account is being opened and KYB is being run. */ fun businessEntity(): Optional = Optional.ofNullable(businessEntity.getNullable("business_entity")) /** - * Only present when user_type == 'BUSINESS'. An individual with significant responsibility for + * Only present when user_type == "BUSINESS". An individual with significant responsibility for * managing the legal entity (e.g., a Chief Executive Officer, Chief Financial Officer, Chief * Operating Officer, Managing Member, General Partner, President, Vice President, or * Treasurer). This can be an executive, or someone who will have program-wide access to the @@ -98,8 +98,8 @@ private constructor( fun created(): OffsetDateTime = created.getRequired("created") /** - * < Deprecated. Use control_person.email when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.email when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary email of Account Holder. */ fun email(): Optional = Optional.ofNullable(email.getNullable("email")) @@ -115,19 +115,19 @@ private constructor( fun externalId(): Optional = Optional.ofNullable(externalId.getNullable("external_id")) /** - * Only present when user_type == 'INDIVIDUAL'. Information about the individual for which the + * Only present when user_type == "INDIVIDUAL". Information about the individual for which the * account is being opened and KYC is being run. */ fun individual(): Optional = Optional.ofNullable(individual.getNullable("individual")) - /** Only present when user_type == 'BUSINESS'. User-submitted description of the business. */ + /** Only present when user_type == "BUSINESS". User-submitted description of the business. */ fun natureOfBusiness(): Optional = Optional.ofNullable(natureOfBusiness.getNullable("nature_of_business")) /** - * < Deprecated. Use control_person.phone_number when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.phone_number when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary phone of Account Holder, entered in E.164 format. */ fun phoneNumber(): Optional = @@ -155,10 +155,10 @@ private constructor( fun token(): String = token.getRequired("token") /** - * The type of Account Holder. If the type is 'INDIVIDUAL', the 'individual' attribute will be - * present. If the type is 'BUSINESS' then the 'business_entity', 'control_person', - * 'beneficial_owner_individuals', 'beneficial_owner_entities', 'nature_of_business', and - * 'website_url' attributes will be present. + * The type of Account Holder. If the type is "INDIVIDUAL", the "individual" attribute will be + * present. If the type is "BUSINESS" then the "business_entity", "control_person", + * "beneficial_owner_individuals", "beneficial_owner_entities", "nature_of_business", and + * "website_url" attributes will be present. */ fun userType(): Optional = Optional.ofNullable(userType.getNullable("user_type")) @@ -167,20 +167,20 @@ private constructor( Optional.ofNullable(verificationApplication.getNullable("verification_application")) /** - * Only present for 'KYB_BASIC' and 'KYC_ADVANCED' workflows. A list of documents required for + * Only present for "KYB_BASIC" and "KYC_ADVANCED" workflows. A list of documents required for * the account holder to be approved. */ fun requiredDocuments(): Optional> = Optional.ofNullable(requiredDocuments.getNullable("required_documents")) - /** Only present when user_type == 'BUSINESS'. Business's primary website. */ + /** Only present when user_type == "BUSINESS". Business's primary website. */ fun websiteUrl(): Optional = Optional.ofNullable(websiteUrl.getNullable("website_url")) /** Globally unique identifier for the account. */ @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken /** - * Only present when user_type == 'BUSINESS'. List of all entities with >25% ownership in the + * Only present when user_type == "BUSINESS". List of all entities with >25% ownership in the * company. */ @JsonProperty("beneficial_owner_entities") @@ -188,7 +188,7 @@ private constructor( fun _beneficialOwnerEntities() = beneficialOwnerEntities /** - * Only present when user_type == 'BUSINESS'. List of all individuals with >25% ownership in the + * Only present when user_type == "BUSINESS". List of all individuals with >25% ownership in the * company. */ @JsonProperty("beneficial_owner_individuals") @@ -205,13 +205,13 @@ private constructor( fun _businessAccountToken() = businessAccountToken /** - * Only present when user_type == 'BUSINESS'. Information about the business for which the + * Only present when user_type == "BUSINESS". Information about the business for which the * account is being opened and KYB is being run. */ @JsonProperty("business_entity") @ExcludeMissing fun _businessEntity() = businessEntity /** - * Only present when user_type == 'BUSINESS'. An individual with significant responsibility for + * Only present when user_type == "BUSINESS". An individual with significant responsibility for * managing the legal entity (e.g., a Chief Executive Officer, Chief Financial Officer, Chief * Operating Officer, Managing Member, General Partner, President, Vice President, or * Treasurer). This can be an executive, or someone who will have program-wide access to the @@ -224,8 +224,8 @@ private constructor( @JsonProperty("created") @ExcludeMissing fun _created() = created /** - * < Deprecated. Use control_person.email when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.email when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary email of Account Holder. */ @JsonProperty("email") @ExcludeMissing fun _email() = email @@ -240,17 +240,17 @@ private constructor( @JsonProperty("external_id") @ExcludeMissing fun _externalId() = externalId /** - * Only present when user_type == 'INDIVIDUAL'. Information about the individual for which the + * Only present when user_type == "INDIVIDUAL". Information about the individual for which the * account is being opened and KYC is being run. */ @JsonProperty("individual") @ExcludeMissing fun _individual() = individual - /** Only present when user_type == 'BUSINESS'. User-submitted description of the business. */ + /** Only present when user_type == "BUSINESS". User-submitted description of the business. */ @JsonProperty("nature_of_business") @ExcludeMissing fun _natureOfBusiness() = natureOfBusiness /** - * < Deprecated. Use control_person.phone_number when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.phone_number when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary phone of Account Holder, entered in E.164 format. */ @JsonProperty("phone_number") @ExcludeMissing fun _phoneNumber() = phoneNumber @@ -276,10 +276,10 @@ private constructor( @JsonProperty("token") @ExcludeMissing fun _token() = token /** - * The type of Account Holder. If the type is 'INDIVIDUAL', the 'individual' attribute will be - * present. If the type is 'BUSINESS' then the 'business_entity', 'control_person', - * 'beneficial_owner_individuals', 'beneficial_owner_entities', 'nature_of_business', and - * 'website_url' attributes will be present. + * The type of Account Holder. If the type is "INDIVIDUAL", the "individual" attribute will be + * present. If the type is "BUSINESS" then the "business_entity", "control_person", + * "beneficial_owner_individuals", "beneficial_owner_entities", "nature_of_business", and + * "website_url" attributes will be present. */ @JsonProperty("user_type") @ExcludeMissing fun _userType() = userType @@ -289,12 +289,12 @@ private constructor( fun _verificationApplication() = verificationApplication /** - * Only present for 'KYB_BASIC' and 'KYC_ADVANCED' workflows. A list of documents required for + * Only present for "KYB_BASIC" and "KYC_ADVANCED" workflows. A list of documents required for * the account holder to be approved. */ @JsonProperty("required_documents") @ExcludeMissing fun _requiredDocuments() = requiredDocuments - /** Only present when user_type == 'BUSINESS'. Business's primary website. */ + /** Only present when user_type == "BUSINESS". Business's primary website. */ @JsonProperty("website_url") @ExcludeMissing fun _websiteUrl() = websiteUrl @JsonAnyGetter @@ -459,14 +459,14 @@ private constructor( } /** - * Only present when user_type == 'BUSINESS'. List of all entities with >25% ownership in + * Only present when user_type == "BUSINESS". List of all entities with >25% ownership in * the company. */ fun beneficialOwnerEntities(beneficialOwnerEntities: List) = beneficialOwnerEntities(JsonField.of(beneficialOwnerEntities)) /** - * Only present when user_type == 'BUSINESS'. List of all entities with >25% ownership in + * Only present when user_type == "BUSINESS". List of all entities with >25% ownership in * the company. */ @JsonProperty("beneficial_owner_entities") @@ -476,7 +476,7 @@ private constructor( ) = apply { this.beneficialOwnerEntities = beneficialOwnerEntities } /** - * Only present when user_type == 'BUSINESS'. List of all individuals with >25% ownership in + * Only present when user_type == "BUSINESS". List of all individuals with >25% ownership in * the company. */ fun beneficialOwnerIndividuals( @@ -484,7 +484,7 @@ private constructor( ) = beneficialOwnerIndividuals(JsonField.of(beneficialOwnerIndividuals)) /** - * Only present when user_type == 'BUSINESS'. List of all individuals with >25% ownership in + * Only present when user_type == "BUSINESS". List of all individuals with >25% ownership in * the company. */ @JsonProperty("beneficial_owner_individuals") @@ -513,14 +513,14 @@ private constructor( } /** - * Only present when user_type == 'BUSINESS'. Information about the business for which the + * Only present when user_type == "BUSINESS". Information about the business for which the * account is being opened and KYB is being run. */ fun businessEntity(businessEntity: AccountHolderBusinessResponse) = businessEntity(JsonField.of(businessEntity)) /** - * Only present when user_type == 'BUSINESS'. Information about the business for which the + * Only present when user_type == "BUSINESS". Information about the business for which the * account is being opened and KYB is being run. */ @JsonProperty("business_entity") @@ -530,7 +530,7 @@ private constructor( } /** - * Only present when user_type == 'BUSINESS'. An individual with significant responsibility + * Only present when user_type == "BUSINESS". An individual with significant responsibility * for managing the legal entity (e.g., a Chief Executive Officer, Chief Financial Officer, * Chief Operating Officer, Managing Member, General Partner, President, Vice President, or * Treasurer). This can be an executive, or someone who will have program-wide access to the @@ -541,7 +541,7 @@ private constructor( controlPerson(JsonField.of(controlPerson)) /** - * Only present when user_type == 'BUSINESS'. An individual with significant responsibility + * Only present when user_type == "BUSINESS". An individual with significant responsibility * for managing the legal entity (e.g., a Chief Executive Officer, Chief Financial Officer, * Chief Operating Officer, Managing Member, General Partner, President, Vice President, or * Treasurer). This can be an executive, or someone who will have program-wide access to the @@ -563,15 +563,15 @@ private constructor( fun created(created: JsonField) = apply { this.created = created } /** - * < Deprecated. Use control_person.email when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.email when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary email of Account Holder. */ fun email(email: String) = email(JsonField.of(email)) /** - * < Deprecated. Use control_person.email when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.email when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary email of Account Holder. */ @JsonProperty("email") @@ -603,14 +603,14 @@ private constructor( fun externalId(externalId: JsonField) = apply { this.externalId = externalId } /** - * Only present when user_type == 'INDIVIDUAL'. Information about the individual for which + * Only present when user_type == "INDIVIDUAL". Information about the individual for which * the account is being opened and KYC is being run. */ fun individual(individual: AccountHolderIndividualResponse) = individual(JsonField.of(individual)) /** - * Only present when user_type == 'INDIVIDUAL'. Information about the individual for which + * Only present when user_type == "INDIVIDUAL". Information about the individual for which * the account is being opened and KYC is being run. */ @JsonProperty("individual") @@ -620,13 +620,13 @@ private constructor( } /** - * Only present when user_type == 'BUSINESS'. User-submitted description of the business. + * Only present when user_type == "BUSINESS". User-submitted description of the business. */ fun natureOfBusiness(natureOfBusiness: String) = natureOfBusiness(JsonField.of(natureOfBusiness)) /** - * Only present when user_type == 'BUSINESS'. User-submitted description of the business. + * Only present when user_type == "BUSINESS". User-submitted description of the business. */ @JsonProperty("nature_of_business") @ExcludeMissing @@ -635,15 +635,15 @@ private constructor( } /** - * < Deprecated. Use control_person.phone_number when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.phone_number when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary phone of Account Holder, entered in E.164 format. */ fun phoneNumber(phoneNumber: String) = phoneNumber(JsonField.of(phoneNumber)) /** - * < Deprecated. Use control_person.phone_number when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.phone_number when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary phone of Account Holder, entered in E.164 format. */ @JsonProperty("phone_number") @@ -702,18 +702,18 @@ private constructor( fun token(token: JsonField) = apply { this.token = token } /** - * The type of Account Holder. If the type is 'INDIVIDUAL', the 'individual' attribute will - * be present. If the type is 'BUSINESS' then the 'business_entity', 'control_person', - * 'beneficial_owner_individuals', 'beneficial_owner_entities', 'nature_of_business', and - * 'website_url' attributes will be present. + * The type of Account Holder. If the type is "INDIVIDUAL", the "individual" attribute will + * be present. If the type is "BUSINESS" then the "business_entity", "control_person", + * "beneficial_owner_individuals", "beneficial_owner_entities", "nature_of_business", and + * "website_url" attributes will be present. */ fun userType(userType: UserType) = userType(JsonField.of(userType)) /** - * The type of Account Holder. If the type is 'INDIVIDUAL', the 'individual' attribute will - * be present. If the type is 'BUSINESS' then the 'business_entity', 'control_person', - * 'beneficial_owner_individuals', 'beneficial_owner_entities', 'nature_of_business', and - * 'website_url' attributes will be present. + * The type of Account Holder. If the type is "INDIVIDUAL", the "individual" attribute will + * be present. If the type is "BUSINESS" then the "business_entity", "control_person", + * "beneficial_owner_individuals", "beneficial_owner_entities", "nature_of_business", and + * "website_url" attributes will be present. */ @JsonProperty("user_type") @ExcludeMissing @@ -731,14 +731,14 @@ private constructor( ) = apply { this.verificationApplication = verificationApplication } /** - * Only present for 'KYB_BASIC' and 'KYC_ADVANCED' workflows. A list of documents required + * Only present for "KYB_BASIC" and "KYC_ADVANCED" workflows. A list of documents required * for the account holder to be approved. */ fun requiredDocuments(requiredDocuments: List) = requiredDocuments(JsonField.of(requiredDocuments)) /** - * Only present for 'KYB_BASIC' and 'KYC_ADVANCED' workflows. A list of documents required + * Only present for "KYB_BASIC" and "KYC_ADVANCED" workflows. A list of documents required * for the account holder to be approved. */ @JsonProperty("required_documents") @@ -747,10 +747,10 @@ private constructor( this.requiredDocuments = requiredDocuments } - /** Only present when user_type == 'BUSINESS'. Business's primary website. */ + /** Only present when user_type == "BUSINESS". Business's primary website. */ fun websiteUrl(websiteUrl: String) = websiteUrl(JsonField.of(websiteUrl)) - /** Only present when user_type == 'BUSINESS'. Business's primary website. */ + /** Only present when user_type == "BUSINESS". Business's primary website. */ @JsonProperty("website_url") @ExcludeMissing fun websiteUrl(websiteUrl: JsonField) = apply { this.websiteUrl = websiteUrl } @@ -1369,181 +1369,6 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = RequiredDocument.Builder::class) - @NoAutoDetect - class RequiredDocument - private constructor( - private val entityToken: JsonField, - private val validDocuments: JsonField>, - private val statusReasons: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Globally unique identifier for an entity. */ - fun entityToken(): String = entityToken.getRequired("entity_token") - - /** - * A list of valid documents that will satisfy the KYC requirements for the specified - * entity. - */ - fun validDocuments(): List = validDocuments.getRequired("valid_documents") - - /** - * rovides the status reasons that will be satisfied by providing one of the valid - * documents. - */ - fun statusReasons(): List = statusReasons.getRequired("status_reasons") - - /** Globally unique identifier for an entity. */ - @JsonProperty("entity_token") @ExcludeMissing fun _entityToken() = entityToken - - /** - * A list of valid documents that will satisfy the KYC requirements for the specified - * entity. - */ - @JsonProperty("valid_documents") @ExcludeMissing fun _validDocuments() = validDocuments - - /** - * rovides the status reasons that will be satisfied by providing one of the valid - * documents. - */ - @JsonProperty("status_reasons") @ExcludeMissing fun _statusReasons() = statusReasons - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): RequiredDocument = apply { - if (!validated) { - entityToken() - validDocuments() - statusReasons() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RequiredDocument && - this.entityToken == other.entityToken && - this.validDocuments == other.validDocuments && - this.statusReasons == other.statusReasons && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - entityToken, - validDocuments, - statusReasons, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RequiredDocument{entityToken=$entityToken, validDocuments=$validDocuments, statusReasons=$statusReasons, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entityToken: JsonField = JsonMissing.of() - private var validDocuments: JsonField> = JsonMissing.of() - private var statusReasons: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(requiredDocument: RequiredDocument) = apply { - this.entityToken = requiredDocument.entityToken - this.validDocuments = requiredDocument.validDocuments - this.statusReasons = requiredDocument.statusReasons - additionalProperties(requiredDocument.additionalProperties) - } - - /** Globally unique identifier for an entity. */ - fun entityToken(entityToken: String) = entityToken(JsonField.of(entityToken)) - - /** Globally unique identifier for an entity. */ - @JsonProperty("entity_token") - @ExcludeMissing - fun entityToken(entityToken: JsonField) = apply { - this.entityToken = entityToken - } - - /** - * A list of valid documents that will satisfy the KYC requirements for the specified - * entity. - */ - fun validDocuments(validDocuments: List) = - validDocuments(JsonField.of(validDocuments)) - - /** - * A list of valid documents that will satisfy the KYC requirements for the specified - * entity. - */ - @JsonProperty("valid_documents") - @ExcludeMissing - fun validDocuments(validDocuments: JsonField>) = apply { - this.validDocuments = validDocuments - } - - /** - * rovides the status reasons that will be satisfied by providing one of the valid - * documents. - */ - fun statusReasons(statusReasons: List) = - statusReasons(JsonField.of(statusReasons)) - - /** - * rovides the status reasons that will be satisfied by providing one of the valid - * documents. - */ - @JsonProperty("status_reasons") - @ExcludeMissing - fun statusReasons(statusReasons: JsonField>) = apply { - this.statusReasons = statusReasons - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): RequiredDocument = - RequiredDocument( - entityToken, - validDocuments.map { it.toUnmodifiable() }, - statusReasons.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - } - class Status @JsonCreator private constructor( diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderCreateResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderCreateResponse.kt index 28822a45..f4d7731e 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderCreateResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderCreateResponse.kt @@ -28,6 +28,7 @@ private constructor( private val externalId: JsonField, private val status: JsonField, private val statusReasons: JsonField>, + private val requiredDocuments: JsonField>, private val token: JsonField, private val additionalProperties: Map, ) { @@ -61,6 +62,13 @@ private constructor( /** Reason for the evaluation status. */ fun statusReasons(): List = statusReasons.getRequired("status_reasons") + /** + * Only present for "KYB_BASIC" and "KYC_ADVANCED" workflows. A list of documents required for + * the account holder to be approved. + */ + fun requiredDocuments(): Optional> = + Optional.ofNullable(requiredDocuments.getNullable("required_documents")) + /** Globally unique identifier for the account holder. */ fun token(): String = token.getRequired("token") @@ -89,6 +97,12 @@ private constructor( /** Reason for the evaluation status. */ @JsonProperty("status_reasons") @ExcludeMissing fun _statusReasons() = statusReasons + /** + * Only present for "KYB_BASIC" and "KYC_ADVANCED" workflows. A list of documents required for + * the account holder to be approved. + */ + @JsonProperty("required_documents") @ExcludeMissing fun _requiredDocuments() = requiredDocuments + /** Globally unique identifier for the account holder. */ @JsonProperty("token") @ExcludeMissing fun _token() = token @@ -103,6 +117,7 @@ private constructor( externalId() status() statusReasons() + requiredDocuments().map { it.forEach { it.validate() } } token() validated = true } @@ -121,6 +136,7 @@ private constructor( this.externalId == other.externalId && this.status == other.status && this.statusReasons == other.statusReasons && + this.requiredDocuments == other.requiredDocuments && this.token == other.token && this.additionalProperties == other.additionalProperties } @@ -134,6 +150,7 @@ private constructor( externalId, status, statusReasons, + requiredDocuments, token, additionalProperties, ) @@ -142,7 +159,7 @@ private constructor( } override fun toString() = - "AccountHolderCreateResponse{accountToken=$accountToken, created=$created, externalId=$externalId, status=$status, statusReasons=$statusReasons, token=$token, additionalProperties=$additionalProperties}" + "AccountHolderCreateResponse{accountToken=$accountToken, created=$created, externalId=$externalId, status=$status, statusReasons=$statusReasons, requiredDocuments=$requiredDocuments, token=$token, additionalProperties=$additionalProperties}" companion object { @@ -156,6 +173,7 @@ private constructor( private var externalId: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() private var statusReasons: JsonField> = JsonMissing.of() + private var requiredDocuments: JsonField> = JsonMissing.of() private var token: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -166,6 +184,7 @@ private constructor( this.externalId = accountHolderCreateResponse.externalId this.status = accountHolderCreateResponse.status this.statusReasons = accountHolderCreateResponse.statusReasons + this.requiredDocuments = accountHolderCreateResponse.requiredDocuments this.token = accountHolderCreateResponse.token additionalProperties(accountHolderCreateResponse.additionalProperties) } @@ -235,6 +254,23 @@ private constructor( this.statusReasons = statusReasons } + /** + * Only present for "KYB_BASIC" and "KYC_ADVANCED" workflows. A list of documents required + * for the account holder to be approved. + */ + fun requiredDocuments(requiredDocuments: List) = + requiredDocuments(JsonField.of(requiredDocuments)) + + /** + * Only present for "KYB_BASIC" and "KYC_ADVANCED" workflows. A list of documents required + * for the account holder to be approved. + */ + @JsonProperty("required_documents") + @ExcludeMissing + fun requiredDocuments(requiredDocuments: JsonField>) = apply { + this.requiredDocuments = requiredDocuments + } + /** Globally unique identifier for the account holder. */ fun token(token: String) = token(JsonField.of(token)) @@ -264,6 +300,7 @@ private constructor( externalId, status, statusReasons.map { it.toUnmodifiable() }, + requiredDocuments.map { it.toUnmodifiable() }, token, additionalProperties.toUnmodifiable(), ) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewResponse.kt index 821f0c50..c1b04c29 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewResponse.kt @@ -69,7 +69,7 @@ private constructor( fun created(): Optional = Optional.ofNullable(created.getNullable("created")) /** - * The type of KYC exemption for a KYC-Exempt Account Holder. 'None' if the account holder is + * The type of KYC exemption for a KYC-Exempt Account Holder. "None" if the account holder is * not KYC-Exempt. */ fun exemptionType(): Optional = @@ -82,13 +82,13 @@ private constructor( fun externalId(): Optional = Optional.ofNullable(externalId.getNullable("external_id")) /** - * The type of Account Holder. If the type is 'INDIVIDUAL', the 'individual' attribute will be + * The type of Account Holder. If the type is "INDIVIDUAL", the "individual" attribute will be * present. * - * If the type is 'BUSINESS' then the 'business_entity', 'control_person', - * 'beneficial_owner_individuals', 'beneficial_owner_entities', + * If the type is "BUSINESS" then the "business_entity", "control_person", + * "beneficial_owner_individuals", "beneficial_owner_entities", * - * 'nature_of_business', and 'website_url' attributes will be present. + * "nature_of_business", and "website_url" attributes will be present. */ fun userType(): Optional = Optional.ofNullable(userType.getNullable("user_type")) @@ -97,35 +97,35 @@ private constructor( Optional.ofNullable(verificationApplication.getNullable("verification_application")) /** - * Only present when user_type == 'INDIVIDUAL'. Information about the individual for which the + * Only present when user_type == "INDIVIDUAL". Information about the individual for which the * account is being opened and KYC is being run. */ fun individual(): Optional = Optional.ofNullable(individual.getNullable("individual")) /** - * Only present when user_type == 'BUSINESS'. Information about the business for which the + * Only present when user_type == "BUSINESS". Information about the business for which the * account is being opened and KYB is being run. */ fun businessEntity(): Optional = Optional.ofNullable(businessEntity.getNullable("business_entity")) /** - * Only present when user_type == 'BUSINESS'. List of all entities with >25% ownership in the + * Only present when user_type == "BUSINESS". List of all entities with >25% ownership in the * company. */ fun beneficialOwnerEntities(): Optional> = Optional.ofNullable(beneficialOwnerEntities.getNullable("beneficial_owner_entities")) /** - * Only present when user_type == 'BUSINESS'. List of all individuals with >25% ownership in the + * Only present when user_type == "BUSINESS". List of all individuals with >25% ownership in the * company. */ fun beneficialOwnerIndividuals(): Optional> = Optional.ofNullable(beneficialOwnerIndividuals.getNullable("beneficial_owner_individuals")) /** - * Only present when user_type == 'BUSINESS'. + * Only present when user_type == "BUSINESS". * * An individual with significant responsibility for managing the legal entity (e.g., a Chief * Executive Officer, Chief Financial Officer, Chief Operating Officer, @@ -139,23 +139,23 @@ private constructor( fun controlPerson(): Optional = Optional.ofNullable(controlPerson.getNullable("control_person")) - /** Only present when user_type == 'BUSINESS'. User-submitted description of the business. */ + /** Only present when user_type == "BUSINESS". User-submitted description of the business. */ fun natureOfBusiness(): Optional = Optional.ofNullable(natureOfBusiness.getNullable("nature_of_business")) - /** Only present when user_type == 'BUSINESS'. Business's primary website. */ + /** Only present when user_type == "BUSINESS". Business's primary website. */ fun websiteUrl(): Optional = Optional.ofNullable(websiteUrl.getNullable("website_url")) /** - * < Deprecated. Use control_person.email when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.email when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary email of Account Holder. */ fun email(): Optional = Optional.ofNullable(email.getNullable("email")) /** - * < Deprecated. Use control_person.phone_number when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.phone_number when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary phone of Account Holder, entered in E.164 format. */ fun phoneNumber(): Optional = @@ -178,7 +178,7 @@ private constructor( Optional.ofNullable(statusReasons.getNullable("status_reasons")) /** - * Only present for 'KYB_BASIC' and 'KYC_ADVANCED' workflows. A list of documents required for + * Only present for "KYB_BASIC" and "KYC_ADVANCED" workflows. A list of documents required for * the account holder to be approved. */ fun requiredDocuments(): Optional> = @@ -203,7 +203,7 @@ private constructor( @JsonProperty("created") @ExcludeMissing fun _created() = created /** - * The type of KYC exemption for a KYC-Exempt Account Holder. 'None' if the account holder is + * The type of KYC exemption for a KYC-Exempt Account Holder. "None" if the account holder is * not KYC-Exempt. */ @JsonProperty("exemption_type") @ExcludeMissing fun _exemptionType() = exemptionType @@ -215,13 +215,13 @@ private constructor( @JsonProperty("external_id") @ExcludeMissing fun _externalId() = externalId /** - * The type of Account Holder. If the type is 'INDIVIDUAL', the 'individual' attribute will be + * The type of Account Holder. If the type is "INDIVIDUAL", the "individual" attribute will be * present. * - * If the type is 'BUSINESS' then the 'business_entity', 'control_person', - * 'beneficial_owner_individuals', 'beneficial_owner_entities', + * If the type is "BUSINESS" then the "business_entity", "control_person", + * "beneficial_owner_individuals", "beneficial_owner_entities", * - * 'nature_of_business', and 'website_url' attributes will be present. + * "nature_of_business", and "website_url" attributes will be present. */ @JsonProperty("user_type") @ExcludeMissing fun _userType() = userType @@ -231,19 +231,19 @@ private constructor( fun _verificationApplication() = verificationApplication /** - * Only present when user_type == 'INDIVIDUAL'. Information about the individual for which the + * Only present when user_type == "INDIVIDUAL". Information about the individual for which the * account is being opened and KYC is being run. */ @JsonProperty("individual") @ExcludeMissing fun _individual() = individual /** - * Only present when user_type == 'BUSINESS'. Information about the business for which the + * Only present when user_type == "BUSINESS". Information about the business for which the * account is being opened and KYB is being run. */ @JsonProperty("business_entity") @ExcludeMissing fun _businessEntity() = businessEntity /** - * Only present when user_type == 'BUSINESS'. List of all entities with >25% ownership in the + * Only present when user_type == "BUSINESS". List of all entities with >25% ownership in the * company. */ @JsonProperty("beneficial_owner_entities") @@ -251,7 +251,7 @@ private constructor( fun _beneficialOwnerEntities() = beneficialOwnerEntities /** - * Only present when user_type == 'BUSINESS'. List of all individuals with >25% ownership in the + * Only present when user_type == "BUSINESS". List of all individuals with >25% ownership in the * company. */ @JsonProperty("beneficial_owner_individuals") @@ -259,7 +259,7 @@ private constructor( fun _beneficialOwnerIndividuals() = beneficialOwnerIndividuals /** - * Only present when user_type == 'BUSINESS'. + * Only present when user_type == "BUSINESS". * * An individual with significant responsibility for managing the legal entity (e.g., a Chief * Executive Officer, Chief Financial Officer, Chief Operating Officer, @@ -272,22 +272,22 @@ private constructor( */ @JsonProperty("control_person") @ExcludeMissing fun _controlPerson() = controlPerson - /** Only present when user_type == 'BUSINESS'. User-submitted description of the business. */ + /** Only present when user_type == "BUSINESS". User-submitted description of the business. */ @JsonProperty("nature_of_business") @ExcludeMissing fun _natureOfBusiness() = natureOfBusiness - /** Only present when user_type == 'BUSINESS'. Business's primary website. */ + /** Only present when user_type == "BUSINESS". Business's primary website. */ @JsonProperty("website_url") @ExcludeMissing fun _websiteUrl() = websiteUrl /** - * < Deprecated. Use control_person.email when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.email when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary email of Account Holder. */ @JsonProperty("email") @ExcludeMissing fun _email() = email /** - * < Deprecated. Use control_person.phone_number when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.phone_number when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary phone of Account Holder, entered in E.164 format. */ @JsonProperty("phone_number") @ExcludeMissing fun _phoneNumber() = phoneNumber @@ -308,7 +308,7 @@ private constructor( @JsonProperty("status_reasons") @ExcludeMissing fun _statusReasons() = statusReasons /** - * Only present for 'KYB_BASIC' and 'KYC_ADVANCED' workflows. A list of documents required for + * Only present for "KYB_BASIC" and "KYC_ADVANCED" workflows. A list of documents required for * the account holder to be approved. */ @JsonProperty("required_documents") @ExcludeMissing fun _requiredDocuments() = requiredDocuments @@ -514,13 +514,13 @@ private constructor( fun created(created: JsonField) = apply { this.created = created } /** - * The type of KYC exemption for a KYC-Exempt Account Holder. 'None' if the account holder + * The type of KYC exemption for a KYC-Exempt Account Holder. "None" if the account holder * is not KYC-Exempt. */ fun exemptionType(exemptionType: ExemptionType) = exemptionType(JsonField.of(exemptionType)) /** - * The type of KYC exemption for a KYC-Exempt Account Holder. 'None' if the account holder + * The type of KYC exemption for a KYC-Exempt Account Holder. "None" if the account holder * is not KYC-Exempt. */ @JsonProperty("exemption_type") @@ -544,24 +544,24 @@ private constructor( fun externalId(externalId: JsonField) = apply { this.externalId = externalId } /** - * The type of Account Holder. If the type is 'INDIVIDUAL', the 'individual' attribute will + * The type of Account Holder. If the type is "INDIVIDUAL", the "individual" attribute will * be present. * - * If the type is 'BUSINESS' then the 'business_entity', 'control_person', - * 'beneficial_owner_individuals', 'beneficial_owner_entities', + * If the type is "BUSINESS" then the "business_entity", "control_person", + * "beneficial_owner_individuals", "beneficial_owner_entities", * - * 'nature_of_business', and 'website_url' attributes will be present. + * "nature_of_business", and "website_url" attributes will be present. */ fun userType(userType: UserType) = userType(JsonField.of(userType)) /** - * The type of Account Holder. If the type is 'INDIVIDUAL', the 'individual' attribute will + * The type of Account Holder. If the type is "INDIVIDUAL", the "individual" attribute will * be present. * - * If the type is 'BUSINESS' then the 'business_entity', 'control_person', - * 'beneficial_owner_individuals', 'beneficial_owner_entities', + * If the type is "BUSINESS" then the "business_entity", "control_person", + * "beneficial_owner_individuals", "beneficial_owner_entities", * - * 'nature_of_business', and 'website_url' attributes will be present. + * "nature_of_business", and "website_url" attributes will be present. */ @JsonProperty("user_type") @ExcludeMissing @@ -580,13 +580,13 @@ private constructor( } /** - * Only present when user_type == 'INDIVIDUAL'. Information about the individual for which + * Only present when user_type == "INDIVIDUAL". Information about the individual for which * the account is being opened and KYC is being run. */ fun individual(individual: Individual) = individual(JsonField.of(individual)) /** - * Only present when user_type == 'INDIVIDUAL'. Information about the individual for which + * Only present when user_type == "INDIVIDUAL". Information about the individual for which * the account is being opened and KYC is being run. */ @JsonProperty("individual") @@ -594,14 +594,14 @@ private constructor( fun individual(individual: JsonField) = apply { this.individual = individual } /** - * Only present when user_type == 'BUSINESS'. Information about the business for which the + * Only present when user_type == "BUSINESS". Information about the business for which the * account is being opened and KYB is being run. */ fun businessEntity(businessEntity: KybBusinessEntity) = businessEntity(JsonField.of(businessEntity)) /** - * Only present when user_type == 'BUSINESS'. Information about the business for which the + * Only present when user_type == "BUSINESS". Information about the business for which the * account is being opened and KYB is being run. */ @JsonProperty("business_entity") @@ -611,14 +611,14 @@ private constructor( } /** - * Only present when user_type == 'BUSINESS'. List of all entities with >25% ownership in + * Only present when user_type == "BUSINESS". List of all entities with >25% ownership in * the company. */ fun beneficialOwnerEntities(beneficialOwnerEntities: List) = beneficialOwnerEntities(JsonField.of(beneficialOwnerEntities)) /** - * Only present when user_type == 'BUSINESS'. List of all entities with >25% ownership in + * Only present when user_type == "BUSINESS". List of all entities with >25% ownership in * the company. */ @JsonProperty("beneficial_owner_entities") @@ -629,14 +629,14 @@ private constructor( } /** - * Only present when user_type == 'BUSINESS'. List of all individuals with >25% ownership in + * Only present when user_type == "BUSINESS". List of all individuals with >25% ownership in * the company. */ fun beneficialOwnerIndividuals(beneficialOwnerIndividuals: List) = beneficialOwnerIndividuals(JsonField.of(beneficialOwnerIndividuals)) /** - * Only present when user_type == 'BUSINESS'. List of all individuals with >25% ownership in + * Only present when user_type == "BUSINESS". List of all individuals with >25% ownership in * the company. */ @JsonProperty("beneficial_owner_individuals") @@ -647,7 +647,7 @@ private constructor( } /** - * Only present when user_type == 'BUSINESS'. + * Only present when user_type == "BUSINESS". * * An individual with significant responsibility for managing the legal entity (e.g., a * Chief Executive Officer, Chief Financial Officer, Chief Operating Officer, @@ -661,7 +661,7 @@ private constructor( fun controlPerson(controlPerson: Individual) = controlPerson(JsonField.of(controlPerson)) /** - * Only present when user_type == 'BUSINESS'. + * Only present when user_type == "BUSINESS". * * An individual with significant responsibility for managing the legal entity (e.g., a * Chief Executive Officer, Chief Financial Officer, Chief Operating Officer, @@ -679,13 +679,13 @@ private constructor( } /** - * Only present when user_type == 'BUSINESS'. User-submitted description of the business. + * Only present when user_type == "BUSINESS". User-submitted description of the business. */ fun natureOfBusiness(natureOfBusiness: String) = natureOfBusiness(JsonField.of(natureOfBusiness)) /** - * Only present when user_type == 'BUSINESS'. User-submitted description of the business. + * Only present when user_type == "BUSINESS". User-submitted description of the business. */ @JsonProperty("nature_of_business") @ExcludeMissing @@ -693,24 +693,24 @@ private constructor( this.natureOfBusiness = natureOfBusiness } - /** Only present when user_type == 'BUSINESS'. Business's primary website. */ + /** Only present when user_type == "BUSINESS". Business's primary website. */ fun websiteUrl(websiteUrl: String) = websiteUrl(JsonField.of(websiteUrl)) - /** Only present when user_type == 'BUSINESS'. Business's primary website. */ + /** Only present when user_type == "BUSINESS". Business's primary website. */ @JsonProperty("website_url") @ExcludeMissing fun websiteUrl(websiteUrl: JsonField) = apply { this.websiteUrl = websiteUrl } /** - * < Deprecated. Use control_person.email when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.email when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary email of Account Holder. */ fun email(email: String) = email(JsonField.of(email)) /** - * < Deprecated. Use control_person.email when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.email when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary email of Account Holder. */ @JsonProperty("email") @@ -718,15 +718,15 @@ private constructor( fun email(email: JsonField) = apply { this.email = email } /** - * < Deprecated. Use control_person.phone_number when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.phone_number when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary phone of Account Holder, entered in E.164 format. */ fun phoneNumber(phoneNumber: String) = phoneNumber(JsonField.of(phoneNumber)) /** - * < Deprecated. Use control_person.phone_number when user_type == 'BUSINESS'. Use - * individual.phone_number when user_type == 'INDIVIDUAL'. + * < Deprecated. Use control_person.phone_number when user_type == "BUSINESS". Use + * individual.phone_number when user_type == "INDIVIDUAL". * > Primary phone of Account Holder, entered in E.164 format. */ @JsonProperty("phone_number") @@ -773,14 +773,14 @@ private constructor( } /** - * Only present for 'KYB_BASIC' and 'KYC_ADVANCED' workflows. A list of documents required + * Only present for "KYB_BASIC" and "KYC_ADVANCED" workflows. A list of documents required * for the account holder to be approved. */ fun requiredDocuments(requiredDocuments: List) = requiredDocuments(JsonField.of(requiredDocuments)) /** - * Only present for 'KYB_BASIC' and 'KYC_ADVANCED' workflows. A list of documents required + * Only present for "KYB_BASIC" and "KYC_ADVANCED" workflows. A list of documents required * for the account holder to be approved. */ @JsonProperty("required_documents") @@ -1919,181 +1919,6 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - @JsonDeserialize(builder = RequiredDocument.Builder::class) - @NoAutoDetect - class RequiredDocument - private constructor( - private val entityToken: JsonField, - private val validDocuments: JsonField>, - private val statusReasons: JsonField>, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** Globally unique identifier for an entity. */ - fun entityToken(): String = entityToken.getRequired("entity_token") - - /** - * A list of valid documents that will satisfy the KYC requirements for the specified - * entity. - */ - fun validDocuments(): List = validDocuments.getRequired("valid_documents") - - /** - * rovides the status reasons that will be satisfied by providing one of the valid - * documents. - */ - fun statusReasons(): List = statusReasons.getRequired("status_reasons") - - /** Globally unique identifier for an entity. */ - @JsonProperty("entity_token") @ExcludeMissing fun _entityToken() = entityToken - - /** - * A list of valid documents that will satisfy the KYC requirements for the specified - * entity. - */ - @JsonProperty("valid_documents") @ExcludeMissing fun _validDocuments() = validDocuments - - /** - * rovides the status reasons that will be satisfied by providing one of the valid - * documents. - */ - @JsonProperty("status_reasons") @ExcludeMissing fun _statusReasons() = statusReasons - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): RequiredDocument = apply { - if (!validated) { - entityToken() - validDocuments() - statusReasons() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RequiredDocument && - this.entityToken == other.entityToken && - this.validDocuments == other.validDocuments && - this.statusReasons == other.statusReasons && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - entityToken, - validDocuments, - statusReasons, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "RequiredDocument{entityToken=$entityToken, validDocuments=$validDocuments, statusReasons=$statusReasons, additionalProperties=$additionalProperties}" - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var entityToken: JsonField = JsonMissing.of() - private var validDocuments: JsonField> = JsonMissing.of() - private var statusReasons: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(requiredDocument: RequiredDocument) = apply { - this.entityToken = requiredDocument.entityToken - this.validDocuments = requiredDocument.validDocuments - this.statusReasons = requiredDocument.statusReasons - additionalProperties(requiredDocument.additionalProperties) - } - - /** Globally unique identifier for an entity. */ - fun entityToken(entityToken: String) = entityToken(JsonField.of(entityToken)) - - /** Globally unique identifier for an entity. */ - @JsonProperty("entity_token") - @ExcludeMissing - fun entityToken(entityToken: JsonField) = apply { - this.entityToken = entityToken - } - - /** - * A list of valid documents that will satisfy the KYC requirements for the specified - * entity. - */ - fun validDocuments(validDocuments: List) = - validDocuments(JsonField.of(validDocuments)) - - /** - * A list of valid documents that will satisfy the KYC requirements for the specified - * entity. - */ - @JsonProperty("valid_documents") - @ExcludeMissing - fun validDocuments(validDocuments: JsonField>) = apply { - this.validDocuments = validDocuments - } - - /** - * rovides the status reasons that will be satisfied by providing one of the valid - * documents. - */ - fun statusReasons(statusReasons: List) = - statusReasons(JsonField.of(statusReasons)) - - /** - * rovides the status reasons that will be satisfied by providing one of the valid - * documents. - */ - @JsonProperty("status_reasons") - @ExcludeMissing - fun statusReasons(statusReasons: JsonField>) = apply { - this.statusReasons = statusReasons - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): RequiredDocument = - RequiredDocument( - entityToken, - validDocuments.map { it.toUnmodifiable() }, - statusReasons.map { it.toUnmodifiable() }, - additionalProperties.toUnmodifiable(), - ) - } - } - class Status @JsonCreator private constructor( diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Address.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Address.kt index 4cd3e53f..901fc807 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Address.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Address.kt @@ -42,15 +42,22 @@ private constructor( fun city(): String = city.getRequired("city") /** - * Valid country code. USA and CAN are supported, entered in uppercase ISO 3166-1 alpha-3 - * three-character format. + * Valid country code, entered in uppercase ISO 3166-1 alpha-3 three-character format. Only USA + * is currently supported for all workflows. KYC_EXEMPT supports CAN additionally. */ fun country(): String = country.getRequired("country") - /** Valid postal code. */ + /** + * Valid postal code. USA postal codes (ZIP codes) are supported, entered as a five-digit postal + * code or nine-digit postal code (ZIP+4) using the format 12345-1234. KYC_EXEMPT supports + * Canadian postal codes. + */ fun postalCode(): String = postalCode.getRequired("postal_code") - /** Valid state code. */ + /** + * Valid state code. USA state codes are supported, entered in uppercase ISO 3166-2 + * two-character format. KYC_EXEMPT supports Canadian province codes. + */ fun state(): String = state.getRequired("state") /** Valid deliverable address (no PO boxes). */ @@ -63,15 +70,22 @@ private constructor( @JsonProperty("city") @ExcludeMissing fun _city() = city /** - * Valid country code. USA and CAN are supported, entered in uppercase ISO 3166-1 alpha-3 - * three-character format. + * Valid country code, entered in uppercase ISO 3166-1 alpha-3 three-character format. Only USA + * is currently supported for all workflows. KYC_EXEMPT supports CAN additionally. */ @JsonProperty("country") @ExcludeMissing fun _country() = country - /** Valid postal code. */ + /** + * Valid postal code. USA postal codes (ZIP codes) are supported, entered as a five-digit postal + * code or nine-digit postal code (ZIP+4) using the format 12345-1234. KYC_EXEMPT supports + * Canadian postal codes. + */ @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode - /** Valid state code. */ + /** + * Valid state code. USA state codes are supported, entered in uppercase ISO 3166-2 + * two-character format. KYC_EXEMPT supports Canadian province codes. + */ @JsonProperty("state") @ExcludeMissing fun _state() = state @JsonAnyGetter @@ -177,31 +191,45 @@ private constructor( fun city(city: JsonField) = apply { this.city = city } /** - * Valid country code. USA and CAN are supported, entered in uppercase ISO 3166-1 alpha-3 - * three-character format. + * Valid country code, entered in uppercase ISO 3166-1 alpha-3 three-character format. Only + * USA is currently supported for all workflows. KYC_EXEMPT supports CAN additionally. */ fun country(country: String) = country(JsonField.of(country)) /** - * Valid country code. USA and CAN are supported, entered in uppercase ISO 3166-1 alpha-3 - * three-character format. + * Valid country code, entered in uppercase ISO 3166-1 alpha-3 three-character format. Only + * USA is currently supported for all workflows. KYC_EXEMPT supports CAN additionally. */ @JsonProperty("country") @ExcludeMissing fun country(country: JsonField) = apply { this.country = country } - /** Valid postal code. */ + /** + * Valid postal code. USA postal codes (ZIP codes) are supported, entered as a five-digit + * postal code or nine-digit postal code (ZIP+4) using the format 12345-1234. KYC_EXEMPT + * supports Canadian postal codes. + */ fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) - /** Valid postal code. */ + /** + * Valid postal code. USA postal codes (ZIP codes) are supported, entered as a five-digit + * postal code or nine-digit postal code (ZIP+4) using the format 12345-1234. KYC_EXEMPT + * supports Canadian postal codes. + */ @JsonProperty("postal_code") @ExcludeMissing fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - /** Valid state code. */ + /** + * Valid state code. USA state codes are supported, entered in uppercase ISO 3166-2 + * two-character format. KYC_EXEMPT supports Canadian province codes. + */ fun state(state: String) = state(JsonField.of(state)) - /** Valid state code. */ + /** + * Valid state code. USA state codes are supported, entered in uppercase ISO 3166-2 + * two-character format. KYC_EXEMPT supports Canadian province codes. + */ @JsonProperty("state") @ExcludeMissing fun state(state: JsonField) = apply { this.state = state } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt index a059b4db..26e14f3f 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt @@ -47,7 +47,7 @@ private constructor( /** * Countries in which the Auth Rule permits transactions. Note that Lithic maintains a list of - * countries in which all transactions are blocked; 'allowing' those countries in an Auth Rule + * countries in which all transactions are blocked; "allowing" those countries in an Auth Rule * does not override the Lithic-wide restrictions. */ fun allowedCountries(): Optional> = @@ -90,7 +90,7 @@ private constructor( /** * Countries in which the Auth Rule permits transactions. Note that Lithic maintains a list of - * countries in which all transactions are blocked; 'allowing' those countries in an Auth Rule + * countries in which all transactions are blocked; "allowing" those countries in an Auth Rule * does not override the Lithic-wide restrictions. */ @JsonProperty("allowed_countries") @ExcludeMissing fun _allowedCountries() = allowedCountries @@ -230,7 +230,7 @@ private constructor( /** * Countries in which the Auth Rule permits transactions. Note that Lithic maintains a list - * of countries in which all transactions are blocked; 'allowing' those countries in an Auth + * of countries in which all transactions are blocked; "allowing" those countries in an Auth * Rule does not override the Lithic-wide restrictions. */ fun allowedCountries(allowedCountries: List) = @@ -238,7 +238,7 @@ private constructor( /** * Countries in which the Auth Rule permits transactions. Note that Lithic maintains a list - * of countries in which all transactions are blocked; 'allowing' those countries in an Auth + * of countries in which all transactions are blocked; "allowing" those countries in an Auth * Rule does not override the Lithic-wide restrictions. */ @JsonProperty("allowed_countries") diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleCreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleCreateParams.kt index b424d678..a96e1ddf 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleCreateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleCreateParams.kt @@ -84,7 +84,7 @@ constructor( /** * Countries in which the Auth Rule permits transactions. Note that Lithic maintains a list - * of countries in which all transactions are blocked; 'allowing' those countries in an Auth + * of countries in which all transactions are blocked; "allowing" those countries in an Auth * Rule does not override the Lithic-wide restrictions. */ @JsonProperty("allowed_countries") fun allowedCountries(): List? = allowedCountries @@ -188,7 +188,7 @@ constructor( /** * Countries in which the Auth Rule permits transactions. Note that Lithic maintains a - * list of countries in which all transactions are blocked; 'allowing' those countries + * list of countries in which all transactions are blocked; "allowing" those countries * in an Auth Rule does not override the Lithic-wide restrictions. */ @JsonProperty("allowed_countries") @@ -345,7 +345,7 @@ constructor( /** * Countries in which the Auth Rule permits transactions. Note that Lithic maintains a list - * of countries in which all transactions are blocked; 'allowing' those countries in an Auth + * of countries in which all transactions are blocked; "allowing" those countries in an Auth * Rule does not override the Lithic-wide restrictions. */ fun allowedCountries(allowedCountries: List) = apply { @@ -355,7 +355,7 @@ constructor( /** * Countries in which the Auth Rule permits transactions. Note that Lithic maintains a list - * of countries in which all transactions are blocked; 'allowing' those countries in an Auth + * of countries in which all transactions are blocked; "allowing" those countries in an Auth * Rule does not override the Lithic-wide restrictions. */ fun addAllowedCountry(allowedCountry: String) = apply { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ApplyParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ApplyParams.kt new file mode 100644 index 00000000..70a35ae5 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ApplyParams.kt @@ -0,0 +1,622 @@ +// 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.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import com.lithic.api.models.* +import java.util.Objects +import java.util.Optional + +class AuthRuleV2ApplyParams +constructor( + private val authRuleToken: String, + private val applyAuthRuleRequestAccountTokens: ApplyAuthRuleRequestAccountTokens?, + private val applyAuthRuleRequestCardTokens: ApplyAuthRuleRequestCardTokens?, + private val applyAuthRuleRequestProgramLevel: ApplyAuthRuleRequestProgramLevel?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun authRuleToken(): String = authRuleToken + + fun applyAuthRuleRequestAccountTokens(): Optional = + Optional.ofNullable(applyAuthRuleRequestAccountTokens) + + fun applyAuthRuleRequestCardTokens(): Optional = + Optional.ofNullable(applyAuthRuleRequestCardTokens) + + fun applyAuthRuleRequestProgramLevel(): Optional = + Optional.ofNullable(applyAuthRuleRequestProgramLevel) + + @JvmSynthetic + internal fun getBody(): AuthRuleV2ApplyBody { + return AuthRuleV2ApplyBody( + applyAuthRuleRequestAccountTokens, + applyAuthRuleRequestCardTokens, + applyAuthRuleRequestProgramLevel, + ) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> authRuleToken + else -> "" + } + } + + @JsonDeserialize(using = AuthRuleV2ApplyBody.Deserializer::class) + @JsonSerialize(using = AuthRuleV2ApplyBody.Serializer::class) + class AuthRuleV2ApplyBody + internal constructor( + private val applyAuthRuleRequestAccountTokens: ApplyAuthRuleRequestAccountTokens? = null, + private val applyAuthRuleRequestCardTokens: ApplyAuthRuleRequestCardTokens? = null, + private val applyAuthRuleRequestProgramLevel: ApplyAuthRuleRequestProgramLevel? = null, + private val _json: JsonValue? = null, + ) { + + fun applyAuthRuleRequestAccountTokens(): Optional = + Optional.ofNullable(applyAuthRuleRequestAccountTokens) + + fun applyAuthRuleRequestCardTokens(): Optional = + Optional.ofNullable(applyAuthRuleRequestCardTokens) + + fun applyAuthRuleRequestProgramLevel(): Optional = + Optional.ofNullable(applyAuthRuleRequestProgramLevel) + + fun isApplyAuthRuleRequestAccountTokens(): Boolean = + applyAuthRuleRequestAccountTokens != null + + fun isApplyAuthRuleRequestCardTokens(): Boolean = applyAuthRuleRequestCardTokens != null + + fun isApplyAuthRuleRequestProgramLevel(): Boolean = applyAuthRuleRequestProgramLevel != null + + fun asApplyAuthRuleRequestAccountTokens(): ApplyAuthRuleRequestAccountTokens = + applyAuthRuleRequestAccountTokens.getOrThrow("applyAuthRuleRequestAccountTokens") + + fun asApplyAuthRuleRequestCardTokens(): ApplyAuthRuleRequestCardTokens = + applyAuthRuleRequestCardTokens.getOrThrow("applyAuthRuleRequestCardTokens") + + fun asApplyAuthRuleRequestProgramLevel(): ApplyAuthRuleRequestProgramLevel = + applyAuthRuleRequestProgramLevel.getOrThrow("applyAuthRuleRequestProgramLevel") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + applyAuthRuleRequestAccountTokens != null -> + visitor.visitApplyAuthRuleRequestAccountTokens( + applyAuthRuleRequestAccountTokens + ) + applyAuthRuleRequestCardTokens != null -> + visitor.visitApplyAuthRuleRequestCardTokens(applyAuthRuleRequestCardTokens) + applyAuthRuleRequestProgramLevel != null -> + visitor.visitApplyAuthRuleRequestProgramLevel(applyAuthRuleRequestProgramLevel) + else -> visitor.unknown(_json) + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleV2ApplyBody && + this.applyAuthRuleRequestAccountTokens == other.applyAuthRuleRequestAccountTokens && + this.applyAuthRuleRequestCardTokens == other.applyAuthRuleRequestCardTokens && + this.applyAuthRuleRequestProgramLevel == other.applyAuthRuleRequestProgramLevel + } + + override fun hashCode(): Int { + return Objects.hash( + applyAuthRuleRequestAccountTokens, + applyAuthRuleRequestCardTokens, + applyAuthRuleRequestProgramLevel, + ) + } + + override fun toString(): String { + return when { + applyAuthRuleRequestAccountTokens != null -> + "AuthRuleV2ApplyBody{applyAuthRuleRequestAccountTokens=$applyAuthRuleRequestAccountTokens}" + applyAuthRuleRequestCardTokens != null -> + "AuthRuleV2ApplyBody{applyAuthRuleRequestCardTokens=$applyAuthRuleRequestCardTokens}" + applyAuthRuleRequestProgramLevel != null -> + "AuthRuleV2ApplyBody{applyAuthRuleRequestProgramLevel=$applyAuthRuleRequestProgramLevel}" + _json != null -> "AuthRuleV2ApplyBody{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleV2ApplyBody") + } + } + + companion object { + + @JvmStatic + fun ofApplyAuthRuleRequestAccountTokens( + applyAuthRuleRequestAccountTokens: ApplyAuthRuleRequestAccountTokens + ) = + AuthRuleV2ApplyBody( + applyAuthRuleRequestAccountTokens = applyAuthRuleRequestAccountTokens + ) + + @JvmStatic + fun ofApplyAuthRuleRequestCardTokens( + applyAuthRuleRequestCardTokens: ApplyAuthRuleRequestCardTokens + ) = AuthRuleV2ApplyBody(applyAuthRuleRequestCardTokens = applyAuthRuleRequestCardTokens) + + @JvmStatic + fun ofApplyAuthRuleRequestProgramLevel( + applyAuthRuleRequestProgramLevel: ApplyAuthRuleRequestProgramLevel + ) = + AuthRuleV2ApplyBody( + applyAuthRuleRequestProgramLevel = applyAuthRuleRequestProgramLevel + ) + } + + interface Visitor { + + fun visitApplyAuthRuleRequestAccountTokens( + applyAuthRuleRequestAccountTokens: ApplyAuthRuleRequestAccountTokens + ): T + + fun visitApplyAuthRuleRequestCardTokens( + applyAuthRuleRequestCardTokens: ApplyAuthRuleRequestCardTokens + ): T + + fun visitApplyAuthRuleRequestProgramLevel( + applyAuthRuleRequestProgramLevel: ApplyAuthRuleRequestProgramLevel + ): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleV2ApplyBody: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleV2ApplyBody::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleV2ApplyBody { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return AuthRuleV2ApplyBody(applyAuthRuleRequestAccountTokens = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return AuthRuleV2ApplyBody(applyAuthRuleRequestCardTokens = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return AuthRuleV2ApplyBody(applyAuthRuleRequestProgramLevel = it, _json = json) + } + + return AuthRuleV2ApplyBody(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleV2ApplyBody::class) { + + override fun serialize( + value: AuthRuleV2ApplyBody, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.applyAuthRuleRequestAccountTokens != null -> + generator.writeObject(value.applyAuthRuleRequestAccountTokens) + value.applyAuthRuleRequestCardTokens != null -> + generator.writeObject(value.applyAuthRuleRequestCardTokens) + value.applyAuthRuleRequestProgramLevel != null -> + generator.writeObject(value.applyAuthRuleRequestProgramLevel) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleV2ApplyBody") + } + } + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleV2ApplyParams && + this.authRuleToken == other.authRuleToken && + this.applyAuthRuleRequestAccountTokens == other.applyAuthRuleRequestAccountTokens && + this.applyAuthRuleRequestCardTokens == other.applyAuthRuleRequestCardTokens && + this.applyAuthRuleRequestProgramLevel == other.applyAuthRuleRequestProgramLevel && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders + } + + override fun hashCode(): Int { + return Objects.hash( + authRuleToken, + applyAuthRuleRequestAccountTokens, + applyAuthRuleRequestCardTokens, + applyAuthRuleRequestProgramLevel, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "AuthRuleV2ApplyParams{authRuleToken=$authRuleToken, applyAuthRuleRequestAccountTokens=$applyAuthRuleRequestAccountTokens, applyAuthRuleRequestCardTokens=$applyAuthRuleRequestCardTokens, applyAuthRuleRequestProgramLevel=$applyAuthRuleRequestProgramLevel, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var authRuleToken: String? = null + private var applyAuthRuleRequestAccountTokens: ApplyAuthRuleRequestAccountTokens? = null + private var applyAuthRuleRequestCardTokens: ApplyAuthRuleRequestCardTokens? = null + private var applyAuthRuleRequestProgramLevel: ApplyAuthRuleRequestProgramLevel? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + + @JvmSynthetic + internal fun from(authRuleV2ApplyParams: AuthRuleV2ApplyParams) = apply { + this.authRuleToken = authRuleV2ApplyParams.authRuleToken + this.applyAuthRuleRequestAccountTokens = + authRuleV2ApplyParams.applyAuthRuleRequestAccountTokens + this.applyAuthRuleRequestCardTokens = + authRuleV2ApplyParams.applyAuthRuleRequestCardTokens + this.applyAuthRuleRequestProgramLevel = + authRuleV2ApplyParams.applyAuthRuleRequestProgramLevel + additionalQueryParams(authRuleV2ApplyParams.additionalQueryParams) + additionalHeaders(authRuleV2ApplyParams.additionalHeaders) + } + + fun authRuleToken(authRuleToken: String) = apply { this.authRuleToken = authRuleToken } + + fun forApplyAuthRuleRequestAccountTokens( + applyAuthRuleRequestAccountTokens: ApplyAuthRuleRequestAccountTokens + ) = apply { + this.applyAuthRuleRequestAccountTokens = applyAuthRuleRequestAccountTokens + this.applyAuthRuleRequestCardTokens = null + this.applyAuthRuleRequestProgramLevel = null + } + + fun forApplyAuthRuleRequestCardTokens( + applyAuthRuleRequestCardTokens: ApplyAuthRuleRequestCardTokens + ) = apply { + this.applyAuthRuleRequestAccountTokens = null + this.applyAuthRuleRequestCardTokens = applyAuthRuleRequestCardTokens + this.applyAuthRuleRequestProgramLevel = null + } + + fun forApplyAuthRuleRequestProgramLevel( + applyAuthRuleRequestProgramLevel: ApplyAuthRuleRequestProgramLevel + ) = apply { + this.applyAuthRuleRequestAccountTokens = null + this.applyAuthRuleRequestCardTokens = null + this.applyAuthRuleRequestProgramLevel = applyAuthRuleRequestProgramLevel + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun build(): AuthRuleV2ApplyParams = + AuthRuleV2ApplyParams( + checkNotNull(authRuleToken) { "`authRuleToken` is required but was not set" }, + applyAuthRuleRequestAccountTokens, + applyAuthRuleRequestCardTokens, + applyAuthRuleRequestProgramLevel, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = ApplyAuthRuleRequestAccountTokens.Builder::class) + @NoAutoDetect + class ApplyAuthRuleRequestAccountTokens + private constructor( + private val accountTokens: List?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") fun accountTokens(): List? = accountTokens + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApplyAuthRuleRequestAccountTokens && + this.accountTokens == other.accountTokens && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(accountTokens, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ApplyAuthRuleRequestAccountTokens{accountTokens=$accountTokens, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var accountTokens: List? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + applyAuthRuleRequestAccountTokens: ApplyAuthRuleRequestAccountTokens + ) = apply { + this.accountTokens = applyAuthRuleRequestAccountTokens.accountTokens + additionalProperties(applyAuthRuleRequestAccountTokens.additionalProperties) + } + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") + fun accountTokens(accountTokens: List) = apply { + this.accountTokens = accountTokens + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ApplyAuthRuleRequestAccountTokens = + ApplyAuthRuleRequestAccountTokens( + checkNotNull(accountTokens) { "`accountTokens` is required but was not set" } + .toUnmodifiable(), + additionalProperties.toUnmodifiable() + ) + } + } + + @JsonDeserialize(builder = ApplyAuthRuleRequestCardTokens.Builder::class) + @NoAutoDetect + class ApplyAuthRuleRequestCardTokens + private constructor( + private val cardTokens: List?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") fun cardTokens(): List? = cardTokens + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApplyAuthRuleRequestCardTokens && + this.cardTokens == other.cardTokens && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(cardTokens, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ApplyAuthRuleRequestCardTokens{cardTokens=$cardTokens, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var cardTokens: List? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(applyAuthRuleRequestCardTokens: ApplyAuthRuleRequestCardTokens) = + apply { + this.cardTokens = applyAuthRuleRequestCardTokens.cardTokens + additionalProperties(applyAuthRuleRequestCardTokens.additionalProperties) + } + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") + fun cardTokens(cardTokens: List) = apply { this.cardTokens = cardTokens } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ApplyAuthRuleRequestCardTokens = + ApplyAuthRuleRequestCardTokens( + checkNotNull(cardTokens) { "`cardTokens` is required but was not set" } + .toUnmodifiable(), + additionalProperties.toUnmodifiable() + ) + } + } + + @JsonDeserialize(builder = ApplyAuthRuleRequestProgramLevel.Builder::class) + @NoAutoDetect + class ApplyAuthRuleRequestProgramLevel + private constructor( + private val programLevel: Boolean?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") fun programLevel(): Boolean? = programLevel + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApplyAuthRuleRequestProgramLevel && + this.programLevel == other.programLevel && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(programLevel, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ApplyAuthRuleRequestProgramLevel{programLevel=$programLevel, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var programLevel: Boolean? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(applyAuthRuleRequestProgramLevel: ApplyAuthRuleRequestProgramLevel) = + apply { + this.programLevel = applyAuthRuleRequestProgramLevel.programLevel + additionalProperties(applyAuthRuleRequestProgramLevel.additionalProperties) + } + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") + fun programLevel(programLevel: Boolean) = apply { this.programLevel = programLevel } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ApplyAuthRuleRequestProgramLevel = + ApplyAuthRuleRequestProgramLevel( + checkNotNull(programLevel) { "`programLevel` is required but was not set" }, + additionalProperties.toUnmodifiable() + ) + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt new file mode 100644 index 00000000..badf0231 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt @@ -0,0 +1,3008 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import com.lithic.api.models.* +import java.util.Objects +import java.util.Optional + +class AuthRuleV2CreateParams +constructor( + private val createAuthRuleRequestAccountTokens: CreateAuthRuleRequestAccountTokens?, + private val createAuthRuleRequestCardTokens: CreateAuthRuleRequestCardTokens?, + private val createAuthRuleRequestProgramLevel: CreateAuthRuleRequestProgramLevel?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun createAuthRuleRequestAccountTokens(): Optional = + Optional.ofNullable(createAuthRuleRequestAccountTokens) + + fun createAuthRuleRequestCardTokens(): Optional = + Optional.ofNullable(createAuthRuleRequestCardTokens) + + fun createAuthRuleRequestProgramLevel(): Optional = + Optional.ofNullable(createAuthRuleRequestProgramLevel) + + @JvmSynthetic + internal fun getBody(): AuthRuleV2CreateBody { + return AuthRuleV2CreateBody( + createAuthRuleRequestAccountTokens, + createAuthRuleRequestCardTokens, + createAuthRuleRequestProgramLevel, + ) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + @JsonDeserialize(using = AuthRuleV2CreateBody.Deserializer::class) + @JsonSerialize(using = AuthRuleV2CreateBody.Serializer::class) + class AuthRuleV2CreateBody + internal constructor( + private val createAuthRuleRequestAccountTokens: CreateAuthRuleRequestAccountTokens? = null, + private val createAuthRuleRequestCardTokens: CreateAuthRuleRequestCardTokens? = null, + private val createAuthRuleRequestProgramLevel: CreateAuthRuleRequestProgramLevel? = null, + private val _json: JsonValue? = null, + ) { + + fun createAuthRuleRequestAccountTokens(): Optional = + Optional.ofNullable(createAuthRuleRequestAccountTokens) + + fun createAuthRuleRequestCardTokens(): Optional = + Optional.ofNullable(createAuthRuleRequestCardTokens) + + fun createAuthRuleRequestProgramLevel(): Optional = + Optional.ofNullable(createAuthRuleRequestProgramLevel) + + fun isCreateAuthRuleRequestAccountTokens(): Boolean = + createAuthRuleRequestAccountTokens != null + + fun isCreateAuthRuleRequestCardTokens(): Boolean = createAuthRuleRequestCardTokens != null + + fun isCreateAuthRuleRequestProgramLevel(): Boolean = + createAuthRuleRequestProgramLevel != null + + fun asCreateAuthRuleRequestAccountTokens(): CreateAuthRuleRequestAccountTokens = + createAuthRuleRequestAccountTokens.getOrThrow("createAuthRuleRequestAccountTokens") + + fun asCreateAuthRuleRequestCardTokens(): CreateAuthRuleRequestCardTokens = + createAuthRuleRequestCardTokens.getOrThrow("createAuthRuleRequestCardTokens") + + fun asCreateAuthRuleRequestProgramLevel(): CreateAuthRuleRequestProgramLevel = + createAuthRuleRequestProgramLevel.getOrThrow("createAuthRuleRequestProgramLevel") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + createAuthRuleRequestAccountTokens != null -> + visitor.visitCreateAuthRuleRequestAccountTokens( + createAuthRuleRequestAccountTokens + ) + createAuthRuleRequestCardTokens != null -> + visitor.visitCreateAuthRuleRequestCardTokens(createAuthRuleRequestCardTokens) + createAuthRuleRequestProgramLevel != null -> + visitor.visitCreateAuthRuleRequestProgramLevel( + createAuthRuleRequestProgramLevel + ) + else -> visitor.unknown(_json) + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleV2CreateBody && + this.createAuthRuleRequestAccountTokens == + other.createAuthRuleRequestAccountTokens && + this.createAuthRuleRequestCardTokens == other.createAuthRuleRequestCardTokens && + this.createAuthRuleRequestProgramLevel == other.createAuthRuleRequestProgramLevel + } + + override fun hashCode(): Int { + return Objects.hash( + createAuthRuleRequestAccountTokens, + createAuthRuleRequestCardTokens, + createAuthRuleRequestProgramLevel, + ) + } + + override fun toString(): String { + return when { + createAuthRuleRequestAccountTokens != null -> + "AuthRuleV2CreateBody{createAuthRuleRequestAccountTokens=$createAuthRuleRequestAccountTokens}" + createAuthRuleRequestCardTokens != null -> + "AuthRuleV2CreateBody{createAuthRuleRequestCardTokens=$createAuthRuleRequestCardTokens}" + createAuthRuleRequestProgramLevel != null -> + "AuthRuleV2CreateBody{createAuthRuleRequestProgramLevel=$createAuthRuleRequestProgramLevel}" + _json != null -> "AuthRuleV2CreateBody{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleV2CreateBody") + } + } + + companion object { + + @JvmStatic + fun ofCreateAuthRuleRequestAccountTokens( + createAuthRuleRequestAccountTokens: CreateAuthRuleRequestAccountTokens + ) = + AuthRuleV2CreateBody( + createAuthRuleRequestAccountTokens = createAuthRuleRequestAccountTokens + ) + + @JvmStatic + fun ofCreateAuthRuleRequestCardTokens( + createAuthRuleRequestCardTokens: CreateAuthRuleRequestCardTokens + ) = + AuthRuleV2CreateBody( + createAuthRuleRequestCardTokens = createAuthRuleRequestCardTokens + ) + + @JvmStatic + fun ofCreateAuthRuleRequestProgramLevel( + createAuthRuleRequestProgramLevel: CreateAuthRuleRequestProgramLevel + ) = + AuthRuleV2CreateBody( + createAuthRuleRequestProgramLevel = createAuthRuleRequestProgramLevel + ) + } + + interface Visitor { + + fun visitCreateAuthRuleRequestAccountTokens( + createAuthRuleRequestAccountTokens: CreateAuthRuleRequestAccountTokens + ): T + + fun visitCreateAuthRuleRequestCardTokens( + createAuthRuleRequestCardTokens: CreateAuthRuleRequestCardTokens + ): T + + fun visitCreateAuthRuleRequestProgramLevel( + createAuthRuleRequestProgramLevel: CreateAuthRuleRequestProgramLevel + ): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleV2CreateBody: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleV2CreateBody::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleV2CreateBody { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return AuthRuleV2CreateBody( + createAuthRuleRequestAccountTokens = it, + _json = json + ) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return AuthRuleV2CreateBody(createAuthRuleRequestCardTokens = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return AuthRuleV2CreateBody( + createAuthRuleRequestProgramLevel = it, + _json = json + ) + } + + return AuthRuleV2CreateBody(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleV2CreateBody::class) { + + override fun serialize( + value: AuthRuleV2CreateBody, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.createAuthRuleRequestAccountTokens != null -> + generator.writeObject(value.createAuthRuleRequestAccountTokens) + value.createAuthRuleRequestCardTokens != null -> + generator.writeObject(value.createAuthRuleRequestCardTokens) + value.createAuthRuleRequestProgramLevel != null -> + generator.writeObject(value.createAuthRuleRequestProgramLevel) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleV2CreateBody") + } + } + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleV2CreateParams && + this.createAuthRuleRequestAccountTokens == other.createAuthRuleRequestAccountTokens && + this.createAuthRuleRequestCardTokens == other.createAuthRuleRequestCardTokens && + this.createAuthRuleRequestProgramLevel == other.createAuthRuleRequestProgramLevel && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders + } + + override fun hashCode(): Int { + return Objects.hash( + createAuthRuleRequestAccountTokens, + createAuthRuleRequestCardTokens, + createAuthRuleRequestProgramLevel, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "AuthRuleV2CreateParams{createAuthRuleRequestAccountTokens=$createAuthRuleRequestAccountTokens, createAuthRuleRequestCardTokens=$createAuthRuleRequestCardTokens, createAuthRuleRequestProgramLevel=$createAuthRuleRequestProgramLevel, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var createAuthRuleRequestAccountTokens: CreateAuthRuleRequestAccountTokens? = null + private var createAuthRuleRequestCardTokens: CreateAuthRuleRequestCardTokens? = null + private var createAuthRuleRequestProgramLevel: CreateAuthRuleRequestProgramLevel? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + + @JvmSynthetic + internal fun from(authRuleV2CreateParams: AuthRuleV2CreateParams) = apply { + this.createAuthRuleRequestAccountTokens = + authRuleV2CreateParams.createAuthRuleRequestAccountTokens + this.createAuthRuleRequestCardTokens = + authRuleV2CreateParams.createAuthRuleRequestCardTokens + this.createAuthRuleRequestProgramLevel = + authRuleV2CreateParams.createAuthRuleRequestProgramLevel + additionalQueryParams(authRuleV2CreateParams.additionalQueryParams) + additionalHeaders(authRuleV2CreateParams.additionalHeaders) + } + + fun forCreateAuthRuleRequestAccountTokens( + createAuthRuleRequestAccountTokens: CreateAuthRuleRequestAccountTokens + ) = apply { + this.createAuthRuleRequestAccountTokens = createAuthRuleRequestAccountTokens + this.createAuthRuleRequestCardTokens = null + this.createAuthRuleRequestProgramLevel = null + } + + fun forCreateAuthRuleRequestCardTokens( + createAuthRuleRequestCardTokens: CreateAuthRuleRequestCardTokens + ) = apply { + this.createAuthRuleRequestAccountTokens = null + this.createAuthRuleRequestCardTokens = createAuthRuleRequestCardTokens + this.createAuthRuleRequestProgramLevel = null + } + + fun forCreateAuthRuleRequestProgramLevel( + createAuthRuleRequestProgramLevel: CreateAuthRuleRequestProgramLevel + ) = apply { + this.createAuthRuleRequestAccountTokens = null + this.createAuthRuleRequestCardTokens = null + this.createAuthRuleRequestProgramLevel = createAuthRuleRequestProgramLevel + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun build(): AuthRuleV2CreateParams = + AuthRuleV2CreateParams( + createAuthRuleRequestAccountTokens, + createAuthRuleRequestCardTokens, + createAuthRuleRequestProgramLevel, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = CreateAuthRuleRequestAccountTokens.Builder::class) + @NoAutoDetect + class CreateAuthRuleRequestAccountTokens + private constructor( + private val accountTokens: List?, + private val type: AuthRuleType?, + private val parameters: AuthRuleParameters?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") fun accountTokens(): List? = accountTokens + + /** The type of Auth Rule */ + @JsonProperty("type") fun type(): AuthRuleType? = type + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") fun parameters(): AuthRuleParameters? = parameters + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateAuthRuleRequestAccountTokens && + this.accountTokens == other.accountTokens && + this.type == other.type && + this.parameters == other.parameters && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + accountTokens, + type, + parameters, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreateAuthRuleRequestAccountTokens{accountTokens=$accountTokens, type=$type, parameters=$parameters, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var accountTokens: List? = null + private var type: AuthRuleType? = null + private var parameters: AuthRuleParameters? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + createAuthRuleRequestAccountTokens: CreateAuthRuleRequestAccountTokens + ) = apply { + this.accountTokens = createAuthRuleRequestAccountTokens.accountTokens + this.type = createAuthRuleRequestAccountTokens.type + this.parameters = createAuthRuleRequestAccountTokens.parameters + additionalProperties(createAuthRuleRequestAccountTokens.additionalProperties) + } + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") + fun accountTokens(accountTokens: List) = apply { + this.accountTokens = accountTokens + } + + /** The type of Auth Rule */ + @JsonProperty("type") fun type(type: AuthRuleType) = apply { this.type = type } + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + fun parameters(parameters: AuthRuleParameters) = apply { this.parameters = parameters } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): CreateAuthRuleRequestAccountTokens = + CreateAuthRuleRequestAccountTokens( + checkNotNull(accountTokens) { "`accountTokens` is required but was not set" } + .toUnmodifiable(), + type, + parameters, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + + class AuthRuleType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CONDITIONAL_BLOCK = AuthRuleType(JsonField.of("CONDITIONAL_BLOCK")) + + @JvmField val VELOCITY_LIMIT = AuthRuleType(JsonField.of("VELOCITY_LIMIT")) + + @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) + } + + enum class Known { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + } + + enum class Value { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Value.VELOCITY_LIMIT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Known.VELOCITY_LIMIT + else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = CreateAuthRuleRequestCardTokens.Builder::class) + @NoAutoDetect + class CreateAuthRuleRequestCardTokens + private constructor( + private val cardTokens: List?, + private val type: AuthRuleType?, + private val parameters: AuthRuleParameters?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") fun cardTokens(): List? = cardTokens + + /** The type of Auth Rule */ + @JsonProperty("type") fun type(): AuthRuleType? = type + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") fun parameters(): AuthRuleParameters? = parameters + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateAuthRuleRequestCardTokens && + this.cardTokens == other.cardTokens && + this.type == other.type && + this.parameters == other.parameters && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + cardTokens, + type, + parameters, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreateAuthRuleRequestCardTokens{cardTokens=$cardTokens, type=$type, parameters=$parameters, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var cardTokens: List? = null + private var type: AuthRuleType? = null + private var parameters: AuthRuleParameters? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createAuthRuleRequestCardTokens: CreateAuthRuleRequestCardTokens) = + apply { + this.cardTokens = createAuthRuleRequestCardTokens.cardTokens + this.type = createAuthRuleRequestCardTokens.type + this.parameters = createAuthRuleRequestCardTokens.parameters + additionalProperties(createAuthRuleRequestCardTokens.additionalProperties) + } + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") + fun cardTokens(cardTokens: List) = apply { this.cardTokens = cardTokens } + + /** The type of Auth Rule */ + @JsonProperty("type") fun type(type: AuthRuleType) = apply { this.type = type } + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + fun parameters(parameters: AuthRuleParameters) = apply { this.parameters = parameters } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): CreateAuthRuleRequestCardTokens = + CreateAuthRuleRequestCardTokens( + checkNotNull(cardTokens) { "`cardTokens` is required but was not set" } + .toUnmodifiable(), + type, + parameters, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + + class AuthRuleType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CONDITIONAL_BLOCK = AuthRuleType(JsonField.of("CONDITIONAL_BLOCK")) + + @JvmField val VELOCITY_LIMIT = AuthRuleType(JsonField.of("VELOCITY_LIMIT")) + + @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) + } + + enum class Known { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + } + + enum class Value { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Value.VELOCITY_LIMIT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Known.VELOCITY_LIMIT + else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + + @JsonDeserialize(builder = CreateAuthRuleRequestProgramLevel.Builder::class) + @NoAutoDetect + class CreateAuthRuleRequestProgramLevel + private constructor( + private val programLevel: Boolean?, + private val type: AuthRuleType?, + private val parameters: AuthRuleParameters?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") fun programLevel(): Boolean? = programLevel + + /** The type of Auth Rule */ + @JsonProperty("type") fun type(): AuthRuleType? = type + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") fun parameters(): AuthRuleParameters? = parameters + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateAuthRuleRequestProgramLevel && + this.programLevel == other.programLevel && + this.type == other.type && + this.parameters == other.parameters && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + programLevel, + type, + parameters, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CreateAuthRuleRequestProgramLevel{programLevel=$programLevel, type=$type, parameters=$parameters, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var programLevel: Boolean? = null + private var type: AuthRuleType? = null + private var parameters: AuthRuleParameters? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + createAuthRuleRequestProgramLevel: CreateAuthRuleRequestProgramLevel + ) = apply { + this.programLevel = createAuthRuleRequestProgramLevel.programLevel + this.type = createAuthRuleRequestProgramLevel.type + this.parameters = createAuthRuleRequestProgramLevel.parameters + additionalProperties(createAuthRuleRequestProgramLevel.additionalProperties) + } + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") + fun programLevel(programLevel: Boolean) = apply { this.programLevel = programLevel } + + /** The type of Auth Rule */ + @JsonProperty("type") fun type(type: AuthRuleType) = apply { this.type = type } + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + fun parameters(parameters: AuthRuleParameters) = apply { this.parameters = parameters } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): CreateAuthRuleRequestProgramLevel = + CreateAuthRuleRequestProgramLevel( + checkNotNull(programLevel) { "`programLevel` is required but was not set" }, + type, + parameters, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + + class AuthRuleType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CONDITIONAL_BLOCK = AuthRuleType(JsonField.of("CONDITIONAL_BLOCK")) + + @JvmField val VELOCITY_LIMIT = AuthRuleType(JsonField.of("VELOCITY_LIMIT")) + + @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) + } + + enum class Known { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + } + + enum class Value { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Value.VELOCITY_LIMIT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Known.VELOCITY_LIMIT + else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2DraftParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2DraftParams.kt new file mode 100644 index 00000000..1df9a5f6 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2DraftParams.kt @@ -0,0 +1,973 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import com.lithic.api.models.* +import java.util.Objects +import java.util.Optional + +class AuthRuleV2DraftParams +constructor( + private val authRuleToken: String, + private val parameters: AuthRuleParameters?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun authRuleToken(): String = authRuleToken + + fun parameters(): Optional = Optional.ofNullable(parameters) + + @JvmSynthetic + internal fun getBody(): AuthRuleV2DraftBody { + return AuthRuleV2DraftBody(parameters, additionalBodyProperties) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> authRuleToken + else -> "" + } + } + + @JsonDeserialize(builder = AuthRuleV2DraftBody.Builder::class) + @NoAutoDetect + class AuthRuleV2DraftBody + internal constructor( + private val parameters: AuthRuleParameters?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") fun parameters(): AuthRuleParameters? = parameters + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleV2DraftBody && + this.parameters == other.parameters && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(parameters, additionalProperties) + } + return hashCode + } + + override fun toString() = + "AuthRuleV2DraftBody{parameters=$parameters, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: AuthRuleParameters? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authRuleV2DraftBody: AuthRuleV2DraftBody) = apply { + this.parameters = authRuleV2DraftBody.parameters + additionalProperties(authRuleV2DraftBody.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + fun parameters(parameters: AuthRuleParameters) = apply { this.parameters = parameters } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AuthRuleV2DraftBody = + AuthRuleV2DraftBody(parameters, additionalProperties.toUnmodifiable()) + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleV2DraftParams && + this.authRuleToken == other.authRuleToken && + this.parameters == other.parameters && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + authRuleToken, + parameters, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "AuthRuleV2DraftParams{authRuleToken=$authRuleToken, parameters=$parameters, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var authRuleToken: String? = null + private var parameters: AuthRuleParameters? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authRuleV2DraftParams: AuthRuleV2DraftParams) = apply { + this.authRuleToken = authRuleV2DraftParams.authRuleToken + this.parameters = authRuleV2DraftParams.parameters + additionalQueryParams(authRuleV2DraftParams.additionalQueryParams) + additionalHeaders(authRuleV2DraftParams.additionalHeaders) + additionalBodyProperties(authRuleV2DraftParams.additionalBodyProperties) + } + + fun authRuleToken(authRuleToken: String) = apply { this.authRuleToken = authRuleToken } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = apply { this.parameters = parameters } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(conditionalBlockParameters: AuthRuleParameters.ConditionalBlockParameters) = + apply { + this.parameters = + AuthRuleParameters.ofConditionalBlockParameters(conditionalBlockParameters) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(velocityLimitParams: VelocityLimitParams) = apply { + this.parameters = AuthRuleParameters.ofVelocityLimitParams(velocityLimitParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): AuthRuleV2DraftParams = + AuthRuleV2DraftParams( + checkNotNull(authRuleToken) { "`authRuleToken` is required but was not set" }, + parameters, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPage.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPage.kt new file mode 100644 index 00000000..85b38c74 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPage.kt @@ -0,0 +1,219 @@ +// 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.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.services.blocking.authRules.V2Service +import java.util.Objects +import java.util.Optional +import java.util.stream.Stream +import java.util.stream.StreamSupport + +class AuthRuleV2ListPage +private constructor( + private val v2Service: V2Service, + private val params: AuthRuleV2ListParams, + private val response: Response, +) { + + fun response(): Response = response + + fun data(): List = response().data() + + fun hasMore(): Boolean = response().hasMore() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleV2ListPage && + this.v2Service == other.v2Service && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + v2Service, + params, + response, + ) + } + + override fun toString() = + "AuthRuleV2ListPage{v2Service=$v2Service, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return !data().isEmpty() + } + + fun getNextPageParams(): Optional { + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + AuthRuleV2ListParams.builder() + .from(params) + .endingBefore(data().first().token()) + .build() + ) + } else { + Optional.of( + AuthRuleV2ListParams.builder() + .from(params) + .startingAfter(data().last().token()) + .build() + ) + } + } + + fun getNextPage(): Optional { + return getNextPageParams().map { v2Service.list(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + @JvmStatic + fun of(v2Service: V2Service, params: AuthRuleV2ListParams, response: Response) = + AuthRuleV2ListPage( + v2Service, + params, + response, + ) + } + + @JsonDeserialize(builder = Response.Builder::class) + @NoAutoDetect + class Response + constructor( + private val data: JsonField>, + private val hasMore: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun data(): List = data.getNullable("data") ?: listOf() + + fun hasMore(): Boolean = hasMore.getRequired("has_more") + + @JsonProperty("data") + fun _data(): Optional>> = Optional.ofNullable(data) + + @JsonProperty("has_more") + fun _hasMore(): Optional> = Optional.ofNullable(hasMore) + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Response = apply { + if (!validated) { + data().map { it.validate() } + hasMore() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Response && + this.data == other.data && + this.hasMore == other.hasMore && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + return Objects.hash( + data, + hasMore, + additionalProperties, + ) + } + + override fun toString() = + "AuthRuleV2ListPage.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(page: Response) = apply { + this.data = page.data + this.hasMore = page.hasMore + this.additionalProperties.putAll(page.additionalProperties) + } + + fun data(data: List) = data(JsonField.of(data)) + + @JsonProperty("data") + fun data(data: JsonField>) = apply { this.data = data } + + fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) + + @JsonProperty("has_more") + fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun build() = + Response( + data, + hasMore, + additionalProperties.toUnmodifiable(), + ) + } + } + + class AutoPager + constructor( + private val firstPage: AuthRuleV2ListPage, + ) : Iterable { + + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.data().size) { + yield(page.data()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 + } + } + + fun stream(): Stream { + return StreamSupport.stream(spliterator(), false) + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPageAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPageAsync.kt new file mode 100644 index 00000000..57085db2 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPageAsync.kt @@ -0,0 +1,232 @@ +// 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.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.services.async.authRules.V2ServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate + +class AuthRuleV2ListPageAsync +private constructor( + private val v2Service: V2ServiceAsync, + private val params: AuthRuleV2ListParams, + private val response: Response, +) { + + fun response(): Response = response + + fun data(): List = response().data() + + fun hasMore(): Boolean = response().hasMore() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleV2ListPageAsync && + this.v2Service == other.v2Service && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + v2Service, + params, + response, + ) + } + + override fun toString() = + "AuthRuleV2ListPageAsync{v2Service=$v2Service, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return !data().isEmpty() + } + + fun getNextPageParams(): Optional { + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + AuthRuleV2ListParams.builder() + .from(params) + .endingBefore(data().first().token()) + .build() + ) + } else { + Optional.of( + AuthRuleV2ListParams.builder() + .from(params) + .startingAfter(data().last().token()) + .build() + ) + } + } + + fun getNextPage(): CompletableFuture> { + return getNextPageParams() + .map { v2Service.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + @JvmStatic + fun of(v2Service: V2ServiceAsync, params: AuthRuleV2ListParams, response: Response) = + AuthRuleV2ListPageAsync( + v2Service, + params, + response, + ) + } + + @JsonDeserialize(builder = Response.Builder::class) + @NoAutoDetect + class Response + constructor( + private val data: JsonField>, + private val hasMore: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun data(): List = data.getNullable("data") ?: listOf() + + fun hasMore(): Boolean = hasMore.getRequired("has_more") + + @JsonProperty("data") + fun _data(): Optional>> = Optional.ofNullable(data) + + @JsonProperty("has_more") + fun _hasMore(): Optional> = Optional.ofNullable(hasMore) + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Response = apply { + if (!validated) { + data().map { it.validate() } + hasMore() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Response && + this.data == other.data && + this.hasMore == other.hasMore && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + return Objects.hash( + data, + hasMore, + additionalProperties, + ) + } + + override fun toString() = + "AuthRuleV2ListPageAsync.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(page: Response) = apply { + this.data = page.data + this.hasMore = page.hasMore + this.additionalProperties.putAll(page.additionalProperties) + } + + fun data(data: List) = data(JsonField.of(data)) + + @JsonProperty("data") + fun data(data: JsonField>) = apply { this.data = data } + + fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) + + @JsonProperty("has_more") + fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun build() = + Response( + data, + hasMore, + additionalProperties.toUnmodifiable(), + ) + } + } + + class AutoPager + constructor( + private val firstPage: AuthRuleV2ListPageAsync, + ) { + + fun forEach( + action: Predicate, + executor: Executor + ): CompletableFuture { + fun CompletableFuture>.forEach( + action: (V2ListResponse) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.data().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) + } + + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListParams.kt new file mode 100644 index 00000000..6236e011 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListParams.kt @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.models.* +import java.util.Objects +import java.util.Optional + +class AuthRuleV2ListParams +constructor( + private val accountToken: String?, + private val cardToken: String?, + private val endingBefore: String?, + private val pageSize: Long?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun accountToken(): Optional = Optional.ofNullable(accountToken) + + fun cardToken(): Optional = Optional.ofNullable(cardToken) + + fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + + @JvmSynthetic + internal fun getQueryParams(): Map> { + val params = mutableMapOf>() + this.accountToken?.let { params.put("account_token", listOf(it.toString())) } + this.cardToken?.let { params.put("card_token", listOf(it.toString())) } + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.pageSize?.let { params.put("page_size", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() + } + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleV2ListParams && + this.accountToken == other.accountToken && + this.cardToken == other.cardToken && + this.endingBefore == other.endingBefore && + this.pageSize == other.pageSize && + this.startingAfter == other.startingAfter && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders + } + + override fun hashCode(): Int { + return Objects.hash( + accountToken, + cardToken, + endingBefore, + pageSize, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "AuthRuleV2ListParams{accountToken=$accountToken, cardToken=$cardToken, endingBefore=$endingBefore, pageSize=$pageSize, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var accountToken: String? = null + private var cardToken: String? = null + private var endingBefore: String? = null + private var pageSize: Long? = null + private var startingAfter: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + + @JvmSynthetic + internal fun from(authRuleV2ListParams: AuthRuleV2ListParams) = apply { + this.accountToken = authRuleV2ListParams.accountToken + this.cardToken = authRuleV2ListParams.cardToken + this.endingBefore = authRuleV2ListParams.endingBefore + this.pageSize = authRuleV2ListParams.pageSize + this.startingAfter = authRuleV2ListParams.startingAfter + additionalQueryParams(authRuleV2ListParams.additionalQueryParams) + additionalHeaders(authRuleV2ListParams.additionalHeaders) + } + + /** Only return Authorization Rules that are bound to the provided account token. */ + fun accountToken(accountToken: String) = apply { this.accountToken = accountToken } + + /** Only return Authorization Rules that are bound to the provided card token. */ + fun cardToken(cardToken: String) = apply { this.cardToken = cardToken } + + /** + * A cursor representing an item's token before which a page of results should end. Used to + * retrieve the previous page of results before this item. + */ + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + + /** Page size (for pagination). */ + fun pageSize(pageSize: Long) = apply { this.pageSize = pageSize } + + /** + * A cursor representing an item's token after which a page of results should begin. Used to + * retrieve the next page of results after this item. + */ + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun build(): AuthRuleV2ListParams = + AuthRuleV2ListParams( + accountToken, + cardToken, + endingBefore, + pageSize, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2PromoteParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2PromoteParams.kt new file mode 100644 index 00000000..f3288d5a --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2PromoteParams.kt @@ -0,0 +1,155 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.models.* +import java.util.Objects +import java.util.Optional + +class AuthRuleV2PromoteParams +constructor( + private val authRuleToken: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun authRuleToken(): String = authRuleToken + + @JvmSynthetic + internal fun getBody(): Optional> { + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> authRuleToken + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleV2PromoteParams && + this.authRuleToken == other.authRuleToken && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + authRuleToken, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "AuthRuleV2PromoteParams{authRuleToken=$authRuleToken, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var authRuleToken: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authRuleV2PromoteParams: AuthRuleV2PromoteParams) = apply { + this.authRuleToken = authRuleV2PromoteParams.authRuleToken + additionalQueryParams(authRuleV2PromoteParams.additionalQueryParams) + additionalHeaders(authRuleV2PromoteParams.additionalHeaders) + additionalBodyProperties(authRuleV2PromoteParams.additionalBodyProperties) + } + + fun authRuleToken(authRuleToken: String) = apply { this.authRuleToken = authRuleToken } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): AuthRuleV2PromoteParams = + AuthRuleV2PromoteParams( + checkNotNull(authRuleToken) { "`authRuleToken` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ReportParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ReportParams.kt new file mode 100644 index 00000000..8031cb58 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ReportParams.kt @@ -0,0 +1,155 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.models.* +import java.util.Objects +import java.util.Optional + +class AuthRuleV2ReportParams +constructor( + private val authRuleToken: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun authRuleToken(): String = authRuleToken + + @JvmSynthetic + internal fun getBody(): Optional> { + return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> authRuleToken + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleV2ReportParams && + this.authRuleToken == other.authRuleToken && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + authRuleToken, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "AuthRuleV2ReportParams{authRuleToken=$authRuleToken, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var authRuleToken: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authRuleV2ReportParams: AuthRuleV2ReportParams) = apply { + this.authRuleToken = authRuleV2ReportParams.authRuleToken + additionalQueryParams(authRuleV2ReportParams.additionalQueryParams) + additionalHeaders(authRuleV2ReportParams.additionalHeaders) + additionalBodyProperties(authRuleV2ReportParams.additionalBodyProperties) + } + + fun authRuleToken(authRuleToken: String) = apply { this.authRuleToken = authRuleToken } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): AuthRuleV2ReportParams = + AuthRuleV2ReportParams( + checkNotNull(authRuleToken) { "`authRuleToken` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2RetrieveParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2RetrieveParams.kt new file mode 100644 index 00000000..21648ac6 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2RetrieveParams.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.models.* +import java.util.Objects + +class AuthRuleV2RetrieveParams +constructor( + private val authRuleToken: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun authRuleToken(): String = authRuleToken + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> authRuleToken + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleV2RetrieveParams && + this.authRuleToken == other.authRuleToken && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders + } + + override fun hashCode(): Int { + return Objects.hash( + authRuleToken, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "AuthRuleV2RetrieveParams{authRuleToken=$authRuleToken, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var authRuleToken: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + + @JvmSynthetic + internal fun from(authRuleV2RetrieveParams: AuthRuleV2RetrieveParams) = apply { + this.authRuleToken = authRuleV2RetrieveParams.authRuleToken + additionalQueryParams(authRuleV2RetrieveParams.additionalQueryParams) + additionalHeaders(authRuleV2RetrieveParams.additionalHeaders) + } + + fun authRuleToken(authRuleToken: String) = apply { this.authRuleToken = authRuleToken } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun build(): AuthRuleV2RetrieveParams = + AuthRuleV2RetrieveParams( + checkNotNull(authRuleToken) { "`authRuleToken` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2UpdateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2UpdateParams.kt new file mode 100644 index 00000000..351a5a5e --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2UpdateParams.kt @@ -0,0 +1,321 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import com.lithic.api.models.* +import java.util.Objects +import java.util.Optional + +class AuthRuleV2UpdateParams +constructor( + private val authRuleToken: String, + private val state: State?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun authRuleToken(): String = authRuleToken + + fun state(): Optional = Optional.ofNullable(state) + + @JvmSynthetic + internal fun getBody(): AuthRuleV2UpdateBody { + return AuthRuleV2UpdateBody(state, additionalBodyProperties) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> authRuleToken + else -> "" + } + } + + @JsonDeserialize(builder = AuthRuleV2UpdateBody.Builder::class) + @NoAutoDetect + class AuthRuleV2UpdateBody + internal constructor( + private val state: State?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** + * The desired state of the Auth Rule. + * + * Note that only deactivating an Auth Rule through this endpoint is supported at this time. + * If you need to (re-)activate an Auth Rule the /promote endpoint should be used to promote + * a draft to the currently active version. + */ + @JsonProperty("state") fun state(): State? = state + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleV2UpdateBody && + this.state == other.state && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(state, additionalProperties) + } + return hashCode + } + + override fun toString() = + "AuthRuleV2UpdateBody{state=$state, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var state: State? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authRuleV2UpdateBody: AuthRuleV2UpdateBody) = apply { + this.state = authRuleV2UpdateBody.state + additionalProperties(authRuleV2UpdateBody.additionalProperties) + } + + /** + * The desired state of the Auth Rule. + * + * Note that only deactivating an Auth Rule through this endpoint is supported at this + * time. If you need to (re-)activate an Auth Rule the /promote endpoint should be used + * to promote a draft to the currently active version. + */ + @JsonProperty("state") fun state(state: State) = apply { this.state = state } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AuthRuleV2UpdateBody = + AuthRuleV2UpdateBody(state, additionalProperties.toUnmodifiable()) + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleV2UpdateParams && + this.authRuleToken == other.authRuleToken && + this.state == other.state && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + authRuleToken, + state, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "AuthRuleV2UpdateParams{authRuleToken=$authRuleToken, state=$state, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var authRuleToken: String? = null + private var state: State? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authRuleV2UpdateParams: AuthRuleV2UpdateParams) = apply { + this.authRuleToken = authRuleV2UpdateParams.authRuleToken + this.state = authRuleV2UpdateParams.state + additionalQueryParams(authRuleV2UpdateParams.additionalQueryParams) + additionalHeaders(authRuleV2UpdateParams.additionalHeaders) + additionalBodyProperties(authRuleV2UpdateParams.additionalBodyProperties) + } + + fun authRuleToken(authRuleToken: String) = apply { this.authRuleToken = authRuleToken } + + /** + * The desired state of the Auth Rule. + * + * Note that only deactivating an Auth Rule through this endpoint is supported at this time. + * If you need to (re-)activate an Auth Rule the /promote endpoint should be used to promote + * a draft to the currently active version. + */ + fun state(state: State) = apply { this.state = state } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): AuthRuleV2UpdateParams = + AuthRuleV2UpdateParams( + checkNotNull(authRuleToken) { "`authRuleToken` is required but was not set" }, + state, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } + + class State + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is State && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val INACTIVE = State(JsonField.of("INACTIVE")) + + @JvmStatic fun of(value: String) = State(JsonField.of(value)) + } + + enum class Known { + INACTIVE, + } + + enum class Value { + INACTIVE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + INACTIVE -> Known.INACTIVE + else -> throw LithicInvalidDataException("Unknown State: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} 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 d441cc04..d91d688a 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 @@ -161,7 +161,7 @@ private constructor( * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. * - `PENDING_FULFILLMENT` - The initial state for cards of type `PHYSICAL`. The card is * provisioned pending manufacturing and fulfillment. Cards in this state can accept - * authorizations for e-commerce purchases, but not for 'Card Present' purchases where the + * authorizations for e-commerce purchases, but not for "Card Present" purchases where the * physical card itself is present. * - `PENDING_ACTIVATION` - At regular intervals, cards of type `PHYSICAL` in state * `PENDING_FULFILLMENT` are sent to the card production warehouse and updated to state @@ -299,7 +299,7 @@ private constructor( * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. * - `PENDING_FULFILLMENT` - The initial state for cards of type `PHYSICAL`. The card is * provisioned pending manufacturing and fulfillment. Cards in this state can accept - * authorizations for e-commerce purchases, but not for 'Card Present' purchases where the + * authorizations for e-commerce purchases, but not for "Card Present" purchases where the * physical card itself is present. * - `PENDING_ACTIVATION` - At regular intervals, cards of type `PHYSICAL` in state * `PENDING_FULFILLMENT` are sent to the card production warehouse and updated to state @@ -748,7 +748,7 @@ private constructor( * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. * - `PENDING_FULFILLMENT` - The initial state for cards of type `PHYSICAL`. The card is * provisioned pending manufacturing and fulfillment. Cards in this state can accept - * authorizations for e-commerce purchases, but not for 'Card Present' purchases where the + * authorizations for e-commerce purchases, but not for "Card Present" purchases where the * physical card itself is present. * - `PENDING_ACTIVATION` - At regular intervals, cards of type `PHYSICAL` in state * `PENDING_FULFILLMENT` are sent to the card production warehouse and updated to state @@ -768,7 +768,7 @@ private constructor( * - `PAUSED` - Card will decline authorizations, but can be resumed at a later time. * - `PENDING_FULFILLMENT` - The initial state for cards of type `PHYSICAL`. The card is * provisioned pending manufacturing and fulfillment. Cards in this state can accept - * authorizations for e-commerce purchases, but not for 'Card Present' purchases where the + * authorizations for e-commerce purchases, but not for "Card Present" purchases where the * physical card itself is present. * - `PENDING_ACTIVATION` - At regular intervals, cards of type `PHYSICAL` in state * `PENDING_FULFILLMENT` are sent to the card production warehouse and updated to state diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Event.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Event.kt index 0b51be63..03420c2c 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Event.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Event.kt @@ -388,6 +388,12 @@ private constructor( val EXTERNAL_BANK_ACCOUNT_UPDATED = EventType(JsonField.of("external_bank_account.updated")) + @JvmField + val EXTERNAL_PAYMENT_CREATED = EventType(JsonField.of("external_payment.created")) + + @JvmField + val EXTERNAL_PAYMENT_UPDATED = EventType(JsonField.of("external_payment.updated")) + @JvmField val FINANCIAL_ACCOUNT_CREATED = EventType(JsonField.of("financial_account.created")) @@ -453,6 +459,8 @@ private constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED, EXTERNAL_BANK_ACCOUNT_CREATED, EXTERNAL_BANK_ACCOUNT_UPDATED, + EXTERNAL_PAYMENT_CREATED, + EXTERNAL_PAYMENT_UPDATED, FINANCIAL_ACCOUNT_CREATED, FINANCIAL_ACCOUNT_UPDATED, PAYMENT_TRANSACTION_CREATED, @@ -489,6 +497,8 @@ private constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED, EXTERNAL_BANK_ACCOUNT_CREATED, EXTERNAL_BANK_ACCOUNT_UPDATED, + EXTERNAL_PAYMENT_CREATED, + EXTERNAL_PAYMENT_UPDATED, FINANCIAL_ACCOUNT_CREATED, FINANCIAL_ACCOUNT_UPDATED, PAYMENT_TRANSACTION_CREATED, @@ -530,6 +540,8 @@ private constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED -> Value.DISPUTE_EVIDENCE_UPLOAD_FAILED EXTERNAL_BANK_ACCOUNT_CREATED -> Value.EXTERNAL_BANK_ACCOUNT_CREATED EXTERNAL_BANK_ACCOUNT_UPDATED -> Value.EXTERNAL_BANK_ACCOUNT_UPDATED + EXTERNAL_PAYMENT_CREATED -> Value.EXTERNAL_PAYMENT_CREATED + EXTERNAL_PAYMENT_UPDATED -> Value.EXTERNAL_PAYMENT_UPDATED FINANCIAL_ACCOUNT_CREATED -> Value.FINANCIAL_ACCOUNT_CREATED FINANCIAL_ACCOUNT_UPDATED -> Value.FINANCIAL_ACCOUNT_UPDATED PAYMENT_TRANSACTION_CREATED -> Value.PAYMENT_TRANSACTION_CREATED @@ -573,6 +585,8 @@ private constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED -> Known.DISPUTE_EVIDENCE_UPLOAD_FAILED EXTERNAL_BANK_ACCOUNT_CREATED -> Known.EXTERNAL_BANK_ACCOUNT_CREATED EXTERNAL_BANK_ACCOUNT_UPDATED -> Known.EXTERNAL_BANK_ACCOUNT_UPDATED + EXTERNAL_PAYMENT_CREATED -> Known.EXTERNAL_PAYMENT_CREATED + EXTERNAL_PAYMENT_UPDATED -> Known.EXTERNAL_PAYMENT_UPDATED FINANCIAL_ACCOUNT_CREATED -> Known.FINANCIAL_ACCOUNT_CREATED FINANCIAL_ACCOUNT_UPDATED -> Known.FINANCIAL_ACCOUNT_UPDATED PAYMENT_TRANSACTION_CREATED -> Known.PAYMENT_TRANSACTION_CREATED diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventListParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventListParams.kt index 314a284f..3af81fc2 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventListParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventListParams.kt @@ -314,6 +314,12 @@ constructor( val EXTERNAL_BANK_ACCOUNT_UPDATED = EventType(JsonField.of("external_bank_account.updated")) + @JvmField + val EXTERNAL_PAYMENT_CREATED = EventType(JsonField.of("external_payment.created")) + + @JvmField + val EXTERNAL_PAYMENT_UPDATED = EventType(JsonField.of("external_payment.updated")) + @JvmField val FINANCIAL_ACCOUNT_CREATED = EventType(JsonField.of("financial_account.created")) @@ -379,6 +385,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED, EXTERNAL_BANK_ACCOUNT_CREATED, EXTERNAL_BANK_ACCOUNT_UPDATED, + EXTERNAL_PAYMENT_CREATED, + EXTERNAL_PAYMENT_UPDATED, FINANCIAL_ACCOUNT_CREATED, FINANCIAL_ACCOUNT_UPDATED, PAYMENT_TRANSACTION_CREATED, @@ -415,6 +423,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED, EXTERNAL_BANK_ACCOUNT_CREATED, EXTERNAL_BANK_ACCOUNT_UPDATED, + EXTERNAL_PAYMENT_CREATED, + EXTERNAL_PAYMENT_UPDATED, FINANCIAL_ACCOUNT_CREATED, FINANCIAL_ACCOUNT_UPDATED, PAYMENT_TRANSACTION_CREATED, @@ -456,6 +466,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED -> Value.DISPUTE_EVIDENCE_UPLOAD_FAILED EXTERNAL_BANK_ACCOUNT_CREATED -> Value.EXTERNAL_BANK_ACCOUNT_CREATED EXTERNAL_BANK_ACCOUNT_UPDATED -> Value.EXTERNAL_BANK_ACCOUNT_UPDATED + EXTERNAL_PAYMENT_CREATED -> Value.EXTERNAL_PAYMENT_CREATED + EXTERNAL_PAYMENT_UPDATED -> Value.EXTERNAL_PAYMENT_UPDATED FINANCIAL_ACCOUNT_CREATED -> Value.FINANCIAL_ACCOUNT_CREATED FINANCIAL_ACCOUNT_UPDATED -> Value.FINANCIAL_ACCOUNT_UPDATED PAYMENT_TRANSACTION_CREATED -> Value.PAYMENT_TRANSACTION_CREATED @@ -499,6 +511,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED -> Known.DISPUTE_EVIDENCE_UPLOAD_FAILED EXTERNAL_BANK_ACCOUNT_CREATED -> Known.EXTERNAL_BANK_ACCOUNT_CREATED EXTERNAL_BANK_ACCOUNT_UPDATED -> Known.EXTERNAL_BANK_ACCOUNT_UPDATED + EXTERNAL_PAYMENT_CREATED -> Known.EXTERNAL_PAYMENT_CREATED + EXTERNAL_PAYMENT_UPDATED -> Known.EXTERNAL_PAYMENT_UPDATED FINANCIAL_ACCOUNT_CREATED -> Known.FINANCIAL_ACCOUNT_CREATED FINANCIAL_ACCOUNT_UPDATED -> Known.FINANCIAL_ACCOUNT_UPDATED PAYMENT_TRANSACTION_CREATED -> Known.PAYMENT_TRANSACTION_CREATED diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscription.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscription.kt index e019f0cb..65f2826e 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscription.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscription.kt @@ -286,6 +286,12 @@ private constructor( val EXTERNAL_BANK_ACCOUNT_UPDATED = EventType(JsonField.of("external_bank_account.updated")) + @JvmField + val EXTERNAL_PAYMENT_CREATED = EventType(JsonField.of("external_payment.created")) + + @JvmField + val EXTERNAL_PAYMENT_UPDATED = EventType(JsonField.of("external_payment.updated")) + @JvmField val FINANCIAL_ACCOUNT_CREATED = EventType(JsonField.of("financial_account.created")) @@ -351,6 +357,8 @@ private constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED, EXTERNAL_BANK_ACCOUNT_CREATED, EXTERNAL_BANK_ACCOUNT_UPDATED, + EXTERNAL_PAYMENT_CREATED, + EXTERNAL_PAYMENT_UPDATED, FINANCIAL_ACCOUNT_CREATED, FINANCIAL_ACCOUNT_UPDATED, PAYMENT_TRANSACTION_CREATED, @@ -387,6 +395,8 @@ private constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED, EXTERNAL_BANK_ACCOUNT_CREATED, EXTERNAL_BANK_ACCOUNT_UPDATED, + EXTERNAL_PAYMENT_CREATED, + EXTERNAL_PAYMENT_UPDATED, FINANCIAL_ACCOUNT_CREATED, FINANCIAL_ACCOUNT_UPDATED, PAYMENT_TRANSACTION_CREATED, @@ -428,6 +438,8 @@ private constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED -> Value.DISPUTE_EVIDENCE_UPLOAD_FAILED EXTERNAL_BANK_ACCOUNT_CREATED -> Value.EXTERNAL_BANK_ACCOUNT_CREATED EXTERNAL_BANK_ACCOUNT_UPDATED -> Value.EXTERNAL_BANK_ACCOUNT_UPDATED + EXTERNAL_PAYMENT_CREATED -> Value.EXTERNAL_PAYMENT_CREATED + EXTERNAL_PAYMENT_UPDATED -> Value.EXTERNAL_PAYMENT_UPDATED FINANCIAL_ACCOUNT_CREATED -> Value.FINANCIAL_ACCOUNT_CREATED FINANCIAL_ACCOUNT_UPDATED -> Value.FINANCIAL_ACCOUNT_UPDATED PAYMENT_TRANSACTION_CREATED -> Value.PAYMENT_TRANSACTION_CREATED @@ -471,6 +483,8 @@ private constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED -> Known.DISPUTE_EVIDENCE_UPLOAD_FAILED EXTERNAL_BANK_ACCOUNT_CREATED -> Known.EXTERNAL_BANK_ACCOUNT_CREATED EXTERNAL_BANK_ACCOUNT_UPDATED -> Known.EXTERNAL_BANK_ACCOUNT_UPDATED + EXTERNAL_PAYMENT_CREATED -> Known.EXTERNAL_PAYMENT_CREATED + EXTERNAL_PAYMENT_UPDATED -> Known.EXTERNAL_PAYMENT_UPDATED FINANCIAL_ACCOUNT_CREATED -> Known.FINANCIAL_ACCOUNT_CREATED FINANCIAL_ACCOUNT_UPDATED -> Known.FINANCIAL_ACCOUNT_UPDATED PAYMENT_TRANSACTION_CREATED -> Known.PAYMENT_TRANSACTION_CREATED diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionCreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionCreateParams.kt index 549b080b..a536f888 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionCreateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionCreateParams.kt @@ -424,6 +424,12 @@ constructor( val EXTERNAL_BANK_ACCOUNT_UPDATED = EventType(JsonField.of("external_bank_account.updated")) + @JvmField + val EXTERNAL_PAYMENT_CREATED = EventType(JsonField.of("external_payment.created")) + + @JvmField + val EXTERNAL_PAYMENT_UPDATED = EventType(JsonField.of("external_payment.updated")) + @JvmField val FINANCIAL_ACCOUNT_CREATED = EventType(JsonField.of("financial_account.created")) @@ -489,6 +495,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED, EXTERNAL_BANK_ACCOUNT_CREATED, EXTERNAL_BANK_ACCOUNT_UPDATED, + EXTERNAL_PAYMENT_CREATED, + EXTERNAL_PAYMENT_UPDATED, FINANCIAL_ACCOUNT_CREATED, FINANCIAL_ACCOUNT_UPDATED, PAYMENT_TRANSACTION_CREATED, @@ -525,6 +533,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED, EXTERNAL_BANK_ACCOUNT_CREATED, EXTERNAL_BANK_ACCOUNT_UPDATED, + EXTERNAL_PAYMENT_CREATED, + EXTERNAL_PAYMENT_UPDATED, FINANCIAL_ACCOUNT_CREATED, FINANCIAL_ACCOUNT_UPDATED, PAYMENT_TRANSACTION_CREATED, @@ -566,6 +576,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED -> Value.DISPUTE_EVIDENCE_UPLOAD_FAILED EXTERNAL_BANK_ACCOUNT_CREATED -> Value.EXTERNAL_BANK_ACCOUNT_CREATED EXTERNAL_BANK_ACCOUNT_UPDATED -> Value.EXTERNAL_BANK_ACCOUNT_UPDATED + EXTERNAL_PAYMENT_CREATED -> Value.EXTERNAL_PAYMENT_CREATED + EXTERNAL_PAYMENT_UPDATED -> Value.EXTERNAL_PAYMENT_UPDATED FINANCIAL_ACCOUNT_CREATED -> Value.FINANCIAL_ACCOUNT_CREATED FINANCIAL_ACCOUNT_UPDATED -> Value.FINANCIAL_ACCOUNT_UPDATED PAYMENT_TRANSACTION_CREATED -> Value.PAYMENT_TRANSACTION_CREATED @@ -609,6 +621,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED -> Known.DISPUTE_EVIDENCE_UPLOAD_FAILED EXTERNAL_BANK_ACCOUNT_CREATED -> Known.EXTERNAL_BANK_ACCOUNT_CREATED EXTERNAL_BANK_ACCOUNT_UPDATED -> Known.EXTERNAL_BANK_ACCOUNT_UPDATED + EXTERNAL_PAYMENT_CREATED -> Known.EXTERNAL_PAYMENT_CREATED + EXTERNAL_PAYMENT_UPDATED -> Known.EXTERNAL_PAYMENT_UPDATED FINANCIAL_ACCOUNT_CREATED -> Known.FINANCIAL_ACCOUNT_CREATED FINANCIAL_ACCOUNT_UPDATED -> Known.FINANCIAL_ACCOUNT_UPDATED PAYMENT_TRANSACTION_CREATED -> Known.PAYMENT_TRANSACTION_CREATED diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionSendSimulatedExampleParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionSendSimulatedExampleParams.kt index f9d8f993..57f199c6 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionSendSimulatedExampleParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionSendSimulatedExampleParams.kt @@ -353,6 +353,12 @@ constructor( val EXTERNAL_BANK_ACCOUNT_UPDATED = EventType(JsonField.of("external_bank_account.updated")) + @JvmField + val EXTERNAL_PAYMENT_CREATED = EventType(JsonField.of("external_payment.created")) + + @JvmField + val EXTERNAL_PAYMENT_UPDATED = EventType(JsonField.of("external_payment.updated")) + @JvmField val FINANCIAL_ACCOUNT_CREATED = EventType(JsonField.of("financial_account.created")) @@ -418,6 +424,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED, EXTERNAL_BANK_ACCOUNT_CREATED, EXTERNAL_BANK_ACCOUNT_UPDATED, + EXTERNAL_PAYMENT_CREATED, + EXTERNAL_PAYMENT_UPDATED, FINANCIAL_ACCOUNT_CREATED, FINANCIAL_ACCOUNT_UPDATED, PAYMENT_TRANSACTION_CREATED, @@ -454,6 +462,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED, EXTERNAL_BANK_ACCOUNT_CREATED, EXTERNAL_BANK_ACCOUNT_UPDATED, + EXTERNAL_PAYMENT_CREATED, + EXTERNAL_PAYMENT_UPDATED, FINANCIAL_ACCOUNT_CREATED, FINANCIAL_ACCOUNT_UPDATED, PAYMENT_TRANSACTION_CREATED, @@ -495,6 +505,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED -> Value.DISPUTE_EVIDENCE_UPLOAD_FAILED EXTERNAL_BANK_ACCOUNT_CREATED -> Value.EXTERNAL_BANK_ACCOUNT_CREATED EXTERNAL_BANK_ACCOUNT_UPDATED -> Value.EXTERNAL_BANK_ACCOUNT_UPDATED + EXTERNAL_PAYMENT_CREATED -> Value.EXTERNAL_PAYMENT_CREATED + EXTERNAL_PAYMENT_UPDATED -> Value.EXTERNAL_PAYMENT_UPDATED FINANCIAL_ACCOUNT_CREATED -> Value.FINANCIAL_ACCOUNT_CREATED FINANCIAL_ACCOUNT_UPDATED -> Value.FINANCIAL_ACCOUNT_UPDATED PAYMENT_TRANSACTION_CREATED -> Value.PAYMENT_TRANSACTION_CREATED @@ -538,6 +550,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED -> Known.DISPUTE_EVIDENCE_UPLOAD_FAILED EXTERNAL_BANK_ACCOUNT_CREATED -> Known.EXTERNAL_BANK_ACCOUNT_CREATED EXTERNAL_BANK_ACCOUNT_UPDATED -> Known.EXTERNAL_BANK_ACCOUNT_UPDATED + EXTERNAL_PAYMENT_CREATED -> Known.EXTERNAL_PAYMENT_CREATED + EXTERNAL_PAYMENT_UPDATED -> Known.EXTERNAL_PAYMENT_UPDATED FINANCIAL_ACCOUNT_CREATED -> Known.FINANCIAL_ACCOUNT_CREATED FINANCIAL_ACCOUNT_UPDATED -> Known.FINANCIAL_ACCOUNT_UPDATED PAYMENT_TRANSACTION_CREATED -> Known.PAYMENT_TRANSACTION_CREATED diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionUpdateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionUpdateParams.kt index fc33fe5f..da8214fd 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionUpdateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionUpdateParams.kt @@ -445,6 +445,12 @@ constructor( val EXTERNAL_BANK_ACCOUNT_UPDATED = EventType(JsonField.of("external_bank_account.updated")) + @JvmField + val EXTERNAL_PAYMENT_CREATED = EventType(JsonField.of("external_payment.created")) + + @JvmField + val EXTERNAL_PAYMENT_UPDATED = EventType(JsonField.of("external_payment.updated")) + @JvmField val FINANCIAL_ACCOUNT_CREATED = EventType(JsonField.of("financial_account.created")) @@ -510,6 +516,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED, EXTERNAL_BANK_ACCOUNT_CREATED, EXTERNAL_BANK_ACCOUNT_UPDATED, + EXTERNAL_PAYMENT_CREATED, + EXTERNAL_PAYMENT_UPDATED, FINANCIAL_ACCOUNT_CREATED, FINANCIAL_ACCOUNT_UPDATED, PAYMENT_TRANSACTION_CREATED, @@ -546,6 +554,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED, EXTERNAL_BANK_ACCOUNT_CREATED, EXTERNAL_BANK_ACCOUNT_UPDATED, + EXTERNAL_PAYMENT_CREATED, + EXTERNAL_PAYMENT_UPDATED, FINANCIAL_ACCOUNT_CREATED, FINANCIAL_ACCOUNT_UPDATED, PAYMENT_TRANSACTION_CREATED, @@ -587,6 +597,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED -> Value.DISPUTE_EVIDENCE_UPLOAD_FAILED EXTERNAL_BANK_ACCOUNT_CREATED -> Value.EXTERNAL_BANK_ACCOUNT_CREATED EXTERNAL_BANK_ACCOUNT_UPDATED -> Value.EXTERNAL_BANK_ACCOUNT_UPDATED + EXTERNAL_PAYMENT_CREATED -> Value.EXTERNAL_PAYMENT_CREATED + EXTERNAL_PAYMENT_UPDATED -> Value.EXTERNAL_PAYMENT_UPDATED FINANCIAL_ACCOUNT_CREATED -> Value.FINANCIAL_ACCOUNT_CREATED FINANCIAL_ACCOUNT_UPDATED -> Value.FINANCIAL_ACCOUNT_UPDATED PAYMENT_TRANSACTION_CREATED -> Value.PAYMENT_TRANSACTION_CREATED @@ -630,6 +642,8 @@ constructor( DISPUTE_EVIDENCE_UPLOAD_FAILED -> Known.DISPUTE_EVIDENCE_UPLOAD_FAILED EXTERNAL_BANK_ACCOUNT_CREATED -> Known.EXTERNAL_BANK_ACCOUNT_CREATED EXTERNAL_BANK_ACCOUNT_UPDATED -> Known.EXTERNAL_BANK_ACCOUNT_UPDATED + EXTERNAL_PAYMENT_CREATED -> Known.EXTERNAL_PAYMENT_CREATED + EXTERNAL_PAYMENT_UPDATED -> Known.EXTERNAL_PAYMENT_UPDATED FINANCIAL_ACCOUNT_CREATED -> Known.FINANCIAL_ACCOUNT_CREATED FINANCIAL_ACCOUNT_UPDATED -> Known.FINANCIAL_ACCOUNT_UPDATED PAYMENT_TRANSACTION_CREATED -> Known.PAYMENT_TRANSACTION_CREATED diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt new file mode 100644 index 00000000..6353f269 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt @@ -0,0 +1,1129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = ExternalPayment.Builder::class) +@NoAutoDetect +class ExternalPayment +private constructor( + private val token: JsonField, + private val result: JsonField, + private val category: JsonField, + private val status: JsonField, + private val settledAmount: JsonField, + private val pendingAmount: JsonField, + private val currency: JsonField, + private val events: JsonField>, + private val created: JsonField, + private val updated: JsonField, + private val userDefinedId: JsonField, + private val financialAccountToken: JsonField, + private val paymentType: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun token(): String = token.getRequired("token") + + fun result(): TransactionResult = result.getRequired("result") + + fun category(): ExternalPaymentCategory = category.getRequired("category") + + fun status(): TransactionStatus = status.getRequired("status") + + fun settledAmount(): Long = settledAmount.getRequired("settled_amount") + + fun pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + fun currency(): String = currency.getRequired("currency") + + fun events(): List = events.getRequired("events") + + fun created(): OffsetDateTime = created.getRequired("created") + + fun updated(): OffsetDateTime = updated.getRequired("updated") + + fun userDefinedId(): Optional = + Optional.ofNullable(userDefinedId.getNullable("user_defined_id")) + + fun financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + fun paymentType(): ExternalPaymentDirection = paymentType.getRequired("payment_type") + + @JsonProperty("token") @ExcludeMissing fun _token() = token + + @JsonProperty("result") @ExcludeMissing fun _result() = result + + @JsonProperty("category") @ExcludeMissing fun _category() = category + + @JsonProperty("status") @ExcludeMissing fun _status() = status + + @JsonProperty("settled_amount") @ExcludeMissing fun _settledAmount() = settledAmount + + @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount + + @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + + @JsonProperty("events") @ExcludeMissing fun _events() = events + + @JsonProperty("created") @ExcludeMissing fun _created() = created + + @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + + @JsonProperty("user_defined_id") @ExcludeMissing fun _userDefinedId() = userDefinedId + + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken() = financialAccountToken + + @JsonProperty("payment_type") @ExcludeMissing fun _paymentType() = paymentType + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ExternalPayment = apply { + if (!validated) { + token() + result() + category() + status() + settledAmount() + pendingAmount() + currency() + events().forEach { it.validate() } + created() + updated() + userDefinedId() + financialAccountToken() + paymentType() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPayment && + this.token == other.token && + this.result == other.result && + this.category == other.category && + this.status == other.status && + this.settledAmount == other.settledAmount && + this.pendingAmount == other.pendingAmount && + this.currency == other.currency && + this.events == other.events && + this.created == other.created && + this.updated == other.updated && + this.userDefinedId == other.userDefinedId && + this.financialAccountToken == other.financialAccountToken && + this.paymentType == other.paymentType && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + token, + result, + category, + status, + settledAmount, + pendingAmount, + currency, + events, + created, + updated, + userDefinedId, + financialAccountToken, + paymentType, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ExternalPayment{token=$token, result=$result, category=$category, status=$status, settledAmount=$settledAmount, pendingAmount=$pendingAmount, currency=$currency, events=$events, created=$created, updated=$updated, userDefinedId=$userDefinedId, financialAccountToken=$financialAccountToken, paymentType=$paymentType, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var token: JsonField = JsonMissing.of() + private var result: JsonField = JsonMissing.of() + private var category: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var settledAmount: JsonField = JsonMissing.of() + private var pendingAmount: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var events: JsonField> = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var updated: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() + private var financialAccountToken: JsonField = JsonMissing.of() + private var paymentType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPayment: ExternalPayment) = apply { + this.token = externalPayment.token + this.result = externalPayment.result + this.category = externalPayment.category + this.status = externalPayment.status + this.settledAmount = externalPayment.settledAmount + this.pendingAmount = externalPayment.pendingAmount + this.currency = externalPayment.currency + this.events = externalPayment.events + this.created = externalPayment.created + this.updated = externalPayment.updated + this.userDefinedId = externalPayment.userDefinedId + this.financialAccountToken = externalPayment.financialAccountToken + this.paymentType = externalPayment.paymentType + additionalProperties(externalPayment.additionalProperties) + } + + fun token(token: String) = token(JsonField.of(token)) + + @JsonProperty("token") + @ExcludeMissing + fun token(token: JsonField) = apply { this.token = token } + + fun result(result: TransactionResult) = result(JsonField.of(result)) + + @JsonProperty("result") + @ExcludeMissing + fun result(result: JsonField) = apply { this.result = result } + + fun category(category: ExternalPaymentCategory) = category(JsonField.of(category)) + + @JsonProperty("category") + @ExcludeMissing + fun category(category: JsonField) = apply { + this.category = category + } + + fun status(status: TransactionStatus) = status(JsonField.of(status)) + + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + @JsonProperty("settled_amount") + @ExcludeMissing + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + @JsonProperty("pending_amount") + @ExcludeMissing + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + fun currency(currency: String) = currency(JsonField.of(currency)) + + @JsonProperty("currency") + @ExcludeMissing + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun events(events: List) = events(JsonField.of(events)) + + @JsonProperty("events") + @ExcludeMissing + fun events(events: JsonField>) = apply { this.events = events } + + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + @JsonProperty("updated") + @ExcludeMissing + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun userDefinedId(userDefinedId: String) = userDefinedId(JsonField.of(userDefinedId)) + + @JsonProperty("user_defined_id") + @ExcludeMissing + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } + + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + @JsonProperty("financial_account_token") + @ExcludeMissing + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + fun paymentType(paymentType: ExternalPaymentDirection) = + paymentType(JsonField.of(paymentType)) + + @JsonProperty("payment_type") + @ExcludeMissing + fun paymentType(paymentType: JsonField) = apply { + this.paymentType = paymentType + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ExternalPayment = + ExternalPayment( + token, + result, + category, + status, + settledAmount, + pendingAmount, + currency, + events.map { it.toUnmodifiable() }, + created, + updated, + userDefinedId, + financialAccountToken, + paymentType, + additionalProperties.toUnmodifiable(), + ) + } + + class ExternalPaymentCategory + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentCategory && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val EXTERNAL_WIRE = ExternalPaymentCategory(JsonField.of("EXTERNAL_WIRE")) + + @JvmField val EXTERNAL_ACH = ExternalPaymentCategory(JsonField.of("EXTERNAL_ACH")) + + @JvmField val EXTERNAL_CHECK = ExternalPaymentCategory(JsonField.of("EXTERNAL_CHECK")) + + @JvmField + val EXTERNAL_TRANSFER = ExternalPaymentCategory(JsonField.of("EXTERNAL_TRANSFER")) + + @JvmStatic fun of(value: String) = ExternalPaymentCategory(JsonField.of(value)) + } + + enum class Known { + EXTERNAL_WIRE, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + } + + enum class Value { + EXTERNAL_WIRE, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + EXTERNAL_WIRE -> Value.EXTERNAL_WIRE + EXTERNAL_ACH -> Value.EXTERNAL_ACH + EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + EXTERNAL_WIRE -> Known.EXTERNAL_WIRE + EXTERNAL_ACH -> Known.EXTERNAL_ACH + EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER + else -> throw LithicInvalidDataException("Unknown ExternalPaymentCategory: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = ExternalPaymentEvent.Builder::class) + @NoAutoDetect + class ExternalPaymentEvent + private constructor( + private val amount: JsonField, + private val type: JsonField, + private val result: JsonField, + private val detailedResults: JsonField>, + private val created: JsonField, + private val token: JsonField, + private val memo: JsonField, + private val effectiveDate: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun amount(): Long = amount.getRequired("amount") + + fun type(): ExternalPaymentEventType = type.getRequired("type") + + fun result(): TransactionResult = result.getRequired("result") + + fun detailedResults(): List = + detailedResults.getRequired("detailed_results") + + fun created(): OffsetDateTime = created.getRequired("created") + + fun token(): String = token.getRequired("token") + + fun memo(): String = memo.getRequired("memo") + + fun effectiveDate(): LocalDate = effectiveDate.getRequired("effective_date") + + @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("result") @ExcludeMissing fun _result() = result + + @JsonProperty("detailed_results") @ExcludeMissing fun _detailedResults() = detailedResults + + @JsonProperty("created") @ExcludeMissing fun _created() = created + + @JsonProperty("token") @ExcludeMissing fun _token() = token + + @JsonProperty("memo") @ExcludeMissing fun _memo() = memo + + @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ExternalPaymentEvent = apply { + if (!validated) { + amount() + type() + result() + detailedResults() + created() + token() + memo() + effectiveDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentEvent && + this.amount == other.amount && + this.type == other.type && + this.result == other.result && + this.detailedResults == other.detailedResults && + this.created == other.created && + this.token == other.token && + this.memo == other.memo && + this.effectiveDate == other.effectiveDate && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + amount, + type, + result, + detailedResults, + created, + token, + memo, + effectiveDate, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ExternalPaymentEvent{amount=$amount, type=$type, result=$result, detailedResults=$detailedResults, created=$created, token=$token, memo=$memo, effectiveDate=$effectiveDate, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var amount: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var result: JsonField = JsonMissing.of() + private var detailedResults: JsonField> = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var token: JsonField = JsonMissing.of() + private var memo: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentEvent: ExternalPaymentEvent) = apply { + this.amount = externalPaymentEvent.amount + this.type = externalPaymentEvent.type + this.result = externalPaymentEvent.result + this.detailedResults = externalPaymentEvent.detailedResults + this.created = externalPaymentEvent.created + this.token = externalPaymentEvent.token + this.memo = externalPaymentEvent.memo + this.effectiveDate = externalPaymentEvent.effectiveDate + additionalProperties(externalPaymentEvent.additionalProperties) + } + + fun amount(amount: Long) = amount(JsonField.of(amount)) + + @JsonProperty("amount") + @ExcludeMissing + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun type(type: ExternalPaymentEventType) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun result(result: TransactionResult) = result(JsonField.of(result)) + + @JsonProperty("result") + @ExcludeMissing + fun result(result: JsonField) = apply { this.result = result } + + fun detailedResults(detailedResults: List) = + detailedResults(JsonField.of(detailedResults)) + + @JsonProperty("detailed_results") + @ExcludeMissing + fun detailedResults(detailedResults: JsonField>) = apply { + this.detailedResults = detailedResults + } + + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + fun token(token: String) = token(JsonField.of(token)) + + @JsonProperty("token") + @ExcludeMissing + fun token(token: JsonField) = apply { this.token = token } + + fun memo(memo: String) = memo(JsonField.of(memo)) + + @JsonProperty("memo") + @ExcludeMissing + fun memo(memo: JsonField) = apply { this.memo = memo } + + fun effectiveDate(effectiveDate: LocalDate) = effectiveDate(JsonField.of(effectiveDate)) + + @JsonProperty("effective_date") + @ExcludeMissing + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ExternalPaymentEvent = + ExternalPaymentEvent( + amount, + type, + result, + detailedResults.map { it.toUnmodifiable() }, + created, + token, + memo, + effectiveDate, + additionalProperties.toUnmodifiable(), + ) + } + + class DetailedResults + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DetailedResults && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val APPROVED = DetailedResults(JsonField.of("APPROVED")) + + @JvmStatic fun of(value: String) = DetailedResults(JsonField.of(value)) + } + + enum class Known { + APPROVED, + } + + enum class Value { + APPROVED, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + APPROVED -> Value.APPROVED + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + else -> throw LithicInvalidDataException("Unknown DetailedResults: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class TransactionResult + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TransactionResult && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val APPROVED = TransactionResult(JsonField.of("APPROVED")) + + @JvmField val DECLINED = TransactionResult(JsonField.of("DECLINED")) + + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } + + enum class Known { + APPROVED, + DECLINED, + } + + enum class Value { + APPROVED, + DECLINED, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + else -> throw LithicInvalidDataException("Unknown TransactionResult: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class ExternalPaymentEventType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentEventType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField + val EXTERNAL_WIRE_INITIATED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_WIRE_INITIATED")) + + @JvmField + val EXTERNAL_WIRE_CANCELED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_WIRE_CANCELED")) + + @JvmField + val EXTERNAL_WIRE_SETTLED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_WIRE_SETTLED")) + + @JvmField + val EXTERNAL_WIRE_REVERSED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_WIRE_REVERSED")) + + @JvmField + val EXTERNAL_WIRE_RELEASED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_WIRE_RELEASED")) + + @JvmField + val EXTERNAL_ACH_INITIATED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_ACH_INITIATED")) + + @JvmField + val EXTERNAL_ACH_CANCELED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_ACH_CANCELED")) + + @JvmField + val EXTERNAL_ACH_SETTLED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_ACH_SETTLED")) + + @JvmField + val EXTERNAL_ACH_REVERSED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_ACH_REVERSED")) + + @JvmField + val EXTERNAL_ACH_RELEASED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_ACH_RELEASED")) + + @JvmField + val EXTERNAL_TRANSFER_INITIATED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_TRANSFER_INITIATED")) + + @JvmField + val EXTERNAL_TRANSFER_CANCELED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_TRANSFER_CANCELED")) + + @JvmField + val EXTERNAL_TRANSFER_SETTLED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_TRANSFER_SETTLED")) + + @JvmField + val EXTERNAL_TRANSFER_REVERSED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_TRANSFER_REVERSED")) + + @JvmField + val EXTERNAL_TRANSFER_RELEASED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_TRANSFER_RELEASED")) + + @JvmField + val EXTERNAL_CHECK_INITIATED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_CHECK_INITIATED")) + + @JvmField + val EXTERNAL_CHECK_CANCELED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_CHECK_CANCELED")) + + @JvmField + val EXTERNAL_CHECK_SETTLED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_CHECK_SETTLED")) + + @JvmField + val EXTERNAL_CHECK_REVERSED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_CHECK_REVERSED")) + + @JvmField + val EXTERNAL_CHECK_RELEASED = + ExternalPaymentEventType(JsonField.of("EXTERNAL_CHECK_RELEASED")) + + @JvmStatic fun of(value: String) = ExternalPaymentEventType(JsonField.of(value)) + } + + enum class Known { + EXTERNAL_WIRE_INITIATED, + EXTERNAL_WIRE_CANCELED, + EXTERNAL_WIRE_SETTLED, + EXTERNAL_WIRE_REVERSED, + EXTERNAL_WIRE_RELEASED, + EXTERNAL_ACH_INITIATED, + EXTERNAL_ACH_CANCELED, + EXTERNAL_ACH_SETTLED, + EXTERNAL_ACH_REVERSED, + EXTERNAL_ACH_RELEASED, + EXTERNAL_TRANSFER_INITIATED, + EXTERNAL_TRANSFER_CANCELED, + EXTERNAL_TRANSFER_SETTLED, + EXTERNAL_TRANSFER_REVERSED, + EXTERNAL_TRANSFER_RELEASED, + EXTERNAL_CHECK_INITIATED, + EXTERNAL_CHECK_CANCELED, + EXTERNAL_CHECK_SETTLED, + EXTERNAL_CHECK_REVERSED, + EXTERNAL_CHECK_RELEASED, + } + + enum class Value { + EXTERNAL_WIRE_INITIATED, + EXTERNAL_WIRE_CANCELED, + EXTERNAL_WIRE_SETTLED, + EXTERNAL_WIRE_REVERSED, + EXTERNAL_WIRE_RELEASED, + EXTERNAL_ACH_INITIATED, + EXTERNAL_ACH_CANCELED, + EXTERNAL_ACH_SETTLED, + EXTERNAL_ACH_REVERSED, + EXTERNAL_ACH_RELEASED, + EXTERNAL_TRANSFER_INITIATED, + EXTERNAL_TRANSFER_CANCELED, + EXTERNAL_TRANSFER_SETTLED, + EXTERNAL_TRANSFER_REVERSED, + EXTERNAL_TRANSFER_RELEASED, + EXTERNAL_CHECK_INITIATED, + EXTERNAL_CHECK_CANCELED, + EXTERNAL_CHECK_SETTLED, + EXTERNAL_CHECK_REVERSED, + EXTERNAL_CHECK_RELEASED, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + EXTERNAL_WIRE_INITIATED -> Value.EXTERNAL_WIRE_INITIATED + EXTERNAL_WIRE_CANCELED -> Value.EXTERNAL_WIRE_CANCELED + EXTERNAL_WIRE_SETTLED -> Value.EXTERNAL_WIRE_SETTLED + EXTERNAL_WIRE_REVERSED -> Value.EXTERNAL_WIRE_REVERSED + EXTERNAL_WIRE_RELEASED -> Value.EXTERNAL_WIRE_RELEASED + EXTERNAL_ACH_INITIATED -> Value.EXTERNAL_ACH_INITIATED + EXTERNAL_ACH_CANCELED -> Value.EXTERNAL_ACH_CANCELED + EXTERNAL_ACH_SETTLED -> Value.EXTERNAL_ACH_SETTLED + EXTERNAL_ACH_REVERSED -> Value.EXTERNAL_ACH_REVERSED + EXTERNAL_ACH_RELEASED -> Value.EXTERNAL_ACH_RELEASED + EXTERNAL_TRANSFER_INITIATED -> Value.EXTERNAL_TRANSFER_INITIATED + EXTERNAL_TRANSFER_CANCELED -> Value.EXTERNAL_TRANSFER_CANCELED + EXTERNAL_TRANSFER_SETTLED -> Value.EXTERNAL_TRANSFER_SETTLED + EXTERNAL_TRANSFER_REVERSED -> Value.EXTERNAL_TRANSFER_REVERSED + EXTERNAL_TRANSFER_RELEASED -> Value.EXTERNAL_TRANSFER_RELEASED + EXTERNAL_CHECK_INITIATED -> Value.EXTERNAL_CHECK_INITIATED + EXTERNAL_CHECK_CANCELED -> Value.EXTERNAL_CHECK_CANCELED + EXTERNAL_CHECK_SETTLED -> Value.EXTERNAL_CHECK_SETTLED + EXTERNAL_CHECK_REVERSED -> Value.EXTERNAL_CHECK_REVERSED + EXTERNAL_CHECK_RELEASED -> Value.EXTERNAL_CHECK_RELEASED + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + EXTERNAL_WIRE_INITIATED -> Known.EXTERNAL_WIRE_INITIATED + EXTERNAL_WIRE_CANCELED -> Known.EXTERNAL_WIRE_CANCELED + EXTERNAL_WIRE_SETTLED -> Known.EXTERNAL_WIRE_SETTLED + EXTERNAL_WIRE_REVERSED -> Known.EXTERNAL_WIRE_REVERSED + EXTERNAL_WIRE_RELEASED -> Known.EXTERNAL_WIRE_RELEASED + EXTERNAL_ACH_INITIATED -> Known.EXTERNAL_ACH_INITIATED + EXTERNAL_ACH_CANCELED -> Known.EXTERNAL_ACH_CANCELED + EXTERNAL_ACH_SETTLED -> Known.EXTERNAL_ACH_SETTLED + EXTERNAL_ACH_REVERSED -> Known.EXTERNAL_ACH_REVERSED + EXTERNAL_ACH_RELEASED -> Known.EXTERNAL_ACH_RELEASED + EXTERNAL_TRANSFER_INITIATED -> Known.EXTERNAL_TRANSFER_INITIATED + EXTERNAL_TRANSFER_CANCELED -> Known.EXTERNAL_TRANSFER_CANCELED + EXTERNAL_TRANSFER_SETTLED -> Known.EXTERNAL_TRANSFER_SETTLED + EXTERNAL_TRANSFER_REVERSED -> Known.EXTERNAL_TRANSFER_REVERSED + EXTERNAL_TRANSFER_RELEASED -> Known.EXTERNAL_TRANSFER_RELEASED + EXTERNAL_CHECK_INITIATED -> Known.EXTERNAL_CHECK_INITIATED + EXTERNAL_CHECK_CANCELED -> Known.EXTERNAL_CHECK_CANCELED + EXTERNAL_CHECK_SETTLED -> Known.EXTERNAL_CHECK_SETTLED + EXTERNAL_CHECK_REVERSED -> Known.EXTERNAL_CHECK_REVERSED + EXTERNAL_CHECK_RELEASED -> Known.EXTERNAL_CHECK_RELEASED + else -> + throw LithicInvalidDataException("Unknown ExternalPaymentEventType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + + class ExternalPaymentDirection + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentDirection && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val DEPOSIT = ExternalPaymentDirection(JsonField.of("DEPOSIT")) + + @JvmField val WITHDRAWAL = ExternalPaymentDirection(JsonField.of("WITHDRAWAL")) + + @JvmStatic fun of(value: String) = ExternalPaymentDirection(JsonField.of(value)) + } + + enum class Known { + DEPOSIT, + WITHDRAWAL, + } + + enum class Value { + DEPOSIT, + WITHDRAWAL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + DEPOSIT -> Value.DEPOSIT + WITHDRAWAL -> Value.WITHDRAWAL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + DEPOSIT -> Known.DEPOSIT + WITHDRAWAL -> Known.WITHDRAWAL + else -> throw LithicInvalidDataException("Unknown ExternalPaymentDirection: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class TransactionResult + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TransactionResult && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val APPROVED = TransactionResult(JsonField.of("APPROVED")) + + @JvmField val DECLINED = TransactionResult(JsonField.of("DECLINED")) + + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } + + enum class Known { + APPROVED, + DECLINED, + } + + enum class Value { + APPROVED, + DECLINED, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + else -> throw LithicInvalidDataException("Unknown TransactionResult: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class TransactionStatus + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TransactionStatus && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PENDING = TransactionStatus(JsonField.of("PENDING")) + + @JvmField val SETTLED = TransactionStatus(JsonField.of("SETTLED")) + + @JvmField val DECLINED = TransactionStatus(JsonField.of("DECLINED")) + + @JvmField val REVERSED = TransactionStatus(JsonField.of("REVERSED")) + + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) + } + + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + } + + enum class Value { + PENDING, + SETTLED, + DECLINED, + REVERSED, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + SETTLED -> Value.SETTLED + DECLINED -> Value.DECLINED + REVERSED -> Value.REVERSED + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + SETTLED -> Known.SETTLED + DECLINED -> Known.DECLINED + REVERSED -> Known.REVERSED + else -> throw LithicInvalidDataException("Unknown TransactionStatus: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCancelParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCancelParams.kt new file mode 100644 index 00000000..a0884869 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCancelParams.kt @@ -0,0 +1,284 @@ +// 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.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.models.* +import java.time.LocalDate +import java.util.Objects +import java.util.Optional + +class ExternalPaymentCancelParams +constructor( + private val externalPaymentToken: String, + private val effectiveDate: LocalDate, + private val memo: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun externalPaymentToken(): String = externalPaymentToken + + fun effectiveDate(): LocalDate = effectiveDate + + fun memo(): Optional = Optional.ofNullable(memo) + + @JvmSynthetic + internal fun getBody(): ExternalPaymentCancelBody { + return ExternalPaymentCancelBody( + effectiveDate, + memo, + additionalBodyProperties, + ) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> externalPaymentToken + else -> "" + } + } + + @JsonDeserialize(builder = ExternalPaymentCancelBody.Builder::class) + @NoAutoDetect + class ExternalPaymentCancelBody + internal constructor( + private val effectiveDate: LocalDate?, + private val memo: String?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + @JsonProperty("effective_date") fun effectiveDate(): LocalDate? = effectiveDate + + @JsonProperty("memo") fun memo(): String? = memo + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentCancelBody && + this.effectiveDate == other.effectiveDate && + this.memo == other.memo && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + effectiveDate, + memo, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ExternalPaymentCancelBody{effectiveDate=$effectiveDate, memo=$memo, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var effectiveDate: LocalDate? = null + private var memo: String? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentCancelBody: ExternalPaymentCancelBody) = apply { + this.effectiveDate = externalPaymentCancelBody.effectiveDate + this.memo = externalPaymentCancelBody.memo + additionalProperties(externalPaymentCancelBody.additionalProperties) + } + + @JsonProperty("effective_date") + fun effectiveDate(effectiveDate: LocalDate) = apply { + this.effectiveDate = effectiveDate + } + + @JsonProperty("memo") fun memo(memo: String) = apply { this.memo = memo } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ExternalPaymentCancelBody = + ExternalPaymentCancelBody( + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + memo, + additionalProperties.toUnmodifiable(), + ) + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentCancelParams && + this.externalPaymentToken == other.externalPaymentToken && + this.effectiveDate == other.effectiveDate && + this.memo == other.memo && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + externalPaymentToken, + effectiveDate, + memo, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "ExternalPaymentCancelParams{externalPaymentToken=$externalPaymentToken, effectiveDate=$effectiveDate, memo=$memo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var externalPaymentToken: String? = null + private var effectiveDate: LocalDate? = null + private var memo: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentCancelParams: ExternalPaymentCancelParams) = apply { + this.externalPaymentToken = externalPaymentCancelParams.externalPaymentToken + this.effectiveDate = externalPaymentCancelParams.effectiveDate + this.memo = externalPaymentCancelParams.memo + additionalQueryParams(externalPaymentCancelParams.additionalQueryParams) + additionalHeaders(externalPaymentCancelParams.additionalHeaders) + additionalBodyProperties(externalPaymentCancelParams.additionalBodyProperties) + } + + fun externalPaymentToken(externalPaymentToken: String) = apply { + this.externalPaymentToken = externalPaymentToken + } + + fun effectiveDate(effectiveDate: LocalDate) = apply { this.effectiveDate = effectiveDate } + + fun memo(memo: String) = apply { this.memo = memo } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ExternalPaymentCancelParams = + ExternalPaymentCancelParams( + checkNotNull(externalPaymentToken) { + "`externalPaymentToken` is required but was not set" + }, + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + memo, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreateParams.kt new file mode 100644 index 00000000..1955acec --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreateParams.kt @@ -0,0 +1,621 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import com.lithic.api.models.* +import java.time.LocalDate +import java.util.Objects +import java.util.Optional + +class ExternalPaymentCreateParams +constructor( + private val amount: Long, + private val category: ExternalPaymentCategory, + private val effectiveDate: LocalDate, + private val financialAccountToken: String, + private val paymentType: ExternalPaymentDirection, + private val token: String?, + private val memo: String?, + private val progressTo: ExternalPaymentProgressTo?, + private val userDefinedId: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun amount(): Long = amount + + fun category(): ExternalPaymentCategory = category + + fun effectiveDate(): LocalDate = effectiveDate + + fun financialAccountToken(): String = financialAccountToken + + fun paymentType(): ExternalPaymentDirection = paymentType + + fun token(): Optional = Optional.ofNullable(token) + + fun memo(): Optional = Optional.ofNullable(memo) + + fun progressTo(): Optional = Optional.ofNullable(progressTo) + + fun userDefinedId(): Optional = Optional.ofNullable(userDefinedId) + + @JvmSynthetic + internal fun getBody(): ExternalPaymentCreateBody { + return ExternalPaymentCreateBody( + amount, + category, + effectiveDate, + financialAccountToken, + paymentType, + token, + memo, + progressTo, + userDefinedId, + additionalBodyProperties, + ) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + @JsonDeserialize(builder = ExternalPaymentCreateBody.Builder::class) + @NoAutoDetect + class ExternalPaymentCreateBody + internal constructor( + private val amount: Long?, + private val category: ExternalPaymentCategory?, + private val effectiveDate: LocalDate?, + private val financialAccountToken: String?, + private val paymentType: ExternalPaymentDirection?, + private val token: String?, + private val memo: String?, + private val progressTo: ExternalPaymentProgressTo?, + private val userDefinedId: String?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + @JsonProperty("amount") fun amount(): Long? = amount + + @JsonProperty("category") fun category(): ExternalPaymentCategory? = category + + @JsonProperty("effective_date") fun effectiveDate(): LocalDate? = effectiveDate + + @JsonProperty("financial_account_token") + fun financialAccountToken(): String? = financialAccountToken + + @JsonProperty("payment_type") fun paymentType(): ExternalPaymentDirection? = paymentType + + @JsonProperty("token") fun token(): String? = token + + @JsonProperty("memo") fun memo(): String? = memo + + @JsonProperty("progress_to") fun progressTo(): ExternalPaymentProgressTo? = progressTo + + @JsonProperty("user_defined_id") fun userDefinedId(): String? = userDefinedId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentCreateBody && + this.amount == other.amount && + this.category == other.category && + this.effectiveDate == other.effectiveDate && + this.financialAccountToken == other.financialAccountToken && + this.paymentType == other.paymentType && + this.token == other.token && + this.memo == other.memo && + this.progressTo == other.progressTo && + this.userDefinedId == other.userDefinedId && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + amount, + category, + effectiveDate, + financialAccountToken, + paymentType, + token, + memo, + progressTo, + userDefinedId, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ExternalPaymentCreateBody{amount=$amount, category=$category, effectiveDate=$effectiveDate, financialAccountToken=$financialAccountToken, paymentType=$paymentType, token=$token, memo=$memo, progressTo=$progressTo, userDefinedId=$userDefinedId, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var amount: Long? = null + private var category: ExternalPaymentCategory? = null + private var effectiveDate: LocalDate? = null + private var financialAccountToken: String? = null + private var paymentType: ExternalPaymentDirection? = null + private var token: String? = null + private var memo: String? = null + private var progressTo: ExternalPaymentProgressTo? = null + private var userDefinedId: String? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentCreateBody: ExternalPaymentCreateBody) = apply { + this.amount = externalPaymentCreateBody.amount + this.category = externalPaymentCreateBody.category + this.effectiveDate = externalPaymentCreateBody.effectiveDate + this.financialAccountToken = externalPaymentCreateBody.financialAccountToken + this.paymentType = externalPaymentCreateBody.paymentType + this.token = externalPaymentCreateBody.token + this.memo = externalPaymentCreateBody.memo + this.progressTo = externalPaymentCreateBody.progressTo + this.userDefinedId = externalPaymentCreateBody.userDefinedId + additionalProperties(externalPaymentCreateBody.additionalProperties) + } + + @JsonProperty("amount") fun amount(amount: Long) = apply { this.amount = amount } + + @JsonProperty("category") + fun category(category: ExternalPaymentCategory) = apply { this.category = category } + + @JsonProperty("effective_date") + fun effectiveDate(effectiveDate: LocalDate) = apply { + this.effectiveDate = effectiveDate + } + + @JsonProperty("financial_account_token") + fun financialAccountToken(financialAccountToken: String) = apply { + this.financialAccountToken = financialAccountToken + } + + @JsonProperty("payment_type") + fun paymentType(paymentType: ExternalPaymentDirection) = apply { + this.paymentType = paymentType + } + + @JsonProperty("token") fun token(token: String) = apply { this.token = token } + + @JsonProperty("memo") fun memo(memo: String) = apply { this.memo = memo } + + @JsonProperty("progress_to") + fun progressTo(progressTo: ExternalPaymentProgressTo) = apply { + this.progressTo = progressTo + } + + @JsonProperty("user_defined_id") + fun userDefinedId(userDefinedId: String) = apply { this.userDefinedId = userDefinedId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ExternalPaymentCreateBody = + ExternalPaymentCreateBody( + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(category) { "`category` is required but was not set" }, + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + checkNotNull(paymentType) { "`paymentType` is required but was not set" }, + token, + memo, + progressTo, + userDefinedId, + additionalProperties.toUnmodifiable(), + ) + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentCreateParams && + this.amount == other.amount && + this.category == other.category && + this.effectiveDate == other.effectiveDate && + this.financialAccountToken == other.financialAccountToken && + this.paymentType == other.paymentType && + this.token == other.token && + this.memo == other.memo && + this.progressTo == other.progressTo && + this.userDefinedId == other.userDefinedId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + amount, + category, + effectiveDate, + financialAccountToken, + paymentType, + token, + memo, + progressTo, + userDefinedId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "ExternalPaymentCreateParams{amount=$amount, category=$category, effectiveDate=$effectiveDate, financialAccountToken=$financialAccountToken, paymentType=$paymentType, token=$token, memo=$memo, progressTo=$progressTo, userDefinedId=$userDefinedId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var amount: Long? = null + private var category: ExternalPaymentCategory? = null + private var effectiveDate: LocalDate? = null + private var financialAccountToken: String? = null + private var paymentType: ExternalPaymentDirection? = null + private var token: String? = null + private var memo: String? = null + private var progressTo: ExternalPaymentProgressTo? = null + private var userDefinedId: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentCreateParams: ExternalPaymentCreateParams) = apply { + this.amount = externalPaymentCreateParams.amount + this.category = externalPaymentCreateParams.category + this.effectiveDate = externalPaymentCreateParams.effectiveDate + this.financialAccountToken = externalPaymentCreateParams.financialAccountToken + this.paymentType = externalPaymentCreateParams.paymentType + this.token = externalPaymentCreateParams.token + this.memo = externalPaymentCreateParams.memo + this.progressTo = externalPaymentCreateParams.progressTo + this.userDefinedId = externalPaymentCreateParams.userDefinedId + additionalQueryParams(externalPaymentCreateParams.additionalQueryParams) + additionalHeaders(externalPaymentCreateParams.additionalHeaders) + additionalBodyProperties(externalPaymentCreateParams.additionalBodyProperties) + } + + fun amount(amount: Long) = apply { this.amount = amount } + + fun category(category: ExternalPaymentCategory) = apply { this.category = category } + + fun effectiveDate(effectiveDate: LocalDate) = apply { this.effectiveDate = effectiveDate } + + fun financialAccountToken(financialAccountToken: String) = apply { + this.financialAccountToken = financialAccountToken + } + + fun paymentType(paymentType: ExternalPaymentDirection) = apply { + this.paymentType = paymentType + } + + fun token(token: String) = apply { this.token = token } + + fun memo(memo: String) = apply { this.memo = memo } + + fun progressTo(progressTo: ExternalPaymentProgressTo) = apply { + this.progressTo = progressTo + } + + fun userDefinedId(userDefinedId: String) = apply { this.userDefinedId = userDefinedId } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ExternalPaymentCreateParams = + ExternalPaymentCreateParams( + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(category) { "`category` is required but was not set" }, + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + checkNotNull(paymentType) { "`paymentType` is required but was not set" }, + token, + memo, + progressTo, + userDefinedId, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } + + class ExternalPaymentCategory + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentCategory && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val EXTERNAL_WIRE = ExternalPaymentCategory(JsonField.of("EXTERNAL_WIRE")) + + @JvmField val EXTERNAL_ACH = ExternalPaymentCategory(JsonField.of("EXTERNAL_ACH")) + + @JvmField val EXTERNAL_CHECK = ExternalPaymentCategory(JsonField.of("EXTERNAL_CHECK")) + + @JvmField + val EXTERNAL_TRANSFER = ExternalPaymentCategory(JsonField.of("EXTERNAL_TRANSFER")) + + @JvmStatic fun of(value: String) = ExternalPaymentCategory(JsonField.of(value)) + } + + enum class Known { + EXTERNAL_WIRE, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + } + + enum class Value { + EXTERNAL_WIRE, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + EXTERNAL_WIRE -> Value.EXTERNAL_WIRE + EXTERNAL_ACH -> Value.EXTERNAL_ACH + EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + EXTERNAL_WIRE -> Known.EXTERNAL_WIRE + EXTERNAL_ACH -> Known.EXTERNAL_ACH + EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER + else -> throw LithicInvalidDataException("Unknown ExternalPaymentCategory: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class ExternalPaymentDirection + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentDirection && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val DEPOSIT = ExternalPaymentDirection(JsonField.of("DEPOSIT")) + + @JvmField val WITHDRAWAL = ExternalPaymentDirection(JsonField.of("WITHDRAWAL")) + + @JvmStatic fun of(value: String) = ExternalPaymentDirection(JsonField.of(value)) + } + + enum class Known { + DEPOSIT, + WITHDRAWAL, + } + + enum class Value { + DEPOSIT, + WITHDRAWAL, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + DEPOSIT -> Value.DEPOSIT + WITHDRAWAL -> Value.WITHDRAWAL + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + DEPOSIT -> Known.DEPOSIT + WITHDRAWAL -> Known.WITHDRAWAL + else -> throw LithicInvalidDataException("Unknown ExternalPaymentDirection: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class ExternalPaymentProgressTo + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentProgressTo && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SETTLED = ExternalPaymentProgressTo(JsonField.of("SETTLED")) + + @JvmField val RELEASED = ExternalPaymentProgressTo(JsonField.of("RELEASED")) + + @JvmStatic fun of(value: String) = ExternalPaymentProgressTo(JsonField.of(value)) + } + + enum class Known { + SETTLED, + RELEASED, + } + + enum class Value { + SETTLED, + RELEASED, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SETTLED -> Value.SETTLED + RELEASED -> Value.RELEASED + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SETTLED -> Known.SETTLED + RELEASED -> Known.RELEASED + else -> + throw LithicInvalidDataException("Unknown ExternalPaymentProgressTo: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentListPage.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentListPage.kt new file mode 100644 index 00000000..d9bafb33 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentListPage.kt @@ -0,0 +1,223 @@ +// 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.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.services.blocking.ExternalPaymentService +import java.util.Objects +import java.util.Optional +import java.util.stream.Stream +import java.util.stream.StreamSupport + +class ExternalPaymentListPage +private constructor( + private val externalPaymentsService: ExternalPaymentService, + private val params: ExternalPaymentListParams, + private val response: Response, +) { + + fun response(): Response = response + + fun data(): List = response().data() + + fun hasMore(): Boolean = response().hasMore() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentListPage && + this.externalPaymentsService == other.externalPaymentsService && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + externalPaymentsService, + params, + response, + ) + } + + override fun toString() = + "ExternalPaymentListPage{externalPaymentsService=$externalPaymentsService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return !data().isEmpty() + } + + fun getNextPageParams(): Optional { + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ExternalPaymentListParams.builder() + .from(params) + .endingBefore(data().first().token()) + .build() + ) + } else { + Optional.of( + ExternalPaymentListParams.builder() + .from(params) + .startingAfter(data().last().token()) + .build() + ) + } + } + + fun getNextPage(): Optional { + return getNextPageParams().map { externalPaymentsService.list(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + @JvmStatic + fun of( + externalPaymentsService: ExternalPaymentService, + params: ExternalPaymentListParams, + response: Response + ) = + ExternalPaymentListPage( + externalPaymentsService, + params, + response, + ) + } + + @JsonDeserialize(builder = Response.Builder::class) + @NoAutoDetect + class Response + constructor( + private val data: JsonField>, + private val hasMore: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun data(): List = data.getNullable("data") ?: listOf() + + fun hasMore(): Boolean = hasMore.getRequired("has_more") + + @JsonProperty("data") + fun _data(): Optional>> = Optional.ofNullable(data) + + @JsonProperty("has_more") + fun _hasMore(): Optional> = Optional.ofNullable(hasMore) + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Response = apply { + if (!validated) { + data().map { it.validate() } + hasMore() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Response && + this.data == other.data && + this.hasMore == other.hasMore && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + return Objects.hash( + data, + hasMore, + additionalProperties, + ) + } + + override fun toString() = + "ExternalPaymentListPage.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(page: Response) = apply { + this.data = page.data + this.hasMore = page.hasMore + this.additionalProperties.putAll(page.additionalProperties) + } + + fun data(data: List) = data(JsonField.of(data)) + + @JsonProperty("data") + fun data(data: JsonField>) = apply { this.data = data } + + fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) + + @JsonProperty("has_more") + fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun build() = + Response( + data, + hasMore, + additionalProperties.toUnmodifiable(), + ) + } + } + + class AutoPager + constructor( + private val firstPage: ExternalPaymentListPage, + ) : Iterable { + + override fun iterator(): Iterator = iterator { + var page = firstPage + var index = 0 + while (true) { + while (index < page.data().size) { + yield(page.data()[index++]) + } + page = page.getNextPage().orElse(null) ?: break + index = 0 + } + } + + fun stream(): Stream { + return StreamSupport.stream(spliterator(), false) + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentListPageAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentListPageAsync.kt new file mode 100644 index 00000000..7316807e --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentListPageAsync.kt @@ -0,0 +1,236 @@ +// 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.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.services.async.ExternalPaymentServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.function.Predicate + +class ExternalPaymentListPageAsync +private constructor( + private val externalPaymentsService: ExternalPaymentServiceAsync, + private val params: ExternalPaymentListParams, + private val response: Response, +) { + + fun response(): Response = response + + fun data(): List = response().data() + + fun hasMore(): Boolean = response().hasMore() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentListPageAsync && + this.externalPaymentsService == other.externalPaymentsService && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + externalPaymentsService, + params, + response, + ) + } + + override fun toString() = + "ExternalPaymentListPageAsync{externalPaymentsService=$externalPaymentsService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return !data().isEmpty() + } + + fun getNextPageParams(): Optional { + if (!hasNextPage()) { + return Optional.empty() + } + + return if (params.endingBefore().isPresent) { + Optional.of( + ExternalPaymentListParams.builder() + .from(params) + .endingBefore(data().first().token()) + .build() + ) + } else { + Optional.of( + ExternalPaymentListParams.builder() + .from(params) + .startingAfter(data().last().token()) + .build() + ) + } + } + + fun getNextPage(): CompletableFuture> { + return getNextPageParams() + .map { externalPaymentsService.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + @JvmStatic + fun of( + externalPaymentsService: ExternalPaymentServiceAsync, + params: ExternalPaymentListParams, + response: Response + ) = + ExternalPaymentListPageAsync( + externalPaymentsService, + params, + response, + ) + } + + @JsonDeserialize(builder = Response.Builder::class) + @NoAutoDetect + class Response + constructor( + private val data: JsonField>, + private val hasMore: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun data(): List = data.getNullable("data") ?: listOf() + + fun hasMore(): Boolean = hasMore.getRequired("has_more") + + @JsonProperty("data") + fun _data(): Optional>> = Optional.ofNullable(data) + + @JsonProperty("has_more") + fun _hasMore(): Optional> = Optional.ofNullable(hasMore) + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Response = apply { + if (!validated) { + data().map { it.validate() } + hasMore() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Response && + this.data == other.data && + this.hasMore == other.hasMore && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + return Objects.hash( + data, + hasMore, + additionalProperties, + ) + } + + override fun toString() = + "ExternalPaymentListPageAsync.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(page: Response) = apply { + this.data = page.data + this.hasMore = page.hasMore + this.additionalProperties.putAll(page.additionalProperties) + } + + fun data(data: List) = data(JsonField.of(data)) + + @JsonProperty("data") + fun data(data: JsonField>) = apply { this.data = data } + + fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) + + @JsonProperty("has_more") + fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun build() = + Response( + data, + hasMore, + additionalProperties.toUnmodifiable(), + ) + } + } + + class AutoPager + constructor( + private val firstPage: ExternalPaymentListPageAsync, + ) { + + fun forEach( + action: Predicate, + executor: Executor + ): CompletableFuture { + fun CompletableFuture>.forEach( + action: (ExternalPayment) -> Boolean, + executor: Executor + ): CompletableFuture = + thenComposeAsync( + { page -> + page + .filter { it.data().all(action) } + .map { it.getNextPage().forEach(action, executor) } + .orElseGet { CompletableFuture.completedFuture(null) } + }, + executor + ) + return CompletableFuture.completedFuture(Optional.of(firstPage)) + .forEach(action::test, executor) + } + + fun toList(executor: Executor): CompletableFuture> { + val values = mutableListOf() + return forEach(values::add, executor).thenApply { values } + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentListParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentListParams.kt new file mode 100644 index 00000000..a36aca71 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentListParams.kt @@ -0,0 +1,449 @@ +// 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.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import com.lithic.api.models.* +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional + +class ExternalPaymentListParams +constructor( + private val begin: OffsetDateTime?, + private val category: ExternalPaymentCategory?, + private val end: OffsetDateTime?, + private val endingBefore: String?, + private val financialAccountToken: String?, + private val pageSize: Long?, + private val result: TransactionResult?, + private val startingAfter: String?, + private val status: TransactionStatus?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun begin(): Optional = Optional.ofNullable(begin) + + fun category(): Optional = Optional.ofNullable(category) + + fun end(): Optional = Optional.ofNullable(end) + + fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + + fun financialAccountToken(): Optional = Optional.ofNullable(financialAccountToken) + + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + fun result(): Optional = Optional.ofNullable(result) + + fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + + fun status(): Optional = Optional.ofNullable(status) + + @JvmSynthetic + internal fun getQueryParams(): Map> { + val params = mutableMapOf>() + this.begin?.let { + params.put("begin", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))) + } + this.category?.let { params.put("category", listOf(it.toString())) } + this.end?.let { + params.put("end", listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it))) + } + this.endingBefore?.let { params.put("ending_before", listOf(it.toString())) } + this.financialAccountToken?.let { + params.put("financial_account_token", listOf(it.toString())) + } + this.pageSize?.let { params.put("page_size", listOf(it.toString())) } + this.result?.let { params.put("result", listOf(it.toString())) } + this.startingAfter?.let { params.put("starting_after", listOf(it.toString())) } + this.status?.let { params.put("status", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() + } + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentListParams && + this.begin == other.begin && + this.category == other.category && + this.end == other.end && + this.endingBefore == other.endingBefore && + this.financialAccountToken == other.financialAccountToken && + this.pageSize == other.pageSize && + this.result == other.result && + this.startingAfter == other.startingAfter && + this.status == other.status && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders + } + + override fun hashCode(): Int { + return Objects.hash( + begin, + category, + end, + endingBefore, + financialAccountToken, + pageSize, + result, + startingAfter, + status, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "ExternalPaymentListParams{begin=$begin, category=$category, end=$end, endingBefore=$endingBefore, financialAccountToken=$financialAccountToken, pageSize=$pageSize, result=$result, startingAfter=$startingAfter, status=$status, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var begin: OffsetDateTime? = null + private var category: ExternalPaymentCategory? = null + private var end: OffsetDateTime? = null + private var endingBefore: String? = null + private var financialAccountToken: String? = null + private var pageSize: Long? = null + private var result: TransactionResult? = null + private var startingAfter: String? = null + private var status: TransactionStatus? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentListParams: ExternalPaymentListParams) = apply { + this.begin = externalPaymentListParams.begin + this.category = externalPaymentListParams.category + this.end = externalPaymentListParams.end + this.endingBefore = externalPaymentListParams.endingBefore + this.financialAccountToken = externalPaymentListParams.financialAccountToken + this.pageSize = externalPaymentListParams.pageSize + this.result = externalPaymentListParams.result + this.startingAfter = externalPaymentListParams.startingAfter + this.status = externalPaymentListParams.status + additionalQueryParams(externalPaymentListParams.additionalQueryParams) + additionalHeaders(externalPaymentListParams.additionalHeaders) + } + + /** + * 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 } + + /** External Payment category to be returned. */ + fun category(category: ExternalPaymentCategory) = apply { this.category = category } + + /** + * 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 } + + /** + * A cursor representing an item's token before which a page of results should end. Used to + * retrieve the previous page of results before this item. + */ + fun endingBefore(endingBefore: String) = apply { this.endingBefore = endingBefore } + + /** + * Globally unique identifier for the financial account or card that will send the funds. + * Accepted type dependent on the program's use case. + */ + fun financialAccountToken(financialAccountToken: String) = apply { + this.financialAccountToken = financialAccountToken + } + + /** Page size (for pagination). */ + fun pageSize(pageSize: Long) = apply { this.pageSize = pageSize } + + /** External Payment result to be returned. */ + fun result(result: TransactionResult) = apply { this.result = result } + + /** + * A cursor representing an item's token after which a page of results should begin. Used to + * retrieve the next page of results after this item. + */ + fun startingAfter(startingAfter: String) = apply { this.startingAfter = startingAfter } + + /** Book transfer status to be returned. */ + fun status(status: TransactionStatus) = apply { this.status = status } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun build(): ExternalPaymentListParams = + ExternalPaymentListParams( + begin, + category, + end, + endingBefore, + financialAccountToken, + pageSize, + result, + startingAfter, + status, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } + + class ExternalPaymentCategory + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentCategory && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val EXTERNAL_WIRE = ExternalPaymentCategory(JsonField.of("EXTERNAL_WIRE")) + + @JvmField val EXTERNAL_ACH = ExternalPaymentCategory(JsonField.of("EXTERNAL_ACH")) + + @JvmField val EXTERNAL_CHECK = ExternalPaymentCategory(JsonField.of("EXTERNAL_CHECK")) + + @JvmField + val EXTERNAL_TRANSFER = ExternalPaymentCategory(JsonField.of("EXTERNAL_TRANSFER")) + + @JvmStatic fun of(value: String) = ExternalPaymentCategory(JsonField.of(value)) + } + + enum class Known { + EXTERNAL_WIRE, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + } + + enum class Value { + EXTERNAL_WIRE, + EXTERNAL_ACH, + EXTERNAL_CHECK, + EXTERNAL_TRANSFER, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + EXTERNAL_WIRE -> Value.EXTERNAL_WIRE + EXTERNAL_ACH -> Value.EXTERNAL_ACH + EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + EXTERNAL_WIRE -> Known.EXTERNAL_WIRE + EXTERNAL_ACH -> Known.EXTERNAL_ACH + EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER + else -> throw LithicInvalidDataException("Unknown ExternalPaymentCategory: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class TransactionResult + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TransactionResult && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val APPROVED = TransactionResult(JsonField.of("APPROVED")) + + @JvmField val DECLINED = TransactionResult(JsonField.of("DECLINED")) + + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } + + enum class Known { + APPROVED, + DECLINED, + } + + enum class Value { + APPROVED, + DECLINED, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + else -> throw LithicInvalidDataException("Unknown TransactionResult: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class TransactionStatus + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TransactionStatus && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PENDING = TransactionStatus(JsonField.of("PENDING")) + + @JvmField val SETTLED = TransactionStatus(JsonField.of("SETTLED")) + + @JvmField val DECLINED = TransactionStatus(JsonField.of("DECLINED")) + + @JvmField val REVERSED = TransactionStatus(JsonField.of("REVERSED")) + + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) + } + + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + } + + enum class Value { + PENDING, + SETTLED, + DECLINED, + REVERSED, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + SETTLED -> Value.SETTLED + DECLINED -> Value.DECLINED + REVERSED -> Value.REVERSED + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + SETTLED -> Known.SETTLED + DECLINED -> Known.DECLINED + REVERSED -> Known.REVERSED + else -> throw LithicInvalidDataException("Unknown TransactionStatus: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentReleaseParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentReleaseParams.kt new file mode 100644 index 00000000..319e9d7d --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentReleaseParams.kt @@ -0,0 +1,284 @@ +// 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.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.models.* +import java.time.LocalDate +import java.util.Objects +import java.util.Optional + +class ExternalPaymentReleaseParams +constructor( + private val externalPaymentToken: String, + private val effectiveDate: LocalDate, + private val memo: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun externalPaymentToken(): String = externalPaymentToken + + fun effectiveDate(): LocalDate = effectiveDate + + fun memo(): Optional = Optional.ofNullable(memo) + + @JvmSynthetic + internal fun getBody(): ExternalPaymentReleaseBody { + return ExternalPaymentReleaseBody( + effectiveDate, + memo, + additionalBodyProperties, + ) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> externalPaymentToken + else -> "" + } + } + + @JsonDeserialize(builder = ExternalPaymentReleaseBody.Builder::class) + @NoAutoDetect + class ExternalPaymentReleaseBody + internal constructor( + private val effectiveDate: LocalDate?, + private val memo: String?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + @JsonProperty("effective_date") fun effectiveDate(): LocalDate? = effectiveDate + + @JsonProperty("memo") fun memo(): String? = memo + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentReleaseBody && + this.effectiveDate == other.effectiveDate && + this.memo == other.memo && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + effectiveDate, + memo, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ExternalPaymentReleaseBody{effectiveDate=$effectiveDate, memo=$memo, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var effectiveDate: LocalDate? = null + private var memo: String? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentReleaseBody: ExternalPaymentReleaseBody) = apply { + this.effectiveDate = externalPaymentReleaseBody.effectiveDate + this.memo = externalPaymentReleaseBody.memo + additionalProperties(externalPaymentReleaseBody.additionalProperties) + } + + @JsonProperty("effective_date") + fun effectiveDate(effectiveDate: LocalDate) = apply { + this.effectiveDate = effectiveDate + } + + @JsonProperty("memo") fun memo(memo: String) = apply { this.memo = memo } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ExternalPaymentReleaseBody = + ExternalPaymentReleaseBody( + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + memo, + additionalProperties.toUnmodifiable(), + ) + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentReleaseParams && + this.externalPaymentToken == other.externalPaymentToken && + this.effectiveDate == other.effectiveDate && + this.memo == other.memo && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + externalPaymentToken, + effectiveDate, + memo, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "ExternalPaymentReleaseParams{externalPaymentToken=$externalPaymentToken, effectiveDate=$effectiveDate, memo=$memo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var externalPaymentToken: String? = null + private var effectiveDate: LocalDate? = null + private var memo: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentReleaseParams: ExternalPaymentReleaseParams) = apply { + this.externalPaymentToken = externalPaymentReleaseParams.externalPaymentToken + this.effectiveDate = externalPaymentReleaseParams.effectiveDate + this.memo = externalPaymentReleaseParams.memo + additionalQueryParams(externalPaymentReleaseParams.additionalQueryParams) + additionalHeaders(externalPaymentReleaseParams.additionalHeaders) + additionalBodyProperties(externalPaymentReleaseParams.additionalBodyProperties) + } + + fun externalPaymentToken(externalPaymentToken: String) = apply { + this.externalPaymentToken = externalPaymentToken + } + + fun effectiveDate(effectiveDate: LocalDate) = apply { this.effectiveDate = effectiveDate } + + fun memo(memo: String) = apply { this.memo = memo } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ExternalPaymentReleaseParams = + ExternalPaymentReleaseParams( + checkNotNull(externalPaymentToken) { + "`externalPaymentToken` is required but was not set" + }, + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + memo, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentRetrieveParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentRetrieveParams.kt new file mode 100644 index 00000000..8f3159e8 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentRetrieveParams.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.models.* +import java.util.Objects + +class ExternalPaymentRetrieveParams +constructor( + private val externalPaymentToken: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun externalPaymentToken(): String = externalPaymentToken + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> externalPaymentToken + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentRetrieveParams && + this.externalPaymentToken == other.externalPaymentToken && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders + } + + override fun hashCode(): Int { + return Objects.hash( + externalPaymentToken, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "ExternalPaymentRetrieveParams{externalPaymentToken=$externalPaymentToken, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var externalPaymentToken: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentRetrieveParams: ExternalPaymentRetrieveParams) = apply { + this.externalPaymentToken = externalPaymentRetrieveParams.externalPaymentToken + additionalQueryParams(externalPaymentRetrieveParams.additionalQueryParams) + additionalHeaders(externalPaymentRetrieveParams.additionalHeaders) + } + + fun externalPaymentToken(externalPaymentToken: String) = apply { + this.externalPaymentToken = externalPaymentToken + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun build(): ExternalPaymentRetrieveParams = + ExternalPaymentRetrieveParams( + checkNotNull(externalPaymentToken) { + "`externalPaymentToken` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentReverseParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentReverseParams.kt new file mode 100644 index 00000000..0acd66ee --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentReverseParams.kt @@ -0,0 +1,284 @@ +// 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.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.models.* +import java.time.LocalDate +import java.util.Objects +import java.util.Optional + +class ExternalPaymentReverseParams +constructor( + private val externalPaymentToken: String, + private val effectiveDate: LocalDate, + private val memo: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun externalPaymentToken(): String = externalPaymentToken + + fun effectiveDate(): LocalDate = effectiveDate + + fun memo(): Optional = Optional.ofNullable(memo) + + @JvmSynthetic + internal fun getBody(): ExternalPaymentReverseBody { + return ExternalPaymentReverseBody( + effectiveDate, + memo, + additionalBodyProperties, + ) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> externalPaymentToken + else -> "" + } + } + + @JsonDeserialize(builder = ExternalPaymentReverseBody.Builder::class) + @NoAutoDetect + class ExternalPaymentReverseBody + internal constructor( + private val effectiveDate: LocalDate?, + private val memo: String?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + @JsonProperty("effective_date") fun effectiveDate(): LocalDate? = effectiveDate + + @JsonProperty("memo") fun memo(): String? = memo + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentReverseBody && + this.effectiveDate == other.effectiveDate && + this.memo == other.memo && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + effectiveDate, + memo, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ExternalPaymentReverseBody{effectiveDate=$effectiveDate, memo=$memo, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var effectiveDate: LocalDate? = null + private var memo: String? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentReverseBody: ExternalPaymentReverseBody) = apply { + this.effectiveDate = externalPaymentReverseBody.effectiveDate + this.memo = externalPaymentReverseBody.memo + additionalProperties(externalPaymentReverseBody.additionalProperties) + } + + @JsonProperty("effective_date") + fun effectiveDate(effectiveDate: LocalDate) = apply { + this.effectiveDate = effectiveDate + } + + @JsonProperty("memo") fun memo(memo: String) = apply { this.memo = memo } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ExternalPaymentReverseBody = + ExternalPaymentReverseBody( + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + memo, + additionalProperties.toUnmodifiable(), + ) + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentReverseParams && + this.externalPaymentToken == other.externalPaymentToken && + this.effectiveDate == other.effectiveDate && + this.memo == other.memo && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + externalPaymentToken, + effectiveDate, + memo, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "ExternalPaymentReverseParams{externalPaymentToken=$externalPaymentToken, effectiveDate=$effectiveDate, memo=$memo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var externalPaymentToken: String? = null + private var effectiveDate: LocalDate? = null + private var memo: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentReverseParams: ExternalPaymentReverseParams) = apply { + this.externalPaymentToken = externalPaymentReverseParams.externalPaymentToken + this.effectiveDate = externalPaymentReverseParams.effectiveDate + this.memo = externalPaymentReverseParams.memo + additionalQueryParams(externalPaymentReverseParams.additionalQueryParams) + additionalHeaders(externalPaymentReverseParams.additionalHeaders) + additionalBodyProperties(externalPaymentReverseParams.additionalBodyProperties) + } + + fun externalPaymentToken(externalPaymentToken: String) = apply { + this.externalPaymentToken = externalPaymentToken + } + + fun effectiveDate(effectiveDate: LocalDate) = apply { this.effectiveDate = effectiveDate } + + fun memo(memo: String) = apply { this.memo = memo } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ExternalPaymentReverseParams = + ExternalPaymentReverseParams( + checkNotNull(externalPaymentToken) { + "`externalPaymentToken` is required but was not set" + }, + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + memo, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentSettleParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentSettleParams.kt new file mode 100644 index 00000000..dee75b49 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentSettleParams.kt @@ -0,0 +1,372 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import com.lithic.api.models.* +import java.time.LocalDate +import java.util.Objects +import java.util.Optional + +class ExternalPaymentSettleParams +constructor( + private val externalPaymentToken: String, + private val effectiveDate: LocalDate, + private val memo: String?, + private val progressTo: ExternalPaymentProgressTo?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun externalPaymentToken(): String = externalPaymentToken + + fun effectiveDate(): LocalDate = effectiveDate + + fun memo(): Optional = Optional.ofNullable(memo) + + fun progressTo(): Optional = Optional.ofNullable(progressTo) + + @JvmSynthetic + internal fun getBody(): ExternalPaymentSettleBody { + return ExternalPaymentSettleBody( + effectiveDate, + memo, + progressTo, + additionalBodyProperties, + ) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> externalPaymentToken + else -> "" + } + } + + @JsonDeserialize(builder = ExternalPaymentSettleBody.Builder::class) + @NoAutoDetect + class ExternalPaymentSettleBody + internal constructor( + private val effectiveDate: LocalDate?, + private val memo: String?, + private val progressTo: ExternalPaymentProgressTo?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + @JsonProperty("effective_date") fun effectiveDate(): LocalDate? = effectiveDate + + @JsonProperty("memo") fun memo(): String? = memo + + @JsonProperty("progress_to") fun progressTo(): ExternalPaymentProgressTo? = progressTo + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentSettleBody && + this.effectiveDate == other.effectiveDate && + this.memo == other.memo && + this.progressTo == other.progressTo && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + effectiveDate, + memo, + progressTo, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ExternalPaymentSettleBody{effectiveDate=$effectiveDate, memo=$memo, progressTo=$progressTo, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var effectiveDate: LocalDate? = null + private var memo: String? = null + private var progressTo: ExternalPaymentProgressTo? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentSettleBody: ExternalPaymentSettleBody) = apply { + this.effectiveDate = externalPaymentSettleBody.effectiveDate + this.memo = externalPaymentSettleBody.memo + this.progressTo = externalPaymentSettleBody.progressTo + additionalProperties(externalPaymentSettleBody.additionalProperties) + } + + @JsonProperty("effective_date") + fun effectiveDate(effectiveDate: LocalDate) = apply { + this.effectiveDate = effectiveDate + } + + @JsonProperty("memo") fun memo(memo: String) = apply { this.memo = memo } + + @JsonProperty("progress_to") + fun progressTo(progressTo: ExternalPaymentProgressTo) = apply { + this.progressTo = progressTo + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ExternalPaymentSettleBody = + ExternalPaymentSettleBody( + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + memo, + progressTo, + additionalProperties.toUnmodifiable(), + ) + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentSettleParams && + this.externalPaymentToken == other.externalPaymentToken && + this.effectiveDate == other.effectiveDate && + this.memo == other.memo && + this.progressTo == other.progressTo && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + externalPaymentToken, + effectiveDate, + memo, + progressTo, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "ExternalPaymentSettleParams{externalPaymentToken=$externalPaymentToken, effectiveDate=$effectiveDate, memo=$memo, progressTo=$progressTo, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var externalPaymentToken: String? = null + private var effectiveDate: LocalDate? = null + private var memo: String? = null + private var progressTo: ExternalPaymentProgressTo? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentSettleParams: ExternalPaymentSettleParams) = apply { + this.externalPaymentToken = externalPaymentSettleParams.externalPaymentToken + this.effectiveDate = externalPaymentSettleParams.effectiveDate + this.memo = externalPaymentSettleParams.memo + this.progressTo = externalPaymentSettleParams.progressTo + additionalQueryParams(externalPaymentSettleParams.additionalQueryParams) + additionalHeaders(externalPaymentSettleParams.additionalHeaders) + additionalBodyProperties(externalPaymentSettleParams.additionalBodyProperties) + } + + fun externalPaymentToken(externalPaymentToken: String) = apply { + this.externalPaymentToken = externalPaymentToken + } + + fun effectiveDate(effectiveDate: LocalDate) = apply { this.effectiveDate = effectiveDate } + + fun memo(memo: String) = apply { this.memo = memo } + + fun progressTo(progressTo: ExternalPaymentProgressTo) = apply { + this.progressTo = progressTo + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ExternalPaymentSettleParams = + ExternalPaymentSettleParams( + checkNotNull(externalPaymentToken) { + "`externalPaymentToken` is required but was not set" + }, + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + memo, + progressTo, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } + + class ExternalPaymentProgressTo + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExternalPaymentProgressTo && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val SETTLED = ExternalPaymentProgressTo(JsonField.of("SETTLED")) + + @JvmField val RELEASED = ExternalPaymentProgressTo(JsonField.of("RELEASED")) + + @JvmStatic fun of(value: String) = ExternalPaymentProgressTo(JsonField.of(value)) + } + + enum class Known { + SETTLED, + RELEASED, + } + + enum class Value { + SETTLED, + RELEASED, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + SETTLED -> Value.SETTLED + RELEASED -> Value.RELEASED + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + SETTLED -> Known.SETTLED + RELEASED -> Known.RELEASED + else -> + throw LithicInvalidDataException("Unknown ExternalPaymentProgressTo: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccount.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccount.kt index 10bb1a7c..162ec8e6 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccount.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccount.kt @@ -19,20 +19,20 @@ import java.time.OffsetDateTime import java.util.Objects import java.util.Optional -/** Financial Account */ @JsonDeserialize(builder = FinancialAccount.Builder::class) @NoAutoDetect class FinancialAccount private constructor( - private val accountNumber: JsonField, - private val accountToken: JsonField, - private val created: JsonField, - private val nickname: JsonField, - private val routingNumber: JsonField, private val token: JsonField, - private val type: JsonField, + private val created: JsonField, private val updated: JsonField, + private val type: JsonField, + private val routingNumber: JsonField, + private val accountNumber: JsonField, + private val nickname: JsonField, + private val accountToken: JsonField, private val isForBenefitOf: JsonField, + private val creditConfiguration: JsonField, private val additionalProperties: Map, ) { @@ -40,78 +40,72 @@ private constructor( private var hashCode: Int = 0 - /** Account number for your Lithic-assigned bank account number, if applicable. */ - fun accountNumber(): Optional = - Optional.ofNullable(accountNumber.getNullable("account_number")) - - /** Account token of the financial account if applicable. */ - fun accountToken(): Optional = - Optional.ofNullable(accountToken.getNullable("account_token")) + /** Globally unique identifier for the account */ + fun token(): String = token.getRequired("token") - /** Date and time for when the financial account was first created. */ fun created(): OffsetDateTime = created.getRequired("created") - /** User-defined nickname for the financial account. */ - fun nickname(): Optional = Optional.ofNullable(nickname.getNullable("nickname")) + fun updated(): OffsetDateTime = updated.getRequired("updated") + + fun type(): Type = type.getRequired("type") - /** Routing number for your Lithic-assigned bank account number, if applicable. */ fun routingNumber(): Optional = Optional.ofNullable(routingNumber.getNullable("routing_number")) - /** Globally unique identifier for the financial account. */ - fun token(): String = token.getRequired("token") + fun accountNumber(): Optional = + Optional.ofNullable(accountNumber.getNullable("account_number")) - /** Type of financial account */ - fun type(): Type = type.getRequired("type") + fun nickname(): Optional = Optional.ofNullable(nickname.getNullable("nickname")) - /** Date and time for when the financial account was last updated. */ - fun updated(): OffsetDateTime = updated.getRequired("updated") + fun accountToken(): Optional = + Optional.ofNullable(accountToken.getNullable("account_token")) - /** Whether the financial account holds funds for benefit of another party. */ + /** Whether financial account is for the benefit of another entity */ fun isForBenefitOf(): Boolean = isForBenefitOf.getRequired("is_for_benefit_of") - /** Account number for your Lithic-assigned bank account number, if applicable. */ - @JsonProperty("account_number") @ExcludeMissing fun _accountNumber() = accountNumber + fun creditConfiguration(): Optional = + Optional.ofNullable(creditConfiguration.getNullable("credit_configuration")) - /** Account token of the financial account if applicable. */ - @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + /** Globally unique identifier for the account */ + @JsonProperty("token") @ExcludeMissing fun _token() = token - /** Date and time for when the financial account was first created. */ @JsonProperty("created") @ExcludeMissing fun _created() = created - /** User-defined nickname for the financial account. */ - @JsonProperty("nickname") @ExcludeMissing fun _nickname() = nickname + @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + + @JsonProperty("type") @ExcludeMissing fun _type() = type - /** Routing number for your Lithic-assigned bank account number, if applicable. */ @JsonProperty("routing_number") @ExcludeMissing fun _routingNumber() = routingNumber - /** Globally unique identifier for the financial account. */ - @JsonProperty("token") @ExcludeMissing fun _token() = token + @JsonProperty("account_number") @ExcludeMissing fun _accountNumber() = accountNumber - /** Type of financial account */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("nickname") @ExcludeMissing fun _nickname() = nickname - /** Date and time for when the financial account was last updated. */ - @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken - /** Whether the financial account holds funds for benefit of another party. */ + /** Whether financial account is for the benefit of another entity */ @JsonProperty("is_for_benefit_of") @ExcludeMissing fun _isForBenefitOf() = isForBenefitOf + @JsonProperty("credit_configuration") + @ExcludeMissing + fun _creditConfiguration() = creditConfiguration + @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties fun validate(): FinancialAccount = apply { if (!validated) { - accountNumber() - accountToken() - created() - nickname() - routingNumber() token() - type() + created() updated() + type() + routingNumber() + accountNumber() + nickname() + accountToken() isForBenefitOf() + creditConfiguration().map { it.validate() } validated = true } } @@ -124,15 +118,16 @@ private constructor( } return other is FinancialAccount && - this.accountNumber == other.accountNumber && - this.accountToken == other.accountToken && - this.created == other.created && - this.nickname == other.nickname && - this.routingNumber == other.routingNumber && this.token == other.token && - this.type == other.type && + this.created == other.created && this.updated == other.updated && + this.type == other.type && + this.routingNumber == other.routingNumber && + this.accountNumber == other.accountNumber && + this.nickname == other.nickname && + this.accountToken == other.accountToken && this.isForBenefitOf == other.isForBenefitOf && + this.creditConfiguration == other.creditConfiguration && this.additionalProperties == other.additionalProperties } @@ -140,15 +135,16 @@ private constructor( if (hashCode == 0) { hashCode = Objects.hash( - accountNumber, - accountToken, - created, - nickname, - routingNumber, token, - type, + created, updated, + type, + routingNumber, + accountNumber, + nickname, + accountToken, isForBenefitOf, + creditConfiguration, additionalProperties, ) } @@ -156,7 +152,7 @@ private constructor( } override fun toString() = - "FinancialAccount{accountNumber=$accountNumber, accountToken=$accountToken, created=$created, nickname=$nickname, routingNumber=$routingNumber, token=$token, type=$type, updated=$updated, isForBenefitOf=$isForBenefitOf, additionalProperties=$additionalProperties}" + "FinancialAccount{token=$token, created=$created, updated=$updated, type=$type, routingNumber=$routingNumber, accountNumber=$accountNumber, nickname=$nickname, accountToken=$accountToken, isForBenefitOf=$isForBenefitOf, creditConfiguration=$creditConfiguration, additionalProperties=$additionalProperties}" companion object { @@ -165,111 +161,109 @@ private constructor( class Builder { - private var accountNumber: JsonField = JsonMissing.of() - private var accountToken: JsonField = JsonMissing.of() - private var created: JsonField = JsonMissing.of() - private var nickname: JsonField = JsonMissing.of() - private var routingNumber: JsonField = JsonMissing.of() private var token: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() private var updated: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var routingNumber: JsonField = JsonMissing.of() + private var accountNumber: JsonField = JsonMissing.of() + private var nickname: JsonField = JsonMissing.of() + private var accountToken: JsonField = JsonMissing.of() private var isForBenefitOf: JsonField = JsonMissing.of() + private var creditConfiguration: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(financialAccount: FinancialAccount) = apply { - this.accountNumber = financialAccount.accountNumber - this.accountToken = financialAccount.accountToken - this.created = financialAccount.created - this.nickname = financialAccount.nickname - this.routingNumber = financialAccount.routingNumber this.token = financialAccount.token - this.type = financialAccount.type + this.created = financialAccount.created this.updated = financialAccount.updated + this.type = financialAccount.type + this.routingNumber = financialAccount.routingNumber + this.accountNumber = financialAccount.accountNumber + this.nickname = financialAccount.nickname + this.accountToken = financialAccount.accountToken this.isForBenefitOf = financialAccount.isForBenefitOf + this.creditConfiguration = financialAccount.creditConfiguration additionalProperties(financialAccount.additionalProperties) } - /** Account number for your Lithic-assigned bank account number, if applicable. */ - fun accountNumber(accountNumber: String) = accountNumber(JsonField.of(accountNumber)) - - /** Account number for your Lithic-assigned bank account number, if applicable. */ - @JsonProperty("account_number") - @ExcludeMissing - fun accountNumber(accountNumber: JsonField) = apply { - this.accountNumber = accountNumber - } - - /** Account token of the financial account if applicable. */ - fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + /** Globally unique identifier for the account */ + fun token(token: String) = token(JsonField.of(token)) - /** Account token of the financial account if applicable. */ - @JsonProperty("account_token") + /** Globally unique identifier for the account */ + @JsonProperty("token") @ExcludeMissing - fun accountToken(accountToken: JsonField) = apply { - this.accountToken = accountToken - } + fun token(token: JsonField) = apply { this.token = token } - /** Date and time for when the financial account was first created. */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) - /** Date and time for when the financial account was first created. */ @JsonProperty("created") @ExcludeMissing fun created(created: JsonField) = apply { this.created = created } - /** User-defined nickname for the financial account. */ - fun nickname(nickname: String) = nickname(JsonField.of(nickname)) + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) - /** User-defined nickname for the financial account. */ - @JsonProperty("nickname") + @JsonProperty("updated") @ExcludeMissing - fun nickname(nickname: JsonField) = apply { this.nickname = nickname } + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun type(type: Type) = type(JsonField.of(type)) + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } - /** Routing number for your Lithic-assigned bank account number, if applicable. */ fun routingNumber(routingNumber: String) = routingNumber(JsonField.of(routingNumber)) - /** Routing number for your Lithic-assigned bank account number, if applicable. */ @JsonProperty("routing_number") @ExcludeMissing fun routingNumber(routingNumber: JsonField) = apply { this.routingNumber = routingNumber } - /** Globally unique identifier for the financial account. */ - fun token(token: String) = token(JsonField.of(token)) + fun accountNumber(accountNumber: String) = accountNumber(JsonField.of(accountNumber)) - /** Globally unique identifier for the financial account. */ - @JsonProperty("token") + @JsonProperty("account_number") @ExcludeMissing - fun token(token: JsonField) = apply { this.token = token } + fun accountNumber(accountNumber: JsonField) = apply { + this.accountNumber = accountNumber + } - /** Type of financial account */ - fun type(type: Type) = type(JsonField.of(type)) + fun nickname(nickname: String) = nickname(JsonField.of(nickname)) - /** Type of financial account */ - @JsonProperty("type") + @JsonProperty("nickname") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun nickname(nickname: JsonField) = apply { this.nickname = nickname } - /** Date and time for when the financial account was last updated. */ - fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) - /** Date and time for when the financial account was last updated. */ - @JsonProperty("updated") + @JsonProperty("account_token") @ExcludeMissing - fun updated(updated: JsonField) = apply { this.updated = updated } + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } - /** Whether the financial account holds funds for benefit of another party. */ + /** Whether financial account is for the benefit of another entity */ fun isForBenefitOf(isForBenefitOf: Boolean) = isForBenefitOf(JsonField.of(isForBenefitOf)) - /** Whether the financial account holds funds for benefit of another party. */ + /** Whether financial account is for the benefit of another entity */ @JsonProperty("is_for_benefit_of") @ExcludeMissing fun isForBenefitOf(isForBenefitOf: JsonField) = apply { this.isForBenefitOf = isForBenefitOf } + fun creditConfiguration(creditConfiguration: FinancialAccountCreditConfig) = + creditConfiguration(JsonField.of(creditConfiguration)) + + @JsonProperty("credit_configuration") + @ExcludeMissing + fun creditConfiguration(creditConfiguration: JsonField) = + apply { + this.creditConfiguration = creditConfiguration + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() this.additionalProperties.putAll(additionalProperties) @@ -286,19 +280,282 @@ private constructor( fun build(): FinancialAccount = FinancialAccount( - accountNumber, - accountToken, - created, - nickname, - routingNumber, token, - type, + created, updated, + type, + routingNumber, + accountNumber, + nickname, + accountToken, isForBenefitOf, + creditConfiguration, additionalProperties.toUnmodifiable(), ) } + @JsonDeserialize(builder = FinancialAccountCreditConfig.Builder::class) + @NoAutoDetect + class FinancialAccountCreditConfig + private constructor( + private val creditLimit: JsonField, + private val externalBankAccountToken: JsonField, + private val creditProductToken: JsonField, + private val tier: JsonField, + private val financialAccountState: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun creditLimit(): Optional = + Optional.ofNullable(creditLimit.getNullable("credit_limit")) + + fun externalBankAccountToken(): Optional = + Optional.ofNullable(externalBankAccountToken.getNullable("external_bank_account_token")) + + /** Globally unique identifier for the credit product */ + fun creditProductToken(): Optional = + Optional.ofNullable(creditProductToken.getNullable("credit_product_token")) + + /** Tier assigned to the financial account */ + fun tier(): Optional = Optional.ofNullable(tier.getNullable("tier")) + + /** State of the financial account */ + fun financialAccountState(): Optional = + Optional.ofNullable(financialAccountState.getNullable("financial_account_state")) + + @JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit() = creditLimit + + @JsonProperty("external_bank_account_token") + @ExcludeMissing + fun _externalBankAccountToken() = externalBankAccountToken + + /** Globally unique identifier for the credit product */ + @JsonProperty("credit_product_token") + @ExcludeMissing + fun _creditProductToken() = creditProductToken + + /** Tier assigned to the financial account */ + @JsonProperty("tier") @ExcludeMissing fun _tier() = tier + + /** State of the financial account */ + @JsonProperty("financial_account_state") + @ExcludeMissing + fun _financialAccountState() = financialAccountState + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): FinancialAccountCreditConfig = apply { + if (!validated) { + creditLimit() + externalBankAccountToken() + creditProductToken() + tier() + financialAccountState() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FinancialAccountCreditConfig && + this.creditLimit == other.creditLimit && + this.externalBankAccountToken == other.externalBankAccountToken && + this.creditProductToken == other.creditProductToken && + this.tier == other.tier && + this.financialAccountState == other.financialAccountState && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + creditLimit, + externalBankAccountToken, + creditProductToken, + tier, + financialAccountState, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "FinancialAccountCreditConfig{creditLimit=$creditLimit, externalBankAccountToken=$externalBankAccountToken, creditProductToken=$creditProductToken, tier=$tier, financialAccountState=$financialAccountState, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var creditLimit: JsonField = JsonMissing.of() + private var externalBankAccountToken: JsonField = JsonMissing.of() + private var creditProductToken: JsonField = JsonMissing.of() + private var tier: JsonField = JsonMissing.of() + private var financialAccountState: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(financialAccountCreditConfig: FinancialAccountCreditConfig) = apply { + this.creditLimit = financialAccountCreditConfig.creditLimit + this.externalBankAccountToken = + financialAccountCreditConfig.externalBankAccountToken + this.creditProductToken = financialAccountCreditConfig.creditProductToken + this.tier = financialAccountCreditConfig.tier + this.financialAccountState = financialAccountCreditConfig.financialAccountState + additionalProperties(financialAccountCreditConfig.additionalProperties) + } + + fun creditLimit(creditLimit: Long) = creditLimit(JsonField.of(creditLimit)) + + @JsonProperty("credit_limit") + @ExcludeMissing + fun creditLimit(creditLimit: JsonField) = apply { this.creditLimit = creditLimit } + + fun externalBankAccountToken(externalBankAccountToken: String) = + externalBankAccountToken(JsonField.of(externalBankAccountToken)) + + @JsonProperty("external_bank_account_token") + @ExcludeMissing + fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { + this.externalBankAccountToken = externalBankAccountToken + } + + /** Globally unique identifier for the credit product */ + fun creditProductToken(creditProductToken: String) = + creditProductToken(JsonField.of(creditProductToken)) + + /** Globally unique identifier for the credit product */ + @JsonProperty("credit_product_token") + @ExcludeMissing + fun creditProductToken(creditProductToken: JsonField) = apply { + this.creditProductToken = creditProductToken + } + + /** Tier assigned to the financial account */ + fun tier(tier: String) = tier(JsonField.of(tier)) + + /** Tier assigned to the financial account */ + @JsonProperty("tier") + @ExcludeMissing + fun tier(tier: JsonField) = apply { this.tier = tier } + + /** State of the financial account */ + fun financialAccountState(financialAccountState: FinancialAccountState) = + financialAccountState(JsonField.of(financialAccountState)) + + /** State of the financial account */ + @JsonProperty("financial_account_state") + @ExcludeMissing + fun financialAccountState(financialAccountState: JsonField) = + apply { + this.financialAccountState = financialAccountState + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): FinancialAccountCreditConfig = + FinancialAccountCreditConfig( + creditLimit, + externalBankAccountToken, + creditProductToken, + tier, + financialAccountState, + additionalProperties.toUnmodifiable(), + ) + } + + class FinancialAccountState + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FinancialAccountState && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PENDING = FinancialAccountState(JsonField.of("PENDING")) + + @JvmField val CURRENT = FinancialAccountState(JsonField.of("CURRENT")) + + @JvmField val DELINQUENT = FinancialAccountState(JsonField.of("DELINQUENT")) + + @JvmStatic fun of(value: String) = FinancialAccountState(JsonField.of(value)) + } + + enum class Known { + PENDING, + CURRENT, + DELINQUENT, + } + + enum class Value { + PENDING, + CURRENT, + DELINQUENT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + CURRENT -> Value.CURRENT + DELINQUENT -> Value.DELINQUENT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + CURRENT -> Known.CURRENT + DELINQUENT -> Known.DELINQUENT + else -> + throw LithicInvalidDataException("Unknown FinancialAccountState: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } + class Type @JsonCreator private constructor( @@ -323,39 +580,39 @@ private constructor( @JvmField val ISSUING = Type(JsonField.of("ISSUING")) - @JvmField val OPERATING = Type(JsonField.of("OPERATING")) - @JvmField val RESERVE = Type(JsonField.of("RESERVE")) + @JvmField val OPERATING = Type(JsonField.of("OPERATING")) + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } enum class Known { ISSUING, - OPERATING, RESERVE, + OPERATING, } enum class Value { ISSUING, - OPERATING, RESERVE, + OPERATING, _UNKNOWN, } fun value(): Value = when (this) { ISSUING -> Value.ISSUING - OPERATING -> Value.OPERATING RESERVE -> Value.RESERVE + OPERATING -> Value.OPERATING else -> Value._UNKNOWN } fun known(): Known = when (this) { ISSUING -> Known.ISSUING - OPERATING -> Known.OPERATING RESERVE -> Known.RESERVE + OPERATING -> Known.OPERATING else -> throw LithicInvalidDataException("Unknown Type: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreditConfig.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreditConfig.kt index db6a47d3..280c521d 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreditConfig.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreditConfig.kt @@ -4,14 +4,17 @@ 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.databind.annotation.JsonDeserialize +import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue import com.lithic.api.core.NoAutoDetect import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException import java.util.Objects import java.util.Optional @@ -24,7 +27,7 @@ private constructor( private val externalBankAccountToken: JsonField, private val creditProductToken: JsonField, private val tier: JsonField, - private val financialAccountState: JsonField, + private val financialAccountState: JsonField, private val additionalProperties: Map, ) { @@ -48,7 +51,7 @@ private constructor( fun tier(): Optional = Optional.ofNullable(tier.getNullable("tier")) /** State of the financial account */ - fun financialAccountState(): Optional = + fun financialAccountState(): Optional = Optional.ofNullable(financialAccountState.getNullable("financial_account_state")) /** Globally unique identifier for the account */ @@ -137,7 +140,7 @@ private constructor( private var externalBankAccountToken: JsonField = JsonMissing.of() private var creditProductToken: JsonField = JsonMissing.of() private var tier: JsonField = JsonMissing.of() - private var financialAccountState: JsonField = JsonMissing.of() + private var financialAccountState: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -196,13 +199,13 @@ private constructor( fun tier(tier: JsonField) = apply { this.tier = tier } /** State of the financial account */ - fun financialAccountState(financialAccountState: String) = + fun financialAccountState(financialAccountState: FinancialAccountState) = financialAccountState(JsonField.of(financialAccountState)) /** State of the financial account */ @JsonProperty("financial_account_state") @ExcludeMissing - fun financialAccountState(financialAccountState: JsonField) = apply { + fun financialAccountState(financialAccountState: JsonField) = apply { this.financialAccountState = financialAccountState } @@ -231,4 +234,67 @@ private constructor( additionalProperties.toUnmodifiable(), ) } + + class FinancialAccountState + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FinancialAccountState && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val PENDING = FinancialAccountState(JsonField.of("PENDING")) + + @JvmField val CURRENT = FinancialAccountState(JsonField.of("CURRENT")) + + @JvmField val DELINQUENT = FinancialAccountState(JsonField.of("DELINQUENT")) + + @JvmStatic fun of(value: String) = FinancialAccountState(JsonField.of(value)) + } + + enum class Known { + PENDING, + CURRENT, + DELINQUENT, + } + + enum class Value { + PENDING, + CURRENT, + DELINQUENT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + CURRENT -> Value.CURRENT + DELINQUENT -> Value.DELINQUENT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + CURRENT -> Known.CURRENT + DELINQUENT -> Known.DELINQUENT + else -> throw LithicInvalidDataException("Unknown FinancialAccountState: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/InstanceFinancialAccountType.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/InstanceFinancialAccountType.kt new file mode 100644 index 00000000..944e017a --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/InstanceFinancialAccountType.kt @@ -0,0 +1,72 @@ +// 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.core.JsonValue +import com.lithic.api.errors.LithicInvalidDataException + +class InstanceFinancialAccountType +@JsonCreator +private constructor( + private val value: JsonField, +) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InstanceFinancialAccountType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ISSUING = InstanceFinancialAccountType(JsonField.of("ISSUING")) + + @JvmField val RESERVE = InstanceFinancialAccountType(JsonField.of("RESERVE")) + + @JvmField val OPERATING = InstanceFinancialAccountType(JsonField.of("OPERATING")) + + @JvmStatic fun of(value: String) = InstanceFinancialAccountType(JsonField.of(value)) + } + + enum class Known { + ISSUING, + RESERVE, + OPERATING, + } + + enum class Value { + ISSUING, + RESERVE, + OPERATING, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ISSUING -> Value.ISSUING + RESERVE -> Value.RESERVE + OPERATING -> Value.OPERATING + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ISSUING -> Known.ISSUING + RESERVE -> Known.RESERVE + OPERATING -> Known.OPERATING + else -> throw LithicInvalidDataException("Unknown InstanceFinancialAccountType: $value") + } + + fun asString(): String = _value().asStringOrThrow() +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/RequiredDocument.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/RequiredDocument.kt new file mode 100644 index 00000000..7b9de983 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/RequiredDocument.kt @@ -0,0 +1,183 @@ +// 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.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import java.util.Objects + +@JsonDeserialize(builder = RequiredDocument.Builder::class) +@NoAutoDetect +class RequiredDocument +private constructor( + private val entityToken: JsonField, + private val validDocuments: JsonField>, + private val statusReasons: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Globally unique identifier for an entity. */ + fun entityToken(): String = entityToken.getRequired("entity_token") + + /** + * A list of valid documents that will satisfy the KYC requirements for the specified entity. + */ + fun validDocuments(): List = validDocuments.getRequired("valid_documents") + + /** + * rovides the status reasons that will be satisfied by providing one of the valid documents. + */ + fun statusReasons(): List = statusReasons.getRequired("status_reasons") + + /** Globally unique identifier for an entity. */ + @JsonProperty("entity_token") @ExcludeMissing fun _entityToken() = entityToken + + /** + * A list of valid documents that will satisfy the KYC requirements for the specified entity. + */ + @JsonProperty("valid_documents") @ExcludeMissing fun _validDocuments() = validDocuments + + /** + * rovides the status reasons that will be satisfied by providing one of the valid documents. + */ + @JsonProperty("status_reasons") @ExcludeMissing fun _statusReasons() = statusReasons + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RequiredDocument = apply { + if (!validated) { + entityToken() + validDocuments() + statusReasons() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RequiredDocument && + this.entityToken == other.entityToken && + this.validDocuments == other.validDocuments && + this.statusReasons == other.statusReasons && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + entityToken, + validDocuments, + statusReasons, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "RequiredDocument{entityToken=$entityToken, validDocuments=$validDocuments, statusReasons=$statusReasons, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var entityToken: JsonField = JsonMissing.of() + private var validDocuments: JsonField> = JsonMissing.of() + private var statusReasons: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(requiredDocument: RequiredDocument) = apply { + this.entityToken = requiredDocument.entityToken + this.validDocuments = requiredDocument.validDocuments + this.statusReasons = requiredDocument.statusReasons + additionalProperties(requiredDocument.additionalProperties) + } + + /** Globally unique identifier for an entity. */ + fun entityToken(entityToken: String) = entityToken(JsonField.of(entityToken)) + + /** Globally unique identifier for an entity. */ + @JsonProperty("entity_token") + @ExcludeMissing + fun entityToken(entityToken: JsonField) = apply { this.entityToken = entityToken } + + /** + * A list of valid documents that will satisfy the KYC requirements for the specified + * entity. + */ + fun validDocuments(validDocuments: List) = + validDocuments(JsonField.of(validDocuments)) + + /** + * A list of valid documents that will satisfy the KYC requirements for the specified + * entity. + */ + @JsonProperty("valid_documents") + @ExcludeMissing + fun validDocuments(validDocuments: JsonField>) = apply { + this.validDocuments = validDocuments + } + + /** + * rovides the status reasons that will be satisfied by providing one of the valid + * documents. + */ + fun statusReasons(statusReasons: List) = statusReasons(JsonField.of(statusReasons)) + + /** + * rovides the status reasons that will be satisfied by providing one of the valid + * documents. + */ + @JsonProperty("status_reasons") + @ExcludeMissing + fun statusReasons(statusReasons: JsonField>) = apply { + this.statusReasons = statusReasons + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): RequiredDocument = + RequiredDocument( + entityToken, + validDocuments.map { it.toUnmodifiable() }, + statusReasons.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationResendActivationCodeParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationResendActivationCodeParams.kt index 7d1c632b..e0fc9735 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationResendActivationCodeParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationResendActivationCodeParams.kt @@ -60,8 +60,8 @@ constructor( /** * The communication method that the user has selected to use to receive the authentication - * code. Supported Values: Sms = 'TEXT_TO_CARDHOLDER_NUMBER'. Email = - * 'EMAIL_TO_CARDHOLDER_ADDRESS' + * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" */ @JsonProperty("activation_method_type") fun activationMethodType(): ActivationMethodType? = activationMethodType @@ -113,8 +113,8 @@ constructor( /** * The communication method that the user has selected to use to receive the - * authentication code. Supported Values: Sms = 'TEXT_TO_CARDHOLDER_NUMBER'. Email = - * 'EMAIL_TO_CARDHOLDER_ADDRESS' + * authentication code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" */ @JsonProperty("activation_method_type") fun activationMethodType(activationMethodType: ActivationMethodType) = apply { @@ -210,8 +210,8 @@ constructor( /** * The communication method that the user has selected to use to receive the authentication - * code. Supported Values: Sms = 'TEXT_TO_CARDHOLDER_NUMBER'. Email = - * 'EMAIL_TO_CARDHOLDER_ADDRESS' + * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" */ fun activationMethodType(activationMethodType: ActivationMethodType) = apply { this.activationMethodType = activationMethodType 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 483f763c..e35e5359 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 @@ -107,14 +107,14 @@ private constructor( fun merchant(): Merchant = merchant.getRequired("merchant") /** - * Analogous to the 'amount' property, but will represent the amount in the transaction's local + * Analogous to the "amount" property, but will represent the amount in the transaction's local * currency (smallest unit), including any acquirer fees. */ fun merchantAmount(): Optional = Optional.ofNullable(merchantAmount.getNullable("merchant_amount")) /** - * Analogous to the 'authorization_amount' property, but will represent the amount in the + * Analogous to the "authorization_amount" property, but will represent the amount in the * transaction's local currency (smallest unit), including any acquirer fees. */ fun merchantAuthorizationAmount(): Optional = @@ -228,13 +228,13 @@ private constructor( @JsonProperty("merchant") @ExcludeMissing fun _merchant() = merchant /** - * Analogous to the 'amount' property, but will represent the amount in the transaction's local + * Analogous to the "amount" property, but will represent the amount in the transaction's local * currency (smallest unit), including any acquirer fees. */ @JsonProperty("merchant_amount") @ExcludeMissing fun _merchantAmount() = merchantAmount /** - * Analogous to the 'authorization_amount' property, but will represent the amount in the + * Analogous to the "authorization_amount" property, but will represent the amount in the * transaction's local currency (smallest unit), including any acquirer fees. */ @JsonProperty("merchant_authorization_amount") @@ -594,13 +594,13 @@ private constructor( fun merchant(merchant: JsonField) = apply { this.merchant = merchant } /** - * Analogous to the 'amount' property, but will represent the amount in the transaction's + * Analogous to the "amount" property, but will represent the amount in the transaction's * local currency (smallest unit), including any acquirer fees. */ fun merchantAmount(merchantAmount: Long) = merchantAmount(JsonField.of(merchantAmount)) /** - * Analogous to the 'amount' property, but will represent the amount in the transaction's + * Analogous to the "amount" property, but will represent the amount in the transaction's * local currency (smallest unit), including any acquirer fees. */ @JsonProperty("merchant_amount") @@ -610,14 +610,14 @@ private constructor( } /** - * Analogous to the 'authorization_amount' property, but will represent the amount in the + * Analogous to the "authorization_amount" property, but will represent the amount in the * transaction's local currency (smallest unit), including any acquirer fees. */ fun merchantAuthorizationAmount(merchantAuthorizationAmount: Long) = merchantAuthorizationAmount(JsonField.of(merchantAuthorizationAmount)) /** - * Analogous to the 'authorization_amount' property, but will represent the amount in the + * Analogous to the "authorization_amount" property, but will represent the amount in the * transaction's local currency (smallest unit), including any acquirer fees. */ @JsonProperty("merchant_authorization_amount") diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ApplyResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ApplyResponse.kt new file mode 100644 index 00000000..ca0f2279 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ApplyResponse.kt @@ -0,0 +1,2063 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = V2ApplyResponse.Builder::class) +@NoAutoDetect +class V2ApplyResponse +private constructor( + private val token: JsonField, + private val state: JsonField, + private val programLevel: JsonField, + private val cardTokens: JsonField>, + private val accountTokens: JsonField>, + private val type: JsonField, + private val currentVersion: JsonField, + private val draftVersion: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun token(): String = token.getRequired("token") + + /** The state of the Auth Rule */ + fun state(): AuthRuleState = state.getRequired("state") + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(): Boolean = programLevel.getRequired("program_level") + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(): List = cardTokens.getRequired("card_tokens") + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(): List = accountTokens.getRequired("account_tokens") + + /** The type of Auth Rule */ + fun type(): AuthRuleType = type.getRequired("type") + + fun currentVersion(): Optional = + Optional.ofNullable(currentVersion.getNullable("current_version")) + + fun draftVersion(): Optional = + Optional.ofNullable(draftVersion.getNullable("draft_version")) + + @JsonProperty("token") @ExcludeMissing fun _token() = token + + /** The state of the Auth Rule */ + @JsonProperty("state") @ExcludeMissing fun _state() = state + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + + /** The type of Auth Rule */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + + @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): V2ApplyResponse = apply { + if (!validated) { + token() + state() + programLevel() + cardTokens() + accountTokens() + type() + currentVersion().map { it.validate() } + draftVersion().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V2ApplyResponse && + this.token == other.token && + this.state == other.state && + this.programLevel == other.programLevel && + this.cardTokens == other.cardTokens && + this.accountTokens == other.accountTokens && + this.type == other.type && + this.currentVersion == other.currentVersion && + this.draftVersion == other.draftVersion && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + token, + state, + programLevel, + cardTokens, + accountTokens, + type, + currentVersion, + draftVersion, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "V2ApplyResponse{token=$token, state=$state, programLevel=$programLevel, cardTokens=$cardTokens, accountTokens=$accountTokens, type=$type, currentVersion=$currentVersion, draftVersion=$draftVersion, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var token: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var programLevel: JsonField = JsonMissing.of() + private var cardTokens: JsonField> = JsonMissing.of() + private var accountTokens: JsonField> = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var currentVersion: JsonField = JsonMissing.of() + private var draftVersion: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v2ApplyResponse: V2ApplyResponse) = apply { + this.token = v2ApplyResponse.token + this.state = v2ApplyResponse.state + this.programLevel = v2ApplyResponse.programLevel + this.cardTokens = v2ApplyResponse.cardTokens + this.accountTokens = v2ApplyResponse.accountTokens + this.type = v2ApplyResponse.type + this.currentVersion = v2ApplyResponse.currentVersion + this.draftVersion = v2ApplyResponse.draftVersion + additionalProperties(v2ApplyResponse.additionalProperties) + } + + fun token(token: String) = token(JsonField.of(token)) + + @JsonProperty("token") + @ExcludeMissing + fun token(token: JsonField) = apply { this.token = token } + + /** The state of the Auth Rule */ + fun state(state: AuthRuleState) = state(JsonField.of(state)) + + /** The state of the Auth Rule */ + @JsonProperty("state") + @ExcludeMissing + fun state(state: JsonField) = apply { this.state = state } + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") + @ExcludeMissing + fun programLevel(programLevel: JsonField) = apply { + this.programLevel = programLevel + } + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") + @ExcludeMissing + fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(accountTokens: List) = accountTokens(JsonField.of(accountTokens)) + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") + @ExcludeMissing + fun accountTokens(accountTokens: JsonField>) = apply { + this.accountTokens = accountTokens + } + + /** The type of Auth Rule */ + fun type(type: AuthRuleType) = type(JsonField.of(type)) + + /** The type of Auth Rule */ + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun currentVersion(currentVersion: CurrentVersion) = + currentVersion(JsonField.of(currentVersion)) + + @JsonProperty("current_version") + @ExcludeMissing + fun currentVersion(currentVersion: JsonField) = apply { + this.currentVersion = currentVersion + } + + fun draftVersion(draftVersion: DraftVersion) = draftVersion(JsonField.of(draftVersion)) + + @JsonProperty("draft_version") + @ExcludeMissing + fun draftVersion(draftVersion: JsonField) = apply { + this.draftVersion = draftVersion + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): V2ApplyResponse = + V2ApplyResponse( + token, + state, + programLevel, + cardTokens.map { it.toUnmodifiable() }, + accountTokens.map { it.toUnmodifiable() }, + type, + currentVersion, + draftVersion, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = CurrentVersion.Builder::class) + @NoAutoDetect + class CurrentVersion + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): AuthRuleParameters = parameters.getRequired("parameters") + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + fun version(): Long = version.getRequired("version") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CurrentVersion = apply { + if (!validated) { + parameters() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentVersion && + this.parameters == other.parameters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CurrentVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(currentVersion: CurrentVersion) = apply { + this.parameters = currentVersion.parameters + this.version = currentVersion.version + additionalProperties(currentVersion.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = parameters(JsonField.of(parameters)) + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): CurrentVersion = + CurrentVersion( + parameters, + version, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + } + + @JsonDeserialize(builder = DraftVersion.Builder::class) + @NoAutoDetect + class DraftVersion + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): AuthRuleParameters = parameters.getRequired("parameters") + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + fun version(): Long = version.getRequired("version") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): DraftVersion = apply { + if (!validated) { + parameters() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DraftVersion && + this.parameters == other.parameters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(draftVersion: DraftVersion) = apply { + this.parameters = draftVersion.parameters + this.version = draftVersion.version + additionalProperties(draftVersion.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = parameters(JsonField.of(parameters)) + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): DraftVersion = + DraftVersion( + parameters, + version, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + } + + class AuthRuleState + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleState && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = AuthRuleState(JsonField.of("ACTIVE")) + + @JvmField val INACTIVE = AuthRuleState(JsonField.of("INACTIVE")) + + @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + INACTIVE, + } + + enum class Value { + ACTIVE, + INACTIVE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw LithicInvalidDataException("Unknown AuthRuleState: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class AuthRuleType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CONDITIONAL_BLOCK = AuthRuleType(JsonField.of("CONDITIONAL_BLOCK")) + + @JvmField val VELOCITY_LIMIT = AuthRuleType(JsonField.of("VELOCITY_LIMIT")) + + @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) + } + + enum class Known { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + } + + enum class Value { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Value.VELOCITY_LIMIT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Known.VELOCITY_LIMIT + else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2CreateResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2CreateResponse.kt new file mode 100644 index 00000000..2a4283a2 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2CreateResponse.kt @@ -0,0 +1,2063 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = V2CreateResponse.Builder::class) +@NoAutoDetect +class V2CreateResponse +private constructor( + private val token: JsonField, + private val state: JsonField, + private val programLevel: JsonField, + private val cardTokens: JsonField>, + private val accountTokens: JsonField>, + private val type: JsonField, + private val currentVersion: JsonField, + private val draftVersion: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun token(): String = token.getRequired("token") + + /** The state of the Auth Rule */ + fun state(): AuthRuleState = state.getRequired("state") + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(): Boolean = programLevel.getRequired("program_level") + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(): List = cardTokens.getRequired("card_tokens") + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(): List = accountTokens.getRequired("account_tokens") + + /** The type of Auth Rule */ + fun type(): AuthRuleType = type.getRequired("type") + + fun currentVersion(): Optional = + Optional.ofNullable(currentVersion.getNullable("current_version")) + + fun draftVersion(): Optional = + Optional.ofNullable(draftVersion.getNullable("draft_version")) + + @JsonProperty("token") @ExcludeMissing fun _token() = token + + /** The state of the Auth Rule */ + @JsonProperty("state") @ExcludeMissing fun _state() = state + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + + /** The type of Auth Rule */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + + @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): V2CreateResponse = apply { + if (!validated) { + token() + state() + programLevel() + cardTokens() + accountTokens() + type() + currentVersion().map { it.validate() } + draftVersion().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V2CreateResponse && + this.token == other.token && + this.state == other.state && + this.programLevel == other.programLevel && + this.cardTokens == other.cardTokens && + this.accountTokens == other.accountTokens && + this.type == other.type && + this.currentVersion == other.currentVersion && + this.draftVersion == other.draftVersion && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + token, + state, + programLevel, + cardTokens, + accountTokens, + type, + currentVersion, + draftVersion, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "V2CreateResponse{token=$token, state=$state, programLevel=$programLevel, cardTokens=$cardTokens, accountTokens=$accountTokens, type=$type, currentVersion=$currentVersion, draftVersion=$draftVersion, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var token: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var programLevel: JsonField = JsonMissing.of() + private var cardTokens: JsonField> = JsonMissing.of() + private var accountTokens: JsonField> = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var currentVersion: JsonField = JsonMissing.of() + private var draftVersion: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v2CreateResponse: V2CreateResponse) = apply { + this.token = v2CreateResponse.token + this.state = v2CreateResponse.state + this.programLevel = v2CreateResponse.programLevel + this.cardTokens = v2CreateResponse.cardTokens + this.accountTokens = v2CreateResponse.accountTokens + this.type = v2CreateResponse.type + this.currentVersion = v2CreateResponse.currentVersion + this.draftVersion = v2CreateResponse.draftVersion + additionalProperties(v2CreateResponse.additionalProperties) + } + + fun token(token: String) = token(JsonField.of(token)) + + @JsonProperty("token") + @ExcludeMissing + fun token(token: JsonField) = apply { this.token = token } + + /** The state of the Auth Rule */ + fun state(state: AuthRuleState) = state(JsonField.of(state)) + + /** The state of the Auth Rule */ + @JsonProperty("state") + @ExcludeMissing + fun state(state: JsonField) = apply { this.state = state } + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") + @ExcludeMissing + fun programLevel(programLevel: JsonField) = apply { + this.programLevel = programLevel + } + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") + @ExcludeMissing + fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(accountTokens: List) = accountTokens(JsonField.of(accountTokens)) + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") + @ExcludeMissing + fun accountTokens(accountTokens: JsonField>) = apply { + this.accountTokens = accountTokens + } + + /** The type of Auth Rule */ + fun type(type: AuthRuleType) = type(JsonField.of(type)) + + /** The type of Auth Rule */ + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun currentVersion(currentVersion: CurrentVersion) = + currentVersion(JsonField.of(currentVersion)) + + @JsonProperty("current_version") + @ExcludeMissing + fun currentVersion(currentVersion: JsonField) = apply { + this.currentVersion = currentVersion + } + + fun draftVersion(draftVersion: DraftVersion) = draftVersion(JsonField.of(draftVersion)) + + @JsonProperty("draft_version") + @ExcludeMissing + fun draftVersion(draftVersion: JsonField) = apply { + this.draftVersion = draftVersion + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): V2CreateResponse = + V2CreateResponse( + token, + state, + programLevel, + cardTokens.map { it.toUnmodifiable() }, + accountTokens.map { it.toUnmodifiable() }, + type, + currentVersion, + draftVersion, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = CurrentVersion.Builder::class) + @NoAutoDetect + class CurrentVersion + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): AuthRuleParameters = parameters.getRequired("parameters") + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + fun version(): Long = version.getRequired("version") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CurrentVersion = apply { + if (!validated) { + parameters() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentVersion && + this.parameters == other.parameters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CurrentVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(currentVersion: CurrentVersion) = apply { + this.parameters = currentVersion.parameters + this.version = currentVersion.version + additionalProperties(currentVersion.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = parameters(JsonField.of(parameters)) + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): CurrentVersion = + CurrentVersion( + parameters, + version, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + } + + @JsonDeserialize(builder = DraftVersion.Builder::class) + @NoAutoDetect + class DraftVersion + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): AuthRuleParameters = parameters.getRequired("parameters") + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + fun version(): Long = version.getRequired("version") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): DraftVersion = apply { + if (!validated) { + parameters() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DraftVersion && + this.parameters == other.parameters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(draftVersion: DraftVersion) = apply { + this.parameters = draftVersion.parameters + this.version = draftVersion.version + additionalProperties(draftVersion.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = parameters(JsonField.of(parameters)) + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): DraftVersion = + DraftVersion( + parameters, + version, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + } + + class AuthRuleState + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleState && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = AuthRuleState(JsonField.of("ACTIVE")) + + @JvmField val INACTIVE = AuthRuleState(JsonField.of("INACTIVE")) + + @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + INACTIVE, + } + + enum class Value { + ACTIVE, + INACTIVE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw LithicInvalidDataException("Unknown AuthRuleState: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class AuthRuleType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CONDITIONAL_BLOCK = AuthRuleType(JsonField.of("CONDITIONAL_BLOCK")) + + @JvmField val VELOCITY_LIMIT = AuthRuleType(JsonField.of("VELOCITY_LIMIT")) + + @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) + } + + enum class Known { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + } + + enum class Value { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Value.VELOCITY_LIMIT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Known.VELOCITY_LIMIT + else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2DraftResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2DraftResponse.kt new file mode 100644 index 00000000..41616909 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2DraftResponse.kt @@ -0,0 +1,2063 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = V2DraftResponse.Builder::class) +@NoAutoDetect +class V2DraftResponse +private constructor( + private val token: JsonField, + private val state: JsonField, + private val programLevel: JsonField, + private val cardTokens: JsonField>, + private val accountTokens: JsonField>, + private val type: JsonField, + private val currentVersion: JsonField, + private val draftVersion: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun token(): String = token.getRequired("token") + + /** The state of the Auth Rule */ + fun state(): AuthRuleState = state.getRequired("state") + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(): Boolean = programLevel.getRequired("program_level") + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(): List = cardTokens.getRequired("card_tokens") + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(): List = accountTokens.getRequired("account_tokens") + + /** The type of Auth Rule */ + fun type(): AuthRuleType = type.getRequired("type") + + fun currentVersion(): Optional = + Optional.ofNullable(currentVersion.getNullable("current_version")) + + fun draftVersion(): Optional = + Optional.ofNullable(draftVersion.getNullable("draft_version")) + + @JsonProperty("token") @ExcludeMissing fun _token() = token + + /** The state of the Auth Rule */ + @JsonProperty("state") @ExcludeMissing fun _state() = state + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + + /** The type of Auth Rule */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + + @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): V2DraftResponse = apply { + if (!validated) { + token() + state() + programLevel() + cardTokens() + accountTokens() + type() + currentVersion().map { it.validate() } + draftVersion().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V2DraftResponse && + this.token == other.token && + this.state == other.state && + this.programLevel == other.programLevel && + this.cardTokens == other.cardTokens && + this.accountTokens == other.accountTokens && + this.type == other.type && + this.currentVersion == other.currentVersion && + this.draftVersion == other.draftVersion && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + token, + state, + programLevel, + cardTokens, + accountTokens, + type, + currentVersion, + draftVersion, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "V2DraftResponse{token=$token, state=$state, programLevel=$programLevel, cardTokens=$cardTokens, accountTokens=$accountTokens, type=$type, currentVersion=$currentVersion, draftVersion=$draftVersion, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var token: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var programLevel: JsonField = JsonMissing.of() + private var cardTokens: JsonField> = JsonMissing.of() + private var accountTokens: JsonField> = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var currentVersion: JsonField = JsonMissing.of() + private var draftVersion: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v2DraftResponse: V2DraftResponse) = apply { + this.token = v2DraftResponse.token + this.state = v2DraftResponse.state + this.programLevel = v2DraftResponse.programLevel + this.cardTokens = v2DraftResponse.cardTokens + this.accountTokens = v2DraftResponse.accountTokens + this.type = v2DraftResponse.type + this.currentVersion = v2DraftResponse.currentVersion + this.draftVersion = v2DraftResponse.draftVersion + additionalProperties(v2DraftResponse.additionalProperties) + } + + fun token(token: String) = token(JsonField.of(token)) + + @JsonProperty("token") + @ExcludeMissing + fun token(token: JsonField) = apply { this.token = token } + + /** The state of the Auth Rule */ + fun state(state: AuthRuleState) = state(JsonField.of(state)) + + /** The state of the Auth Rule */ + @JsonProperty("state") + @ExcludeMissing + fun state(state: JsonField) = apply { this.state = state } + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") + @ExcludeMissing + fun programLevel(programLevel: JsonField) = apply { + this.programLevel = programLevel + } + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") + @ExcludeMissing + fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(accountTokens: List) = accountTokens(JsonField.of(accountTokens)) + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") + @ExcludeMissing + fun accountTokens(accountTokens: JsonField>) = apply { + this.accountTokens = accountTokens + } + + /** The type of Auth Rule */ + fun type(type: AuthRuleType) = type(JsonField.of(type)) + + /** The type of Auth Rule */ + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun currentVersion(currentVersion: CurrentVersion) = + currentVersion(JsonField.of(currentVersion)) + + @JsonProperty("current_version") + @ExcludeMissing + fun currentVersion(currentVersion: JsonField) = apply { + this.currentVersion = currentVersion + } + + fun draftVersion(draftVersion: DraftVersion) = draftVersion(JsonField.of(draftVersion)) + + @JsonProperty("draft_version") + @ExcludeMissing + fun draftVersion(draftVersion: JsonField) = apply { + this.draftVersion = draftVersion + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): V2DraftResponse = + V2DraftResponse( + token, + state, + programLevel, + cardTokens.map { it.toUnmodifiable() }, + accountTokens.map { it.toUnmodifiable() }, + type, + currentVersion, + draftVersion, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = CurrentVersion.Builder::class) + @NoAutoDetect + class CurrentVersion + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): AuthRuleParameters = parameters.getRequired("parameters") + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + fun version(): Long = version.getRequired("version") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CurrentVersion = apply { + if (!validated) { + parameters() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentVersion && + this.parameters == other.parameters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CurrentVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(currentVersion: CurrentVersion) = apply { + this.parameters = currentVersion.parameters + this.version = currentVersion.version + additionalProperties(currentVersion.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = parameters(JsonField.of(parameters)) + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): CurrentVersion = + CurrentVersion( + parameters, + version, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + } + + @JsonDeserialize(builder = DraftVersion.Builder::class) + @NoAutoDetect + class DraftVersion + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): AuthRuleParameters = parameters.getRequired("parameters") + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + fun version(): Long = version.getRequired("version") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): DraftVersion = apply { + if (!validated) { + parameters() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DraftVersion && + this.parameters == other.parameters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(draftVersion: DraftVersion) = apply { + this.parameters = draftVersion.parameters + this.version = draftVersion.version + additionalProperties(draftVersion.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = parameters(JsonField.of(parameters)) + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): DraftVersion = + DraftVersion( + parameters, + version, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + } + + class AuthRuleState + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleState && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = AuthRuleState(JsonField.of("ACTIVE")) + + @JvmField val INACTIVE = AuthRuleState(JsonField.of("INACTIVE")) + + @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + INACTIVE, + } + + enum class Value { + ACTIVE, + INACTIVE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw LithicInvalidDataException("Unknown AuthRuleState: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class AuthRuleType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CONDITIONAL_BLOCK = AuthRuleType(JsonField.of("CONDITIONAL_BLOCK")) + + @JvmField val VELOCITY_LIMIT = AuthRuleType(JsonField.of("VELOCITY_LIMIT")) + + @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) + } + + enum class Known { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + } + + enum class Value { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Value.VELOCITY_LIMIT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Known.VELOCITY_LIMIT + else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ListResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ListResponse.kt new file mode 100644 index 00000000..558f7603 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ListResponse.kt @@ -0,0 +1,2063 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = V2ListResponse.Builder::class) +@NoAutoDetect +class V2ListResponse +private constructor( + private val token: JsonField, + private val state: JsonField, + private val programLevel: JsonField, + private val cardTokens: JsonField>, + private val accountTokens: JsonField>, + private val type: JsonField, + private val currentVersion: JsonField, + private val draftVersion: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun token(): String = token.getRequired("token") + + /** The state of the Auth Rule */ + fun state(): AuthRuleState = state.getRequired("state") + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(): Boolean = programLevel.getRequired("program_level") + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(): List = cardTokens.getRequired("card_tokens") + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(): List = accountTokens.getRequired("account_tokens") + + /** The type of Auth Rule */ + fun type(): AuthRuleType = type.getRequired("type") + + fun currentVersion(): Optional = + Optional.ofNullable(currentVersion.getNullable("current_version")) + + fun draftVersion(): Optional = + Optional.ofNullable(draftVersion.getNullable("draft_version")) + + @JsonProperty("token") @ExcludeMissing fun _token() = token + + /** The state of the Auth Rule */ + @JsonProperty("state") @ExcludeMissing fun _state() = state + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + + /** The type of Auth Rule */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + + @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): V2ListResponse = apply { + if (!validated) { + token() + state() + programLevel() + cardTokens() + accountTokens() + type() + currentVersion().map { it.validate() } + draftVersion().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V2ListResponse && + this.token == other.token && + this.state == other.state && + this.programLevel == other.programLevel && + this.cardTokens == other.cardTokens && + this.accountTokens == other.accountTokens && + this.type == other.type && + this.currentVersion == other.currentVersion && + this.draftVersion == other.draftVersion && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + token, + state, + programLevel, + cardTokens, + accountTokens, + type, + currentVersion, + draftVersion, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "V2ListResponse{token=$token, state=$state, programLevel=$programLevel, cardTokens=$cardTokens, accountTokens=$accountTokens, type=$type, currentVersion=$currentVersion, draftVersion=$draftVersion, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var token: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var programLevel: JsonField = JsonMissing.of() + private var cardTokens: JsonField> = JsonMissing.of() + private var accountTokens: JsonField> = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var currentVersion: JsonField = JsonMissing.of() + private var draftVersion: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v2ListResponse: V2ListResponse) = apply { + this.token = v2ListResponse.token + this.state = v2ListResponse.state + this.programLevel = v2ListResponse.programLevel + this.cardTokens = v2ListResponse.cardTokens + this.accountTokens = v2ListResponse.accountTokens + this.type = v2ListResponse.type + this.currentVersion = v2ListResponse.currentVersion + this.draftVersion = v2ListResponse.draftVersion + additionalProperties(v2ListResponse.additionalProperties) + } + + fun token(token: String) = token(JsonField.of(token)) + + @JsonProperty("token") + @ExcludeMissing + fun token(token: JsonField) = apply { this.token = token } + + /** The state of the Auth Rule */ + fun state(state: AuthRuleState) = state(JsonField.of(state)) + + /** The state of the Auth Rule */ + @JsonProperty("state") + @ExcludeMissing + fun state(state: JsonField) = apply { this.state = state } + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") + @ExcludeMissing + fun programLevel(programLevel: JsonField) = apply { + this.programLevel = programLevel + } + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") + @ExcludeMissing + fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(accountTokens: List) = accountTokens(JsonField.of(accountTokens)) + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") + @ExcludeMissing + fun accountTokens(accountTokens: JsonField>) = apply { + this.accountTokens = accountTokens + } + + /** The type of Auth Rule */ + fun type(type: AuthRuleType) = type(JsonField.of(type)) + + /** The type of Auth Rule */ + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun currentVersion(currentVersion: CurrentVersion) = + currentVersion(JsonField.of(currentVersion)) + + @JsonProperty("current_version") + @ExcludeMissing + fun currentVersion(currentVersion: JsonField) = apply { + this.currentVersion = currentVersion + } + + fun draftVersion(draftVersion: DraftVersion) = draftVersion(JsonField.of(draftVersion)) + + @JsonProperty("draft_version") + @ExcludeMissing + fun draftVersion(draftVersion: JsonField) = apply { + this.draftVersion = draftVersion + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): V2ListResponse = + V2ListResponse( + token, + state, + programLevel, + cardTokens.map { it.toUnmodifiable() }, + accountTokens.map { it.toUnmodifiable() }, + type, + currentVersion, + draftVersion, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = CurrentVersion.Builder::class) + @NoAutoDetect + class CurrentVersion + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): AuthRuleParameters = parameters.getRequired("parameters") + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + fun version(): Long = version.getRequired("version") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CurrentVersion = apply { + if (!validated) { + parameters() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentVersion && + this.parameters == other.parameters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CurrentVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(currentVersion: CurrentVersion) = apply { + this.parameters = currentVersion.parameters + this.version = currentVersion.version + additionalProperties(currentVersion.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = parameters(JsonField.of(parameters)) + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): CurrentVersion = + CurrentVersion( + parameters, + version, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + } + + @JsonDeserialize(builder = DraftVersion.Builder::class) + @NoAutoDetect + class DraftVersion + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): AuthRuleParameters = parameters.getRequired("parameters") + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + fun version(): Long = version.getRequired("version") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): DraftVersion = apply { + if (!validated) { + parameters() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DraftVersion && + this.parameters == other.parameters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(draftVersion: DraftVersion) = apply { + this.parameters = draftVersion.parameters + this.version = draftVersion.version + additionalProperties(draftVersion.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = parameters(JsonField.of(parameters)) + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): DraftVersion = + DraftVersion( + parameters, + version, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + } + + class AuthRuleState + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleState && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = AuthRuleState(JsonField.of("ACTIVE")) + + @JvmField val INACTIVE = AuthRuleState(JsonField.of("INACTIVE")) + + @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + INACTIVE, + } + + enum class Value { + ACTIVE, + INACTIVE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw LithicInvalidDataException("Unknown AuthRuleState: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class AuthRuleType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CONDITIONAL_BLOCK = AuthRuleType(JsonField.of("CONDITIONAL_BLOCK")) + + @JvmField val VELOCITY_LIMIT = AuthRuleType(JsonField.of("VELOCITY_LIMIT")) + + @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) + } + + enum class Known { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + } + + enum class Value { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Value.VELOCITY_LIMIT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Known.VELOCITY_LIMIT + else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2PromoteResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2PromoteResponse.kt new file mode 100644 index 00000000..4be372f9 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2PromoteResponse.kt @@ -0,0 +1,2063 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = V2PromoteResponse.Builder::class) +@NoAutoDetect +class V2PromoteResponse +private constructor( + private val token: JsonField, + private val state: JsonField, + private val programLevel: JsonField, + private val cardTokens: JsonField>, + private val accountTokens: JsonField>, + private val type: JsonField, + private val currentVersion: JsonField, + private val draftVersion: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun token(): String = token.getRequired("token") + + /** The state of the Auth Rule */ + fun state(): AuthRuleState = state.getRequired("state") + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(): Boolean = programLevel.getRequired("program_level") + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(): List = cardTokens.getRequired("card_tokens") + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(): List = accountTokens.getRequired("account_tokens") + + /** The type of Auth Rule */ + fun type(): AuthRuleType = type.getRequired("type") + + fun currentVersion(): Optional = + Optional.ofNullable(currentVersion.getNullable("current_version")) + + fun draftVersion(): Optional = + Optional.ofNullable(draftVersion.getNullable("draft_version")) + + @JsonProperty("token") @ExcludeMissing fun _token() = token + + /** The state of the Auth Rule */ + @JsonProperty("state") @ExcludeMissing fun _state() = state + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + + /** The type of Auth Rule */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + + @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): V2PromoteResponse = apply { + if (!validated) { + token() + state() + programLevel() + cardTokens() + accountTokens() + type() + currentVersion().map { it.validate() } + draftVersion().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V2PromoteResponse && + this.token == other.token && + this.state == other.state && + this.programLevel == other.programLevel && + this.cardTokens == other.cardTokens && + this.accountTokens == other.accountTokens && + this.type == other.type && + this.currentVersion == other.currentVersion && + this.draftVersion == other.draftVersion && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + token, + state, + programLevel, + cardTokens, + accountTokens, + type, + currentVersion, + draftVersion, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "V2PromoteResponse{token=$token, state=$state, programLevel=$programLevel, cardTokens=$cardTokens, accountTokens=$accountTokens, type=$type, currentVersion=$currentVersion, draftVersion=$draftVersion, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var token: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var programLevel: JsonField = JsonMissing.of() + private var cardTokens: JsonField> = JsonMissing.of() + private var accountTokens: JsonField> = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var currentVersion: JsonField = JsonMissing.of() + private var draftVersion: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v2PromoteResponse: V2PromoteResponse) = apply { + this.token = v2PromoteResponse.token + this.state = v2PromoteResponse.state + this.programLevel = v2PromoteResponse.programLevel + this.cardTokens = v2PromoteResponse.cardTokens + this.accountTokens = v2PromoteResponse.accountTokens + this.type = v2PromoteResponse.type + this.currentVersion = v2PromoteResponse.currentVersion + this.draftVersion = v2PromoteResponse.draftVersion + additionalProperties(v2PromoteResponse.additionalProperties) + } + + fun token(token: String) = token(JsonField.of(token)) + + @JsonProperty("token") + @ExcludeMissing + fun token(token: JsonField) = apply { this.token = token } + + /** The state of the Auth Rule */ + fun state(state: AuthRuleState) = state(JsonField.of(state)) + + /** The state of the Auth Rule */ + @JsonProperty("state") + @ExcludeMissing + fun state(state: JsonField) = apply { this.state = state } + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") + @ExcludeMissing + fun programLevel(programLevel: JsonField) = apply { + this.programLevel = programLevel + } + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") + @ExcludeMissing + fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(accountTokens: List) = accountTokens(JsonField.of(accountTokens)) + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") + @ExcludeMissing + fun accountTokens(accountTokens: JsonField>) = apply { + this.accountTokens = accountTokens + } + + /** The type of Auth Rule */ + fun type(type: AuthRuleType) = type(JsonField.of(type)) + + /** The type of Auth Rule */ + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun currentVersion(currentVersion: CurrentVersion) = + currentVersion(JsonField.of(currentVersion)) + + @JsonProperty("current_version") + @ExcludeMissing + fun currentVersion(currentVersion: JsonField) = apply { + this.currentVersion = currentVersion + } + + fun draftVersion(draftVersion: DraftVersion) = draftVersion(JsonField.of(draftVersion)) + + @JsonProperty("draft_version") + @ExcludeMissing + fun draftVersion(draftVersion: JsonField) = apply { + this.draftVersion = draftVersion + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): V2PromoteResponse = + V2PromoteResponse( + token, + state, + programLevel, + cardTokens.map { it.toUnmodifiable() }, + accountTokens.map { it.toUnmodifiable() }, + type, + currentVersion, + draftVersion, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = CurrentVersion.Builder::class) + @NoAutoDetect + class CurrentVersion + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): AuthRuleParameters = parameters.getRequired("parameters") + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + fun version(): Long = version.getRequired("version") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CurrentVersion = apply { + if (!validated) { + parameters() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentVersion && + this.parameters == other.parameters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CurrentVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(currentVersion: CurrentVersion) = apply { + this.parameters = currentVersion.parameters + this.version = currentVersion.version + additionalProperties(currentVersion.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = parameters(JsonField.of(parameters)) + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): CurrentVersion = + CurrentVersion( + parameters, + version, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + } + + @JsonDeserialize(builder = DraftVersion.Builder::class) + @NoAutoDetect + class DraftVersion + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): AuthRuleParameters = parameters.getRequired("parameters") + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + fun version(): Long = version.getRequired("version") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): DraftVersion = apply { + if (!validated) { + parameters() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DraftVersion && + this.parameters == other.parameters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(draftVersion: DraftVersion) = apply { + this.parameters = draftVersion.parameters + this.version = draftVersion.version + additionalProperties(draftVersion.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = parameters(JsonField.of(parameters)) + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): DraftVersion = + DraftVersion( + parameters, + version, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + } + + class AuthRuleState + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleState && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = AuthRuleState(JsonField.of("ACTIVE")) + + @JvmField val INACTIVE = AuthRuleState(JsonField.of("INACTIVE")) + + @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + INACTIVE, + } + + enum class Value { + ACTIVE, + INACTIVE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw LithicInvalidDataException("Unknown AuthRuleState: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class AuthRuleType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CONDITIONAL_BLOCK = AuthRuleType(JsonField.of("CONDITIONAL_BLOCK")) + + @JvmField val VELOCITY_LIMIT = AuthRuleType(JsonField.of("VELOCITY_LIMIT")) + + @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) + } + + enum class Known { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + } + + enum class Value { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Value.VELOCITY_LIMIT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Known.VELOCITY_LIMIT + else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ReportResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ReportResponse.kt new file mode 100644 index 00000000..ff8faeff --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ReportResponse.kt @@ -0,0 +1,107 @@ +// 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.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toUnmodifiable +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = V2ReportResponse.Builder::class) +@NoAutoDetect +class V2ReportResponse +private constructor( + private val reportToken: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun reportToken(): Optional = + Optional.ofNullable(reportToken.getNullable("report_token")) + + @JsonProperty("report_token") @ExcludeMissing fun _reportToken() = reportToken + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): V2ReportResponse = apply { + if (!validated) { + reportToken() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V2ReportResponse && + this.reportToken == other.reportToken && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(reportToken, additionalProperties) + } + return hashCode + } + + override fun toString() = + "V2ReportResponse{reportToken=$reportToken, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var reportToken: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v2ReportResponse: V2ReportResponse) = apply { + this.reportToken = v2ReportResponse.reportToken + additionalProperties(v2ReportResponse.additionalProperties) + } + + fun reportToken(reportToken: String) = reportToken(JsonField.of(reportToken)) + + @JsonProperty("report_token") + @ExcludeMissing + fun reportToken(reportToken: JsonField) = apply { this.reportToken = reportToken } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): V2ReportResponse = + V2ReportResponse(reportToken, additionalProperties.toUnmodifiable()) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2RetrieveResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2RetrieveResponse.kt new file mode 100644 index 00000000..0a075aee --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2RetrieveResponse.kt @@ -0,0 +1,2063 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = V2RetrieveResponse.Builder::class) +@NoAutoDetect +class V2RetrieveResponse +private constructor( + private val token: JsonField, + private val state: JsonField, + private val programLevel: JsonField, + private val cardTokens: JsonField>, + private val accountTokens: JsonField>, + private val type: JsonField, + private val currentVersion: JsonField, + private val draftVersion: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun token(): String = token.getRequired("token") + + /** The state of the Auth Rule */ + fun state(): AuthRuleState = state.getRequired("state") + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(): Boolean = programLevel.getRequired("program_level") + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(): List = cardTokens.getRequired("card_tokens") + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(): List = accountTokens.getRequired("account_tokens") + + /** The type of Auth Rule */ + fun type(): AuthRuleType = type.getRequired("type") + + fun currentVersion(): Optional = + Optional.ofNullable(currentVersion.getNullable("current_version")) + + fun draftVersion(): Optional = + Optional.ofNullable(draftVersion.getNullable("draft_version")) + + @JsonProperty("token") @ExcludeMissing fun _token() = token + + /** The state of the Auth Rule */ + @JsonProperty("state") @ExcludeMissing fun _state() = state + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + + /** The type of Auth Rule */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + + @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): V2RetrieveResponse = apply { + if (!validated) { + token() + state() + programLevel() + cardTokens() + accountTokens() + type() + currentVersion().map { it.validate() } + draftVersion().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V2RetrieveResponse && + this.token == other.token && + this.state == other.state && + this.programLevel == other.programLevel && + this.cardTokens == other.cardTokens && + this.accountTokens == other.accountTokens && + this.type == other.type && + this.currentVersion == other.currentVersion && + this.draftVersion == other.draftVersion && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + token, + state, + programLevel, + cardTokens, + accountTokens, + type, + currentVersion, + draftVersion, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "V2RetrieveResponse{token=$token, state=$state, programLevel=$programLevel, cardTokens=$cardTokens, accountTokens=$accountTokens, type=$type, currentVersion=$currentVersion, draftVersion=$draftVersion, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var token: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var programLevel: JsonField = JsonMissing.of() + private var cardTokens: JsonField> = JsonMissing.of() + private var accountTokens: JsonField> = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var currentVersion: JsonField = JsonMissing.of() + private var draftVersion: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v2RetrieveResponse: V2RetrieveResponse) = apply { + this.token = v2RetrieveResponse.token + this.state = v2RetrieveResponse.state + this.programLevel = v2RetrieveResponse.programLevel + this.cardTokens = v2RetrieveResponse.cardTokens + this.accountTokens = v2RetrieveResponse.accountTokens + this.type = v2RetrieveResponse.type + this.currentVersion = v2RetrieveResponse.currentVersion + this.draftVersion = v2RetrieveResponse.draftVersion + additionalProperties(v2RetrieveResponse.additionalProperties) + } + + fun token(token: String) = token(JsonField.of(token)) + + @JsonProperty("token") + @ExcludeMissing + fun token(token: JsonField) = apply { this.token = token } + + /** The state of the Auth Rule */ + fun state(state: AuthRuleState) = state(JsonField.of(state)) + + /** The state of the Auth Rule */ + @JsonProperty("state") + @ExcludeMissing + fun state(state: JsonField) = apply { this.state = state } + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") + @ExcludeMissing + fun programLevel(programLevel: JsonField) = apply { + this.programLevel = programLevel + } + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") + @ExcludeMissing + fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(accountTokens: List) = accountTokens(JsonField.of(accountTokens)) + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") + @ExcludeMissing + fun accountTokens(accountTokens: JsonField>) = apply { + this.accountTokens = accountTokens + } + + /** The type of Auth Rule */ + fun type(type: AuthRuleType) = type(JsonField.of(type)) + + /** The type of Auth Rule */ + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun currentVersion(currentVersion: CurrentVersion) = + currentVersion(JsonField.of(currentVersion)) + + @JsonProperty("current_version") + @ExcludeMissing + fun currentVersion(currentVersion: JsonField) = apply { + this.currentVersion = currentVersion + } + + fun draftVersion(draftVersion: DraftVersion) = draftVersion(JsonField.of(draftVersion)) + + @JsonProperty("draft_version") + @ExcludeMissing + fun draftVersion(draftVersion: JsonField) = apply { + this.draftVersion = draftVersion + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): V2RetrieveResponse = + V2RetrieveResponse( + token, + state, + programLevel, + cardTokens.map { it.toUnmodifiable() }, + accountTokens.map { it.toUnmodifiable() }, + type, + currentVersion, + draftVersion, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = CurrentVersion.Builder::class) + @NoAutoDetect + class CurrentVersion + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): AuthRuleParameters = parameters.getRequired("parameters") + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + fun version(): Long = version.getRequired("version") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CurrentVersion = apply { + if (!validated) { + parameters() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentVersion && + this.parameters == other.parameters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CurrentVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(currentVersion: CurrentVersion) = apply { + this.parameters = currentVersion.parameters + this.version = currentVersion.version + additionalProperties(currentVersion.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = parameters(JsonField.of(parameters)) + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): CurrentVersion = + CurrentVersion( + parameters, + version, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + } + + @JsonDeserialize(builder = DraftVersion.Builder::class) + @NoAutoDetect + class DraftVersion + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): AuthRuleParameters = parameters.getRequired("parameters") + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + fun version(): Long = version.getRequired("version") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): DraftVersion = apply { + if (!validated) { + parameters() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DraftVersion && + this.parameters == other.parameters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(draftVersion: DraftVersion) = apply { + this.parameters = draftVersion.parameters + this.version = draftVersion.version + additionalProperties(draftVersion.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = parameters(JsonField.of(parameters)) + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): DraftVersion = + DraftVersion( + parameters, + version, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + } + + class AuthRuleState + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleState && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = AuthRuleState(JsonField.of("ACTIVE")) + + @JvmField val INACTIVE = AuthRuleState(JsonField.of("INACTIVE")) + + @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + INACTIVE, + } + + enum class Value { + ACTIVE, + INACTIVE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw LithicInvalidDataException("Unknown AuthRuleState: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class AuthRuleType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CONDITIONAL_BLOCK = AuthRuleType(JsonField.of("CONDITIONAL_BLOCK")) + + @JvmField val VELOCITY_LIMIT = AuthRuleType(JsonField.of("VELOCITY_LIMIT")) + + @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) + } + + enum class Known { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + } + + enum class Value { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Value.VELOCITY_LIMIT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Known.VELOCITY_LIMIT + else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2UpdateResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2UpdateResponse.kt new file mode 100644 index 00000000..7b7d2044 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2UpdateResponse.kt @@ -0,0 +1,2063 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = V2UpdateResponse.Builder::class) +@NoAutoDetect +class V2UpdateResponse +private constructor( + private val token: JsonField, + private val state: JsonField, + private val programLevel: JsonField, + private val cardTokens: JsonField>, + private val accountTokens: JsonField>, + private val type: JsonField, + private val currentVersion: JsonField, + private val draftVersion: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun token(): String = token.getRequired("token") + + /** The state of the Auth Rule */ + fun state(): AuthRuleState = state.getRequired("state") + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(): Boolean = programLevel.getRequired("program_level") + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(): List = cardTokens.getRequired("card_tokens") + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(): List = accountTokens.getRequired("account_tokens") + + /** The type of Auth Rule */ + fun type(): AuthRuleType = type.getRequired("type") + + fun currentVersion(): Optional = + Optional.ofNullable(currentVersion.getNullable("current_version")) + + fun draftVersion(): Optional = + Optional.ofNullable(draftVersion.getNullable("draft_version")) + + @JsonProperty("token") @ExcludeMissing fun _token() = token + + /** The state of the Auth Rule */ + @JsonProperty("state") @ExcludeMissing fun _state() = state + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") @ExcludeMissing fun _programLevel() = programLevel + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") @ExcludeMissing fun _cardTokens() = cardTokens + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") @ExcludeMissing fun _accountTokens() = accountTokens + + /** The type of Auth Rule */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + + @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): V2UpdateResponse = apply { + if (!validated) { + token() + state() + programLevel() + cardTokens() + accountTokens() + type() + currentVersion().map { it.validate() } + draftVersion().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V2UpdateResponse && + this.token == other.token && + this.state == other.state && + this.programLevel == other.programLevel && + this.cardTokens == other.cardTokens && + this.accountTokens == other.accountTokens && + this.type == other.type && + this.currentVersion == other.currentVersion && + this.draftVersion == other.draftVersion && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + token, + state, + programLevel, + cardTokens, + accountTokens, + type, + currentVersion, + draftVersion, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "V2UpdateResponse{token=$token, state=$state, programLevel=$programLevel, cardTokens=$cardTokens, accountTokens=$accountTokens, type=$type, currentVersion=$currentVersion, draftVersion=$draftVersion, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var token: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var programLevel: JsonField = JsonMissing.of() + private var cardTokens: JsonField> = JsonMissing.of() + private var accountTokens: JsonField> = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var currentVersion: JsonField = JsonMissing.of() + private var draftVersion: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v2UpdateResponse: V2UpdateResponse) = apply { + this.token = v2UpdateResponse.token + this.state = v2UpdateResponse.state + this.programLevel = v2UpdateResponse.programLevel + this.cardTokens = v2UpdateResponse.cardTokens + this.accountTokens = v2UpdateResponse.accountTokens + this.type = v2UpdateResponse.type + this.currentVersion = v2UpdateResponse.currentVersion + this.draftVersion = v2UpdateResponse.draftVersion + additionalProperties(v2UpdateResponse.additionalProperties) + } + + fun token(token: String) = token(JsonField.of(token)) + + @JsonProperty("token") + @ExcludeMissing + fun token(token: JsonField) = apply { this.token = token } + + /** The state of the Auth Rule */ + fun state(state: AuthRuleState) = state(JsonField.of(state)) + + /** The state of the Auth Rule */ + @JsonProperty("state") + @ExcludeMissing + fun state(state: JsonField) = apply { this.state = state } + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) + + /** Whether the Auth Rule applies to all authorizations on the card program. */ + @JsonProperty("program_level") + @ExcludeMissing + fun programLevel(programLevel: JsonField) = apply { + this.programLevel = programLevel + } + + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) + + /** Card tokens to which the Auth Rule applies. */ + @JsonProperty("card_tokens") + @ExcludeMissing + fun cardTokens(cardTokens: JsonField>) = apply { this.cardTokens = cardTokens } + + /** Account tokens to which the Auth Rule applies. */ + fun accountTokens(accountTokens: List) = accountTokens(JsonField.of(accountTokens)) + + /** Account tokens to which the Auth Rule applies. */ + @JsonProperty("account_tokens") + @ExcludeMissing + fun accountTokens(accountTokens: JsonField>) = apply { + this.accountTokens = accountTokens + } + + /** The type of Auth Rule */ + fun type(type: AuthRuleType) = type(JsonField.of(type)) + + /** The type of Auth Rule */ + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + fun currentVersion(currentVersion: CurrentVersion) = + currentVersion(JsonField.of(currentVersion)) + + @JsonProperty("current_version") + @ExcludeMissing + fun currentVersion(currentVersion: JsonField) = apply { + this.currentVersion = currentVersion + } + + fun draftVersion(draftVersion: DraftVersion) = draftVersion(JsonField.of(draftVersion)) + + @JsonProperty("draft_version") + @ExcludeMissing + fun draftVersion(draftVersion: JsonField) = apply { + this.draftVersion = draftVersion + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): V2UpdateResponse = + V2UpdateResponse( + token, + state, + programLevel, + cardTokens.map { it.toUnmodifiable() }, + accountTokens.map { it.toUnmodifiable() }, + type, + currentVersion, + draftVersion, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = CurrentVersion.Builder::class) + @NoAutoDetect + class CurrentVersion + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): AuthRuleParameters = parameters.getRequired("parameters") + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + fun version(): Long = version.getRequired("version") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CurrentVersion = apply { + if (!validated) { + parameters() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentVersion && + this.parameters == other.parameters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CurrentVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(currentVersion: CurrentVersion) = apply { + this.parameters = currentVersion.parameters + this.version = currentVersion.version + additionalProperties(currentVersion.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = parameters(JsonField.of(parameters)) + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): CurrentVersion = + CurrentVersion( + parameters, + version, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + } + + @JsonDeserialize(builder = DraftVersion.Builder::class) + @NoAutoDetect + class DraftVersion + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Parameters for the current version of the Auth Rule */ + fun parameters(): AuthRuleParameters = parameters.getRequired("parameters") + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + fun version(): Long = version.getRequired("version") + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") @ExcludeMissing fun _parameters() = parameters + + /** The version of the rule, this is incremented whenever the rule's parameters change. */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): DraftVersion = apply { + if (!validated) { + parameters() + version() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DraftVersion && + this.parameters == other.parameters && + this.version == other.version && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + parameters, + version, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var parameters: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(draftVersion: DraftVersion) = apply { + this.parameters = draftVersion.parameters + this.version = draftVersion.version + additionalProperties(draftVersion.additionalProperties) + } + + /** Parameters for the current version of the Auth Rule */ + fun parameters(parameters: AuthRuleParameters) = parameters(JsonField.of(parameters)) + + /** Parameters for the current version of the Auth Rule */ + @JsonProperty("parameters") + @ExcludeMissing + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): DraftVersion = + DraftVersion( + parameters, + version, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = AuthRuleParameters.Deserializer::class) + @JsonSerialize(using = AuthRuleParameters.Serializer::class) + class AuthRuleParameters + private constructor( + private val conditionalBlockParameters: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun conditionalBlockParameters(): Optional = + Optional.ofNullable(conditionalBlockParameters) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun isConditionalBlockParameters(): Boolean = conditionalBlockParameters != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun asConditionalBlockParameters(): ConditionalBlockParameters = + conditionalBlockParameters.getOrThrow("conditionalBlockParameters") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + conditionalBlockParameters != null -> + visitor.visitConditionalBlockParameters(conditionalBlockParameters) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + else -> visitor.unknown(_json) + } + } + + fun validate(): AuthRuleParameters = apply { + if (!validated) { + if (conditionalBlockParameters == null && velocityLimitParams == null) { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $_json") + } + conditionalBlockParameters?.validate() + velocityLimitParams?.validate() + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleParameters && + this.conditionalBlockParameters == other.conditionalBlockParameters && + this.velocityLimitParams == other.velocityLimitParams + } + + override fun hashCode(): Int { + return Objects.hash(conditionalBlockParameters, velocityLimitParams) + } + + override fun toString(): String { + return when { + conditionalBlockParameters != null -> + "AuthRuleParameters{conditionalBlockParameters=$conditionalBlockParameters}" + velocityLimitParams != null -> + "AuthRuleParameters{velocityLimitParams=$velocityLimitParams}" + _json != null -> "AuthRuleParameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + + companion object { + + @JvmStatic + fun ofConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ) = AuthRuleParameters(conditionalBlockParameters = conditionalBlockParameters) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + AuthRuleParameters(velocityLimitParams = velocityLimitParams) + } + + interface Visitor { + + fun visitConditionalBlockParameters( + conditionalBlockParameters: ConditionalBlockParameters + ): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AuthRuleParameters: $json") + } + } + + class Deserializer : BaseDeserializer(AuthRuleParameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AuthRuleParameters { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return AuthRuleParameters(conditionalBlockParameters = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return AuthRuleParameters(velocityLimitParams = it, _json = json) + } + + return AuthRuleParameters(_json = json) + } + } + + class Serializer : BaseSerializer(AuthRuleParameters::class) { + + override fun serialize( + value: AuthRuleParameters, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.conditionalBlockParameters != null -> + generator.writeObject(value.conditionalBlockParameters) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AuthRuleParameters") + } + } + } + + @JsonDeserialize(builder = ConditionalBlockParameters.Builder::class) + @NoAutoDetect + class ConditionalBlockParameters + private constructor( + private val conditions: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun conditions(): List = conditions.getRequired("conditions") + + @JsonProperty("conditions") @ExcludeMissing fun _conditions() = conditions + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ConditionalBlockParameters = apply { + if (!validated) { + conditions().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConditionalBlockParameters && + this.conditions == other.conditions && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(conditions, additionalProperties) + } + return hashCode + } + + override fun toString() = + "ConditionalBlockParameters{conditions=$conditions, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var conditions: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(conditionalBlockParameters: ConditionalBlockParameters) = + apply { + this.conditions = conditionalBlockParameters.conditions + additionalProperties(conditionalBlockParameters.additionalProperties) + } + + fun conditions(conditions: List) = + conditions(JsonField.of(conditions)) + + @JsonProperty("conditions") + @ExcludeMissing + fun conditions(conditions: JsonField>) = apply { + this.conditions = conditions + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ConditionalBlockParameters = + ConditionalBlockParameters( + conditions.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } + + @JsonDeserialize(builder = Condition.Builder::class) + @NoAutoDetect + class Condition + private constructor( + private val attribute: JsonField, + private val operation: JsonField, + private val value: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The attribute to target */ + fun attribute(): Optional = + Optional.ofNullable(attribute.getNullable("attribute")) + + /** The operation to apply to the attribute */ + fun operation(): Optional = + Optional.ofNullable(operation.getNullable("operation")) + + fun value(): Optional = Optional.ofNullable(value.getNullable("value")) + + /** The attribute to target */ + @JsonProperty("attribute") @ExcludeMissing fun _attribute() = attribute + + /** The operation to apply to the attribute */ + @JsonProperty("operation") @ExcludeMissing fun _operation() = operation + + @JsonProperty("value") @ExcludeMissing fun _value() = value + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Condition = apply { + if (!validated) { + attribute() + operation() + value() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + this.attribute == other.attribute && + this.operation == other.operation && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + attribute, + operation, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var attribute: JsonField = JsonMissing.of() + private var operation: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(condition: Condition) = apply { + this.attribute = condition.attribute + this.operation = condition.operation + this.value = condition.value + additionalProperties(condition.additionalProperties) + } + + /** The attribute to target */ + fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute)) + + /** The attribute to target */ + @JsonProperty("attribute") + @ExcludeMissing + fun attribute(attribute: JsonField) = apply { + this.attribute = attribute + } + + /** The operation to apply to the attribute */ + fun operation(operation: Operation) = operation(JsonField.of(operation)) + + /** The operation to apply to the attribute */ + @JsonProperty("operation") + @ExcludeMissing + fun operation(operation: JsonField) = apply { + this.operation = operation + } + + fun value(value: Value) = value(JsonField.of(value)) + + @JsonProperty("value") + @ExcludeMissing + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun build(): Condition = + Condition( + attribute, + operation, + value, + additionalProperties.toUnmodifiable(), + ) + } + + class Attribute + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Attribute && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val MCC = Attribute(JsonField.of("MCC")) + + @JvmField val COUNTRY = Attribute(JsonField.of("COUNTRY")) + + @JvmField val CURRENCY = Attribute(JsonField.of("CURRENCY")) + + @JvmField val MERCHANT_ID = Attribute(JsonField.of("MERCHANT_ID")) + + @JvmField val DESCRIPTOR = Attribute(JsonField.of("DESCRIPTOR")) + + @JvmField + val LIABILITY_SHIFT = Attribute(JsonField.of("LIABILITY_SHIFT")) + + @JvmField val PAN_ENTRY_MODE = Attribute(JsonField.of("PAN_ENTRY_MODE")) + + @JvmField + val TRANSACTION_AMOUNT = Attribute(JsonField.of("TRANSACTION_AMOUNT")) + + @JvmField val RISK_SCORE = Attribute(JsonField.of("RISK_SCORE")) + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + enum class Known { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + } + + enum class Value { + MCC, + COUNTRY, + CURRENCY, + MERCHANT_ID, + DESCRIPTOR, + LIABILITY_SHIFT, + PAN_ENTRY_MODE, + TRANSACTION_AMOUNT, + RISK_SCORE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MCC -> Value.MCC + COUNTRY -> Value.COUNTRY + CURRENCY -> Value.CURRENCY + MERCHANT_ID -> Value.MERCHANT_ID + DESCRIPTOR -> Value.DESCRIPTOR + LIABILITY_SHIFT -> Value.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Value.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + RISK_SCORE -> Value.RISK_SCORE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MCC -> Known.MCC + COUNTRY -> Known.COUNTRY + CURRENCY -> Known.CURRENCY + MERCHANT_ID -> Known.MERCHANT_ID + DESCRIPTOR -> Known.DESCRIPTOR + LIABILITY_SHIFT -> Known.LIABILITY_SHIFT + PAN_ENTRY_MODE -> Known.PAN_ENTRY_MODE + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + RISK_SCORE -> Known.RISK_SCORE + else -> + throw LithicInvalidDataException("Unknown Attribute: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Operation + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operation && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val IS_ONE_OF = Operation(JsonField.of("IS_ONE_OF")) + + @JvmField val IS_NOT_ONE_OF = Operation(JsonField.of("IS_NOT_ONE_OF")) + + @JvmField val MATCHES = Operation(JsonField.of("MATCHES")) + + @JvmField val DOES_NOT_MATCH = Operation(JsonField.of("DOES_NOT_MATCH")) + + @JvmField + val IS_GREATER_THAN = Operation(JsonField.of("IS_GREATER_THAN")) + + @JvmField val IS_LESS_THAN = Operation(JsonField.of("IS_LESS_THAN")) + + @JvmStatic fun of(value: String) = Operation(JsonField.of(value)) + } + + enum class Known { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + } + + enum class Value { + IS_ONE_OF, + IS_NOT_ONE_OF, + MATCHES, + DOES_NOT_MATCH, + IS_GREATER_THAN, + IS_LESS_THAN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + IS_ONE_OF -> Value.IS_ONE_OF + IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF + MATCHES -> Value.MATCHES + DOES_NOT_MATCH -> Value.DOES_NOT_MATCH + IS_GREATER_THAN -> Value.IS_GREATER_THAN + IS_LESS_THAN -> Value.IS_LESS_THAN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + IS_ONE_OF -> Known.IS_ONE_OF + IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF + MATCHES -> Known.MATCHES + DOES_NOT_MATCH -> Known.DOES_NOT_MATCH + IS_GREATER_THAN -> Known.IS_GREATER_THAN + IS_LESS_THAN -> Known.IS_LESS_THAN + else -> + throw LithicInvalidDataException("Unknown Operation: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val double: Double? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun string(): Optional = Optional.ofNullable(string) + /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */ + fun double(): Optional = Optional.ofNullable(double) + /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isString(): Boolean = string != null + + fun isDouble(): Boolean = double != null + + fun isStrings(): Boolean = strings != null + + fun asString(): String = string.getOrThrow("string") + + fun asDouble(): Double = double.getOrThrow("double") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + string != null -> visitor.visitString(string) + double != null -> visitor.visitDouble(double) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if (string == null && double == null && strings == null) { + throw LithicInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.string == other.string && + this.double == other.double && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + string, + double, + strings, + ) + } + + override fun toString(): String { + return when { + string != null -> "Value{string=$string}" + double != null -> "Value{double=$double}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic + fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitString(string: String): T + + fun visitDouble(double: Double): T + + fun visitStrings(strings: List): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Value: $json") + } + } + + class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(string = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef>())?.let { + return Value(strings = it, _json = json) + } + + return Value(_json = json) + } + } + + class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.double != null -> generator.writeObject(value.double) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + } + } + } + } + + class AuthRuleState + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleState && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val ACTIVE = AuthRuleState(JsonField.of("ACTIVE")) + + @JvmField val INACTIVE = AuthRuleState(JsonField.of("INACTIVE")) + + @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) + } + + enum class Known { + ACTIVE, + INACTIVE, + } + + enum class Value { + ACTIVE, + INACTIVE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw LithicInvalidDataException("Unknown AuthRuleState: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class AuthRuleType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthRuleType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CONDITIONAL_BLOCK = AuthRuleType(JsonField.of("CONDITIONAL_BLOCK")) + + @JvmField val VELOCITY_LIMIT = AuthRuleType(JsonField.of("VELOCITY_LIMIT")) + + @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) + } + + enum class Known { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + } + + enum class Value { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Value.VELOCITY_LIMIT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Known.VELOCITY_LIMIT + else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} 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 new file mode 100644 index 00000000..9b319763 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/VelocityLimitParams.kt @@ -0,0 +1,579 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toUnmodifiable +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = VelocityLimitParams.Builder::class) +@NoAutoDetect +class VelocityLimitParams +private constructor( + private val scope: JsonField, + private val period: JsonField, + private val filters: JsonField, + private val limitAmount: JsonField, + private val limitCount: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun scope(): Scope = scope.getRequired("scope") + + fun period(): Period = period.getRequired("period") + + fun filters(): Filters = filters.getRequired("filters") + + /** + * The maximum amount of spend velocity allowed in the period in minor units (the smallest unit + * of a currency, e.g. cents for USD). Transactions exceeding this limit will be declined. + */ + fun limitAmount(): Optional = + Optional.ofNullable(limitAmount.getNullable("limit_amount")) + + /** + * The number of spend velocity impacting transactions may not exceed this limit in the period. + * Transactions exceeding this limit will be declined. A spend velocity impacting transaction is + * a transaction that has been authorized, and optionally settled, or a force post (a + * transaction that settled without prior authorization). + */ + fun limitCount(): Optional = Optional.ofNullable(limitCount.getNullable("limit_count")) + + @JsonProperty("scope") @ExcludeMissing fun _scope() = scope + + @JsonProperty("period") @ExcludeMissing fun _period() = period + + @JsonProperty("filters") @ExcludeMissing fun _filters() = filters + + /** + * The maximum amount of spend velocity allowed in the period in minor units (the smallest unit + * of a currency, e.g. cents for USD). Transactions exceeding this limit will be declined. + */ + @JsonProperty("limit_amount") @ExcludeMissing fun _limitAmount() = limitAmount + + /** + * The number of spend velocity impacting transactions may not exceed this limit in the period. + * Transactions exceeding this limit will be declined. A spend velocity impacting transaction is + * a transaction that has been authorized, and optionally settled, or a force post (a + * transaction that settled without prior authorization). + */ + @JsonProperty("limit_count") @ExcludeMissing fun _limitCount() = limitCount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): VelocityLimitParams = apply { + if (!validated) { + scope() + period() + filters().validate() + limitAmount() + limitCount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VelocityLimitParams && + this.scope == other.scope && + this.period == other.period && + this.filters == other.filters && + this.limitAmount == other.limitAmount && + this.limitCount == other.limitCount && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + scope, + period, + filters, + limitAmount, + limitCount, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "VelocityLimitParams{scope=$scope, period=$period, filters=$filters, limitAmount=$limitAmount, limitCount=$limitCount, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var scope: JsonField = JsonMissing.of() + private var period: JsonField = JsonMissing.of() + private var filters: JsonField = JsonMissing.of() + private var limitAmount: JsonField = JsonMissing.of() + private var limitCount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(velocityLimitParams: VelocityLimitParams) = apply { + this.scope = velocityLimitParams.scope + this.period = velocityLimitParams.period + this.filters = velocityLimitParams.filters + this.limitAmount = velocityLimitParams.limitAmount + this.limitCount = velocityLimitParams.limitCount + additionalProperties(velocityLimitParams.additionalProperties) + } + + fun scope(scope: Scope) = scope(JsonField.of(scope)) + + @JsonProperty("scope") + @ExcludeMissing + fun scope(scope: JsonField) = apply { this.scope = scope } + + fun period(period: Period) = period(JsonField.of(period)) + + @JsonProperty("period") + @ExcludeMissing + fun period(period: JsonField) = apply { this.period = period } + + fun filters(filters: Filters) = filters(JsonField.of(filters)) + + @JsonProperty("filters") + @ExcludeMissing + fun filters(filters: JsonField) = apply { this.filters = filters } + + /** + * The maximum amount of spend velocity allowed in the period in minor units (the smallest + * unit of a currency, e.g. cents for USD). Transactions exceeding this limit will be + * declined. + */ + fun limitAmount(limitAmount: Double) = limitAmount(JsonField.of(limitAmount)) + + /** + * The maximum amount of spend velocity allowed in the period in minor units (the smallest + * unit of a currency, e.g. cents for USD). Transactions exceeding this limit will be + * declined. + */ + @JsonProperty("limit_amount") + @ExcludeMissing + fun limitAmount(limitAmount: JsonField) = apply { this.limitAmount = limitAmount } + + /** + * The number of spend velocity impacting transactions may not exceed this limit in the + * period. Transactions exceeding this limit will be declined. A spend velocity impacting + * transaction is a transaction that has been authorized, and optionally settled, or a force + * post (a transaction that settled without prior authorization). + */ + fun limitCount(limitCount: Double) = limitCount(JsonField.of(limitCount)) + + /** + * The number of spend velocity impacting transactions may not exceed this limit in the + * period. Transactions exceeding this limit will be declined. A spend velocity impacting + * transaction is a transaction that has been authorized, and optionally settled, or a force + * post (a transaction that settled without prior authorization). + */ + @JsonProperty("limit_count") + @ExcludeMissing + fun limitCount(limitCount: JsonField) = apply { this.limitCount = limitCount } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): VelocityLimitParams = + VelocityLimitParams( + scope, + period, + filters, + limitAmount, + limitCount, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = Filters.Builder::class) + @NoAutoDetect + class Filters + private constructor( + private val includeMccs: JsonField>, + private val includeCountries: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * Merchant Category Codes to include in the velocity calculation. Transactions not matching + * this MCC will not be included in the calculated velocity. + */ + fun includeMccs(): Optional> = + Optional.ofNullable(includeMccs.getNullable("include_mccs")) + + /** + * ISO-3166-1 alpha-3 Country Codes to include in the velocity calculation. Transactions not + * matching any of the provided will not be included in the calculated velocity. + */ + fun includeCountries(): Optional> = + Optional.ofNullable(includeCountries.getNullable("include_countries")) + + /** + * Merchant Category Codes to include in the velocity calculation. Transactions not matching + * this MCC will not be included in the calculated velocity. + */ + @JsonProperty("include_mccs") @ExcludeMissing fun _includeMccs() = includeMccs + + /** + * ISO-3166-1 alpha-3 Country Codes to include in the velocity calculation. Transactions not + * matching any of the provided will not be included in the calculated velocity. + */ + @JsonProperty("include_countries") + @ExcludeMissing + fun _includeCountries() = includeCountries + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Filters = apply { + if (!validated) { + includeMccs() + includeCountries() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filters && + this.includeMccs == other.includeMccs && + this.includeCountries == other.includeCountries && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + includeMccs, + includeCountries, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Filters{includeMccs=$includeMccs, includeCountries=$includeCountries, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var includeMccs: JsonField> = JsonMissing.of() + private var includeCountries: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(filters: Filters) = apply { + this.includeMccs = filters.includeMccs + this.includeCountries = filters.includeCountries + additionalProperties(filters.additionalProperties) + } + + /** + * Merchant Category Codes to include in the velocity calculation. Transactions not + * matching this MCC will not be included in the calculated velocity. + */ + fun includeMccs(includeMccs: List) = includeMccs(JsonField.of(includeMccs)) + + /** + * Merchant Category Codes to include in the velocity calculation. Transactions not + * matching this MCC will not be included in the calculated velocity. + */ + @JsonProperty("include_mccs") + @ExcludeMissing + fun includeMccs(includeMccs: JsonField>) = apply { + this.includeMccs = includeMccs + } + + /** + * ISO-3166-1 alpha-3 Country Codes to include in the velocity calculation. Transactions + * not matching any of the provided will not be included in the calculated velocity. + */ + fun includeCountries(includeCountries: List) = + includeCountries(JsonField.of(includeCountries)) + + /** + * ISO-3166-1 alpha-3 Country Codes to include in the velocity calculation. Transactions + * not matching any of the provided will not be included in the calculated velocity. + */ + @JsonProperty("include_countries") + @ExcludeMissing + fun includeCountries(includeCountries: JsonField>) = apply { + this.includeCountries = includeCountries + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Filters = + Filters( + includeMccs.map { it.toUnmodifiable() }, + includeCountries.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + } + + @JsonDeserialize(using = Period.Deserializer::class) + @JsonSerialize(using = Period.Serializer::class) + class Period + private constructor( + private val double: Double? = null, + private val velocityLimitParamsPeriodWindow: VelocityLimitParamsPeriodWindow? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + /** The size of the trailing window to calculate Spend Velocity over in seconds. */ + fun double(): Optional = Optional.ofNullable(double) + /** + * The window of time to calculate Spend Velocity over. + * - `DAY`: Velocity over the current day since midnight Eastern Time. + * - `MONTH`: Velocity over the current month since 00:00 / 12 AM on the first of the month + * in Eastern Time. + */ + fun velocityLimitParamsPeriodWindow(): Optional = + Optional.ofNullable(velocityLimitParamsPeriodWindow) + + fun isDouble(): Boolean = double != null + + fun isVelocityLimitParamsPeriodWindow(): Boolean = velocityLimitParamsPeriodWindow != null + + fun asDouble(): Double = double.getOrThrow("double") + + fun asVelocityLimitParamsPeriodWindow(): VelocityLimitParamsPeriodWindow = + velocityLimitParamsPeriodWindow.getOrThrow("velocityLimitParamsPeriodWindow") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T { + return when { + double != null -> visitor.visitDouble(double) + velocityLimitParamsPeriodWindow != null -> + visitor.visitVelocityLimitParamsPeriodWindow(velocityLimitParamsPeriodWindow) + else -> visitor.unknown(_json) + } + } + + fun validate(): Period = apply { + if (!validated) { + if (double == null && velocityLimitParamsPeriodWindow == null) { + throw LithicInvalidDataException("Unknown Period: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Period && + this.double == other.double && + this.velocityLimitParamsPeriodWindow == other.velocityLimitParamsPeriodWindow + } + + override fun hashCode(): Int { + return Objects.hash(double, velocityLimitParamsPeriodWindow) + } + + override fun toString(): String { + return when { + double != null -> "Period{double=$double}" + velocityLimitParamsPeriodWindow != null -> + "Period{velocityLimitParamsPeriodWindow=$velocityLimitParamsPeriodWindow}" + _json != null -> "Period{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Period") + } + } + + companion object { + + @JvmStatic fun ofDouble(double: Double) = Period(double = double) + + @JvmStatic + fun ofVelocityLimitParamsPeriodWindow( + velocityLimitParamsPeriodWindow: VelocityLimitParamsPeriodWindow + ) = Period(velocityLimitParamsPeriodWindow = velocityLimitParamsPeriodWindow) + } + + interface Visitor { + + fun visitDouble(double: Double): T + + fun visitVelocityLimitParamsPeriodWindow( + velocityLimitParamsPeriodWindow: VelocityLimitParamsPeriodWindow + ): T + + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Period: $json") + } + } + + class Deserializer : BaseDeserializer(Period::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Period { + val json = JsonValue.fromJsonNode(node) + tryDeserialize(node, jacksonTypeRef())?.let { + return Period(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Period(velocityLimitParamsPeriodWindow = it, _json = json) + } + + return Period(_json = json) + } + } + + class Serializer : BaseSerializer(Period::class) { + + override fun serialize( + value: Period, + generator: JsonGenerator, + provider: SerializerProvider + ) { + when { + value.double != null -> generator.writeObject(value.double) + 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 { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scope && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val CARD = Scope(JsonField.of("CARD")) + + @JvmField val ACCOUNT = Scope(JsonField.of("ACCOUNT")) + + @JvmStatic fun of(value: String) = Scope(JsonField.of(value)) + } + + enum class Known { + CARD, + ACCOUNT, + } + + enum class Value { + CARD, + ACCOUNT, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CARD -> Value.CARD + ACCOUNT -> Value.ACCOUNT + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CARD -> Known.CARD + ACCOUNT -> Known.ACCOUNT + else -> throw LithicInvalidDataException("Unknown Scope: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} 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 new file mode 100644 index 00000000..2dc5c38f --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/VelocityLimitParamsPeriodWindow.kt @@ -0,0 +1,67 @@ +// 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.core.JsonValue +import com.lithic.api.errors.LithicInvalidDataException + +class VelocityLimitParamsPeriodWindow +@JsonCreator +private constructor( + private val value: JsonField, +) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VelocityLimitParamsPeriodWindow && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val DAY = VelocityLimitParamsPeriodWindow(JsonField.of("DAY")) + + @JvmField val MONTH = VelocityLimitParamsPeriodWindow(JsonField.of("MONTH")) + + @JvmStatic fun of(value: String) = VelocityLimitParamsPeriodWindow(JsonField.of(value)) + } + + enum class Known { + DAY, + MONTH, + } + + enum class Value { + DAY, + MONTH, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + DAY -> Value.DAY + MONTH -> Value.MONTH + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + DAY -> Known.DAY + MONTH -> Known.MONTH + else -> + throw LithicInvalidDataException("Unknown VelocityLimitParamsPeriodWindow: $value") + } + + fun asString(): String = _value().asStringOrThrow() +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AuthRuleServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AuthRuleServiceAsync.kt index 85fdae8a..0de26496 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AuthRuleServiceAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AuthRuleServiceAsync.kt @@ -15,10 +15,13 @@ import com.lithic.api.models.AuthRuleRemoveResponse import com.lithic.api.models.AuthRuleRetrieveParams import com.lithic.api.models.AuthRuleRetrieveResponse import com.lithic.api.models.AuthRuleUpdateParams +import com.lithic.api.services.async.authRules.V2ServiceAsync import java.util.concurrent.CompletableFuture interface AuthRuleServiceAsync { + fun v2(): V2ServiceAsync + /** * Creates an authorization rule (Auth Rule) and applies it at the program, account, or card * level. diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AuthRuleServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AuthRuleServiceAsyncImpl.kt index 1b6d64a6..29bb747b 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AuthRuleServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/AuthRuleServiceAsyncImpl.kt @@ -18,6 +18,8 @@ import com.lithic.api.models.AuthRuleRemoveResponse import com.lithic.api.models.AuthRuleRetrieveParams import com.lithic.api.models.AuthRuleRetrieveResponse import com.lithic.api.models.AuthRuleUpdateParams +import com.lithic.api.services.async.authRules.V2ServiceAsync +import com.lithic.api.services.async.authRules.V2ServiceAsyncImpl import com.lithic.api.services.errorHandler import com.lithic.api.services.json import com.lithic.api.services.jsonHandler @@ -31,6 +33,10 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val v2: V2ServiceAsync by lazy { V2ServiceAsyncImpl(clientOptions) } + + override fun v2(): V2ServiceAsync = v2 + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalPaymentServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalPaymentServiceAsync.kt new file mode 100644 index 00000000..5e76310c --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalPaymentServiceAsync.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package com.lithic.api.services.async + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.ExternalPayment +import com.lithic.api.models.ExternalPaymentCancelParams +import com.lithic.api.models.ExternalPaymentCreateParams +import com.lithic.api.models.ExternalPaymentListPageAsync +import com.lithic.api.models.ExternalPaymentListParams +import com.lithic.api.models.ExternalPaymentReleaseParams +import com.lithic.api.models.ExternalPaymentRetrieveParams +import com.lithic.api.models.ExternalPaymentReverseParams +import com.lithic.api.models.ExternalPaymentSettleParams +import java.util.concurrent.CompletableFuture + +interface ExternalPaymentServiceAsync { + + /** Create external payment */ + @JvmOverloads + fun create( + params: ExternalPaymentCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** Get external payment */ + @JvmOverloads + fun retrieve( + params: ExternalPaymentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** List external payments */ + @JvmOverloads + fun list( + params: ExternalPaymentListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** Cancel external payment */ + @JvmOverloads + fun cancel( + params: ExternalPaymentCancelParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** Release external payment */ + @JvmOverloads + fun release( + params: ExternalPaymentReleaseParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** Reverse external payment */ + @JvmOverloads + fun reverse( + params: ExternalPaymentReverseParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** Settle external payment */ + @JvmOverloads + fun settle( + params: ExternalPaymentSettleParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalPaymentServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalPaymentServiceAsyncImpl.kt new file mode 100644 index 00000000..1f0c1b9f --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalPaymentServiceAsyncImpl.kt @@ -0,0 +1,242 @@ +// 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.HttpMethod +import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse.Handler +import com.lithic.api.errors.LithicError +import com.lithic.api.models.ExternalPayment +import com.lithic.api.models.ExternalPaymentCancelParams +import com.lithic.api.models.ExternalPaymentCreateParams +import com.lithic.api.models.ExternalPaymentListPageAsync +import com.lithic.api.models.ExternalPaymentListParams +import com.lithic.api.models.ExternalPaymentReleaseParams +import com.lithic.api.models.ExternalPaymentRetrieveParams +import com.lithic.api.models.ExternalPaymentReverseParams +import com.lithic.api.models.ExternalPaymentSettleParams +import com.lithic.api.services.errorHandler +import com.lithic.api.services.json +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture + +class ExternalPaymentServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : ExternalPaymentServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Create external payment */ + override fun create( + params: ExternalPaymentCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "external_payments") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Get external payment */ + override fun retrieve( + params: ExternalPaymentRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "external_payments", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** List external payments */ + override fun list( + params: ExternalPaymentListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "external_payments") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ExternalPaymentListPageAsync.of(this, params, it) } + } + } + + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Cancel external payment */ + override fun cancel( + params: ExternalPaymentCancelParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "external_payments", params.getPathParam(0), "cancel") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { cancelHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val releaseHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Release external payment */ + override fun release( + params: ExternalPaymentReleaseParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "external_payments", params.getPathParam(0), "release") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { releaseHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val reverseHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Reverse external payment */ + override fun reverse( + params: ExternalPaymentReverseParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "external_payments", params.getPathParam(0), "reverse") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { reverseHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val settleHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Settle external payment */ + override fun settle( + params: ExternalPaymentSettleParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "external_payments", params.getPathParam(0), "settle") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { settleHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsync.kt new file mode 100644 index 00000000..3c25fc1e --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsync.kt @@ -0,0 +1,107 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package com.lithic.api.services.async.authRules + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.AuthRuleV2ApplyParams +import com.lithic.api.models.AuthRuleV2CreateParams +import com.lithic.api.models.AuthRuleV2DraftParams +import com.lithic.api.models.AuthRuleV2ListPageAsync +import com.lithic.api.models.AuthRuleV2ListParams +import com.lithic.api.models.AuthRuleV2PromoteParams +import com.lithic.api.models.AuthRuleV2ReportParams +import com.lithic.api.models.AuthRuleV2RetrieveParams +import com.lithic.api.models.AuthRuleV2UpdateParams +import com.lithic.api.models.V2ApplyResponse +import com.lithic.api.models.V2CreateResponse +import com.lithic.api.models.V2DraftResponse +import com.lithic.api.models.V2PromoteResponse +import com.lithic.api.models.V2ReportResponse +import com.lithic.api.models.V2RetrieveResponse +import com.lithic.api.models.V2UpdateResponse +import java.util.concurrent.CompletableFuture + +interface V2ServiceAsync { + + /** Creates a new V2 authorization rule in draft mode */ + @JvmOverloads + fun create( + params: AuthRuleV2CreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** Fetches an authorization rule by its token */ + @JvmOverloads + fun retrieve( + params: AuthRuleV2RetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** Updates an authorization rule's properties */ + @JvmOverloads + fun update( + params: AuthRuleV2UpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** Lists V2 authorization rules */ + @JvmOverloads + fun list( + params: AuthRuleV2ListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** + * Associates an authorization rules with a card program, the provided account(s) or card(s). + * + * This endpoint will replace any existing associations with the provided list of entities. + */ + @JvmOverloads + fun apply( + params: AuthRuleV2ApplyParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** + * Creates a new draft version of an authorization rules that will be ran in shadow mode. + * + * This can also be utilized to reset the draft parameters, causing a draft version to no longer + * be ran in shadow mode. + */ + @JvmOverloads + fun draft( + params: AuthRuleV2DraftParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** + * Promotes a draft version of an authorization rule to the currently active version such that + * it is enforced in the authorization stream. + */ + @JvmOverloads + fun promote( + params: AuthRuleV2PromoteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** + * Requests a performance report of an authorization rule to be asynchronously generated. + * Reports can only be run on rules in draft or active mode and will included approved and + * declined statistics as well as examples. The generated report will be delivered + * asynchronously through a webhook with `event_type` = `auth_rules.performance_report.created`. + * See the docs on setting up [webhook subscriptions](https://docs.lithic.com/docs/events-api). + * + * Note that generating a report may take up to 15 minutes and that delivery is not guaranteed. + * Customers are required to have created an event subscription to receive the webhook. + * Additionally, there is a delay of approximately 15 minutes between when Lithic's transaction + * processing systems have processed the transaction, and when a transaction will be included in + * the report. + */ + @JvmOverloads + fun report( + params: AuthRuleV2ReportParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt new file mode 100644 index 00000000..ecc67f35 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt @@ -0,0 +1,303 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async.authRules + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +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.errors.LithicError +import com.lithic.api.models.AuthRuleV2ApplyParams +import com.lithic.api.models.AuthRuleV2CreateParams +import com.lithic.api.models.AuthRuleV2DraftParams +import com.lithic.api.models.AuthRuleV2ListPageAsync +import com.lithic.api.models.AuthRuleV2ListParams +import com.lithic.api.models.AuthRuleV2PromoteParams +import com.lithic.api.models.AuthRuleV2ReportParams +import com.lithic.api.models.AuthRuleV2RetrieveParams +import com.lithic.api.models.AuthRuleV2UpdateParams +import com.lithic.api.models.V2ApplyResponse +import com.lithic.api.models.V2CreateResponse +import com.lithic.api.models.V2DraftResponse +import com.lithic.api.models.V2PromoteResponse +import com.lithic.api.models.V2ReportResponse +import com.lithic.api.models.V2RetrieveResponse +import com.lithic.api.models.V2UpdateResponse +import com.lithic.api.services.errorHandler +import com.lithic.api.services.json +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture + +class V2ServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : V2ServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Creates a new V2 authorization rule in draft mode */ + override fun create( + params: AuthRuleV2CreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v2", "auth_rules") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Fetches an authorization rule by its token */ + override fun retrieve( + params: AuthRuleV2RetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v2", "auth_rules", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Updates an authorization rule's properties */ + override fun update( + params: AuthRuleV2UpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v2", "auth_rules", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Lists V2 authorization rules */ + override fun list( + params: AuthRuleV2ListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v2", "auth_rules") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { AuthRuleV2ListPageAsync.of(this, params, it) } + } + } + + private val applyHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Associates an authorization rules with a card program, the provided account(s) or card(s). + * + * This endpoint will replace any existing associations with the provided list of entities. + */ + override fun apply( + params: AuthRuleV2ApplyParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v2", "auth_rules", params.getPathParam(0), "apply") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { applyHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val draftHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Creates a new draft version of an authorization rules that will be ran in shadow mode. + * + * This can also be utilized to reset the draft parameters, causing a draft version to no longer + * be ran in shadow mode. + */ + override fun draft( + params: AuthRuleV2DraftParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v2", "auth_rules", params.getPathParam(0), "draft") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { draftHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val promoteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Promotes a draft version of an authorization rule to the currently active version such that + * it is enforced in the authorization stream. + */ + override fun promote( + params: AuthRuleV2PromoteParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v2", "auth_rules", params.getPathParam(0), "promote") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { promoteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val reportHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Requests a performance report of an authorization rule to be asynchronously generated. + * Reports can only be run on rules in draft or active mode and will included approved and + * declined statistics as well as examples. The generated report will be delivered + * asynchronously through a webhook with `event_type` = `auth_rules.performance_report.created`. + * See the docs on setting up [webhook subscriptions](https://docs.lithic.com/docs/events-api). + * + * Note that generating a report may take up to 15 minutes and that delivery is not guaranteed. + * Customers are required to have created an event subscription to receive the webhook. + * Additionally, there is a delay of approximately 15 minutes between when Lithic's transaction + * processing systems have processed the transaction, and when a transaction will be included in + * the report. + */ + override fun report( + params: AuthRuleV2ReportParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v2", "auth_rules", params.getPathParam(0), "report") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { reportHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AuthRuleService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AuthRuleService.kt index 5190c6f7..7201ba3f 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AuthRuleService.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AuthRuleService.kt @@ -15,9 +15,12 @@ import com.lithic.api.models.AuthRuleRemoveResponse import com.lithic.api.models.AuthRuleRetrieveParams import com.lithic.api.models.AuthRuleRetrieveResponse import com.lithic.api.models.AuthRuleUpdateParams +import com.lithic.api.services.blocking.authRules.V2Service interface AuthRuleService { + fun v2(): V2Service + /** * Creates an authorization rule (Auth Rule) and applies it at the program, account, or card * level. diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AuthRuleServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AuthRuleServiceImpl.kt index 5159b405..11d422c3 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AuthRuleServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/AuthRuleServiceImpl.kt @@ -18,6 +18,8 @@ import com.lithic.api.models.AuthRuleRemoveResponse import com.lithic.api.models.AuthRuleRetrieveParams import com.lithic.api.models.AuthRuleRetrieveResponse import com.lithic.api.models.AuthRuleUpdateParams +import com.lithic.api.services.blocking.authRules.V2Service +import com.lithic.api.services.blocking.authRules.V2ServiceImpl import com.lithic.api.services.errorHandler import com.lithic.api.services.json import com.lithic.api.services.jsonHandler @@ -30,6 +32,10 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val v2: V2Service by lazy { V2ServiceImpl(clientOptions) } + + override fun v2(): V2Service = v2 + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalPaymentService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalPaymentService.kt new file mode 100644 index 00000000..643ba636 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalPaymentService.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package com.lithic.api.services.blocking + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.ExternalPayment +import com.lithic.api.models.ExternalPaymentCancelParams +import com.lithic.api.models.ExternalPaymentCreateParams +import com.lithic.api.models.ExternalPaymentListPage +import com.lithic.api.models.ExternalPaymentListParams +import com.lithic.api.models.ExternalPaymentReleaseParams +import com.lithic.api.models.ExternalPaymentRetrieveParams +import com.lithic.api.models.ExternalPaymentReverseParams +import com.lithic.api.models.ExternalPaymentSettleParams + +interface ExternalPaymentService { + + /** Create external payment */ + @JvmOverloads + fun create( + params: ExternalPaymentCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ExternalPayment + + /** Get external payment */ + @JvmOverloads + fun retrieve( + params: ExternalPaymentRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ExternalPayment + + /** List external payments */ + @JvmOverloads + fun list( + params: ExternalPaymentListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ExternalPaymentListPage + + /** Cancel external payment */ + @JvmOverloads + fun cancel( + params: ExternalPaymentCancelParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ExternalPayment + + /** Release external payment */ + @JvmOverloads + fun release( + params: ExternalPaymentReleaseParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ExternalPayment + + /** Reverse external payment */ + @JvmOverloads + fun reverse( + params: ExternalPaymentReverseParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ExternalPayment + + /** Settle external payment */ + @JvmOverloads + fun settle( + params: ExternalPaymentSettleParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ExternalPayment +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalPaymentServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalPaymentServiceImpl.kt new file mode 100644 index 00000000..09086114 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalPaymentServiceImpl.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.http.HttpMethod +import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse.Handler +import com.lithic.api.errors.LithicError +import com.lithic.api.models.ExternalPayment +import com.lithic.api.models.ExternalPaymentCancelParams +import com.lithic.api.models.ExternalPaymentCreateParams +import com.lithic.api.models.ExternalPaymentListPage +import com.lithic.api.models.ExternalPaymentListParams +import com.lithic.api.models.ExternalPaymentReleaseParams +import com.lithic.api.models.ExternalPaymentRetrieveParams +import com.lithic.api.models.ExternalPaymentReverseParams +import com.lithic.api.models.ExternalPaymentSettleParams +import com.lithic.api.services.errorHandler +import com.lithic.api.services.json +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class ExternalPaymentServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : ExternalPaymentService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Create external payment */ + override fun create( + params: ExternalPaymentCreateParams, + requestOptions: RequestOptions + ): ExternalPayment { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "external_payments") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Get external payment */ + override fun retrieve( + params: ExternalPaymentRetrieveParams, + requestOptions: RequestOptions + ): ExternalPayment { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "external_payments", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** List external payments */ + override fun list( + params: ExternalPaymentListParams, + requestOptions: RequestOptions + ): ExternalPaymentListPage { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v1", "external_payments") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ExternalPaymentListPage.of(this, params, it) } + } + } + + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Cancel external payment */ + override fun cancel( + params: ExternalPaymentCancelParams, + requestOptions: RequestOptions + ): ExternalPayment { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "external_payments", params.getPathParam(0), "cancel") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { cancelHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val releaseHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Release external payment */ + override fun release( + params: ExternalPaymentReleaseParams, + requestOptions: RequestOptions + ): ExternalPayment { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "external_payments", params.getPathParam(0), "release") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { releaseHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val reverseHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Reverse external payment */ + override fun reverse( + params: ExternalPaymentReverseParams, + requestOptions: RequestOptions + ): ExternalPayment { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "external_payments", params.getPathParam(0), "reverse") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { reverseHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val settleHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Settle external payment */ + override fun settle( + params: ExternalPaymentSettleParams, + requestOptions: RequestOptions + ): ExternalPayment { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v1", "external_payments", params.getPathParam(0), "settle") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { settleHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2Service.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2Service.kt new file mode 100644 index 00000000..2f6da6ba --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2Service.kt @@ -0,0 +1,106 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package com.lithic.api.services.blocking.authRules + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.AuthRuleV2ApplyParams +import com.lithic.api.models.AuthRuleV2CreateParams +import com.lithic.api.models.AuthRuleV2DraftParams +import com.lithic.api.models.AuthRuleV2ListPage +import com.lithic.api.models.AuthRuleV2ListParams +import com.lithic.api.models.AuthRuleV2PromoteParams +import com.lithic.api.models.AuthRuleV2ReportParams +import com.lithic.api.models.AuthRuleV2RetrieveParams +import com.lithic.api.models.AuthRuleV2UpdateParams +import com.lithic.api.models.V2ApplyResponse +import com.lithic.api.models.V2CreateResponse +import com.lithic.api.models.V2DraftResponse +import com.lithic.api.models.V2PromoteResponse +import com.lithic.api.models.V2ReportResponse +import com.lithic.api.models.V2RetrieveResponse +import com.lithic.api.models.V2UpdateResponse + +interface V2Service { + + /** Creates a new V2 authorization rule in draft mode */ + @JvmOverloads + fun create( + params: AuthRuleV2CreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): V2CreateResponse + + /** Fetches an authorization rule by its token */ + @JvmOverloads + fun retrieve( + params: AuthRuleV2RetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): V2RetrieveResponse + + /** Updates an authorization rule's properties */ + @JvmOverloads + fun update( + params: AuthRuleV2UpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): V2UpdateResponse + + /** Lists V2 authorization rules */ + @JvmOverloads + fun list( + params: AuthRuleV2ListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): AuthRuleV2ListPage + + /** + * Associates an authorization rules with a card program, the provided account(s) or card(s). + * + * This endpoint will replace any existing associations with the provided list of entities. + */ + @JvmOverloads + fun apply( + params: AuthRuleV2ApplyParams, + requestOptions: RequestOptions = RequestOptions.none() + ): V2ApplyResponse + + /** + * Creates a new draft version of an authorization rules that will be ran in shadow mode. + * + * This can also be utilized to reset the draft parameters, causing a draft version to no longer + * be ran in shadow mode. + */ + @JvmOverloads + fun draft( + params: AuthRuleV2DraftParams, + requestOptions: RequestOptions = RequestOptions.none() + ): V2DraftResponse + + /** + * Promotes a draft version of an authorization rule to the currently active version such that + * it is enforced in the authorization stream. + */ + @JvmOverloads + fun promote( + params: AuthRuleV2PromoteParams, + requestOptions: RequestOptions = RequestOptions.none() + ): V2PromoteResponse + + /** + * Requests a performance report of an authorization rule to be asynchronously generated. + * Reports can only be run on rules in draft or active mode and will included approved and + * declined statistics as well as examples. The generated report will be delivered + * asynchronously through a webhook with `event_type` = `auth_rules.performance_report.created`. + * See the docs on setting up [webhook subscriptions](https://docs.lithic.com/docs/events-api). + * + * Note that generating a report may take up to 15 minutes and that delivery is not guaranteed. + * Customers are required to have created an event subscription to receive the webhook. + * Additionally, there is a delay of approximately 15 minutes between when Lithic's transaction + * processing systems have processed the transaction, and when a transaction will be included in + * the report. + */ + @JvmOverloads + fun report( + params: AuthRuleV2ReportParams, + requestOptions: RequestOptions = RequestOptions.none() + ): V2ReportResponse +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt new file mode 100644 index 00000000..c01c703c --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt @@ -0,0 +1,294 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.authRules + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +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.errors.LithicError +import com.lithic.api.models.AuthRuleV2ApplyParams +import com.lithic.api.models.AuthRuleV2CreateParams +import com.lithic.api.models.AuthRuleV2DraftParams +import com.lithic.api.models.AuthRuleV2ListPage +import com.lithic.api.models.AuthRuleV2ListParams +import com.lithic.api.models.AuthRuleV2PromoteParams +import com.lithic.api.models.AuthRuleV2ReportParams +import com.lithic.api.models.AuthRuleV2RetrieveParams +import com.lithic.api.models.AuthRuleV2UpdateParams +import com.lithic.api.models.V2ApplyResponse +import com.lithic.api.models.V2CreateResponse +import com.lithic.api.models.V2DraftResponse +import com.lithic.api.models.V2PromoteResponse +import com.lithic.api.models.V2ReportResponse +import com.lithic.api.models.V2RetrieveResponse +import com.lithic.api.models.V2UpdateResponse +import com.lithic.api.services.errorHandler +import com.lithic.api.services.json +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class V2ServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : V2Service { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Creates a new V2 authorization rule in draft mode */ + override fun create( + params: AuthRuleV2CreateParams, + requestOptions: RequestOptions + ): V2CreateResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v2", "auth_rules") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Fetches an authorization rule by its token */ + override fun retrieve( + params: AuthRuleV2RetrieveParams, + requestOptions: RequestOptions + ): V2RetrieveResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v2", "auth_rules", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Updates an authorization rule's properties */ + override fun update( + params: AuthRuleV2UpdateParams, + requestOptions: RequestOptions + ): V2UpdateResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("v2", "auth_rules", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Lists V2 authorization rules */ + override fun list( + params: AuthRuleV2ListParams, + requestOptions: RequestOptions + ): AuthRuleV2ListPage { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("v2", "auth_rules") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { AuthRuleV2ListPage.of(this, params, it) } + } + } + + private val applyHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Associates an authorization rules with a card program, the provided account(s) or card(s). + * + * This endpoint will replace any existing associations with the provided list of entities. + */ + override fun apply( + params: AuthRuleV2ApplyParams, + requestOptions: RequestOptions + ): V2ApplyResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v2", "auth_rules", params.getPathParam(0), "apply") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { applyHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val draftHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Creates a new draft version of an authorization rules that will be ran in shadow mode. + * + * This can also be utilized to reset the draft parameters, causing a draft version to no longer + * be ran in shadow mode. + */ + override fun draft( + params: AuthRuleV2DraftParams, + requestOptions: RequestOptions + ): V2DraftResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v2", "auth_rules", params.getPathParam(0), "draft") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { draftHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val promoteHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Promotes a draft version of an authorization rule to the currently active version such that + * it is enforced in the authorization stream. + */ + override fun promote( + params: AuthRuleV2PromoteParams, + requestOptions: RequestOptions + ): V2PromoteResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v2", "auth_rules", params.getPathParam(0), "promote") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { promoteHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val reportHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Requests a performance report of an authorization rule to be asynchronously generated. + * Reports can only be run on rules in draft or active mode and will included approved and + * declined statistics as well as examples. The generated report will be delivered + * asynchronously through a webhook with `event_type` = `auth_rules.performance_report.created`. + * See the docs on setting up [webhook subscriptions](https://docs.lithic.com/docs/events-api). + * + * Note that generating a report may take up to 15 minutes and that delivery is not guaranteed. + * Customers are required to have created an event subscription to receive the webhook. + * Additionally, there is a delay of approximately 15 minutes between when Lithic's transaction + * processing systems have processed the transaction, and when a transaction will be included in + * the report. + */ + override fun report( + params: AuthRuleV2ReportParams, + requestOptions: RequestOptions + ): V2ReportResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v2", "auth_rules", params.getPathParam(0), "report") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { reportHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreateParamsTest.kt index b76d2156..ffbd40f0 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreateParamsTest.kt @@ -19,9 +19,9 @@ class AccountHolderCreateParamsTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -40,9 +40,9 @@ class AccountHolderCreateParamsTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -61,9 +61,9 @@ class AccountHolderCreateParamsTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -80,9 +80,9 @@ class AccountHolderCreateParamsTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreateResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreateResponseTest.kt index e34c0ca7..c0249eeb 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreateResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreateResponseTest.kt @@ -20,6 +20,15 @@ class AccountHolderCreateResponseTest { ) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalId("external_id") + .requiredDocuments( + listOf( + RequiredDocument.builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .statusReasons(listOf("string")) + .validDocuments(listOf("string")) + .build() + ) + ) .build() assertThat(accountHolderCreateResponse).isNotNull assertThat(accountHolderCreateResponse.token()) @@ -33,5 +42,13 @@ class AccountHolderCreateResponseTest { assertThat(accountHolderCreateResponse.created()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(accountHolderCreateResponse.externalId()).contains("external_id") + assertThat(accountHolderCreateResponse.requiredDocuments().get()) + .containsExactly( + RequiredDocument.builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .statusReasons(listOf("string")) + .validDocuments(listOf("string")) + .build() + ) } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderResubmitParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderResubmitParamsTest.kt index 76b88445..d7175bee 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderResubmitParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderResubmitParamsTest.kt @@ -18,9 +18,9 @@ class AccountHolderResubmitParamsTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -48,9 +48,9 @@ class AccountHolderResubmitParamsTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -74,9 +74,9 @@ class AccountHolderResubmitParamsTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -103,9 +103,9 @@ class AccountHolderResubmitParamsTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .build() ) .dob("1991-03-08 08:00:00") @@ -128,9 +128,9 @@ class AccountHolderResubmitParamsTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .build() ) .dob("1991-03-08 08:00:00") @@ -156,9 +156,9 @@ class AccountHolderResubmitParamsTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .build() ) .dob("1991-03-08 08:00:00") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewResponseTest.kt index 4d649a0f..71994476 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderSimulateEnrollmentReviewResponseTest.kt @@ -133,7 +133,7 @@ class AccountHolderSimulateEnrollmentReviewResponseTest { .phoneNumber("phone_number") .requiredDocuments( listOf( - AccountHolderSimulateEnrollmentReviewResponse.RequiredDocument.builder() + RequiredDocument.builder() .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .statusReasons(listOf("string")) .validDocuments(listOf("string")) @@ -294,7 +294,7 @@ class AccountHolderSimulateEnrollmentReviewResponseTest { .contains("phone_number") assertThat(accountHolderSimulateEnrollmentReviewResponse.requiredDocuments().get()) .containsExactly( - AccountHolderSimulateEnrollmentReviewResponse.RequiredDocument.builder() + RequiredDocument.builder() .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .statusReasons(listOf("string")) .validDocuments(listOf("string")) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderTest.kt index ffabf1cf..671250de 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderTest.kt @@ -22,9 +22,9 @@ class AccountHolderTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -44,9 +44,9 @@ class AccountHolderTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -66,9 +66,9 @@ class AccountHolderTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -86,9 +86,9 @@ class AccountHolderTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -109,9 +109,9 @@ class AccountHolderTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -127,7 +127,7 @@ class AccountHolderTest { .phoneNumber("+12124007676") .requiredDocuments( listOf( - AccountHolder.RequiredDocument.builder() + RequiredDocument.builder() .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .statusReasons(listOf("string")) .validDocuments(listOf("string")) @@ -164,9 +164,9 @@ class AccountHolderTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -185,9 +185,9 @@ class AccountHolderTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -208,9 +208,9 @@ class AccountHolderTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -229,9 +229,9 @@ class AccountHolderTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -254,9 +254,9 @@ class AccountHolderTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -272,7 +272,7 @@ class AccountHolderTest { assertThat(accountHolder.phoneNumber()).contains("+12124007676") assertThat(accountHolder.requiredDocuments().get()) .containsExactly( - AccountHolder.RequiredDocument.builder() + RequiredDocument.builder() .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .statusReasons(listOf("string")) .validDocuments(listOf("string")) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AddressTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AddressTest.kt index a82b2da1..d5428ae7 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AddressTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AddressTest.kt @@ -13,17 +13,17 @@ class AddressTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() assertThat(address).isNotNull assertThat(address.address1()).isEqualTo("123 Old Forest Way") assertThat(address.city()).isEqualTo("Omaha") - assertThat(address.country()).isEqualTo("CAN") - assertThat(address.postalCode()).isEqualTo("M5V 1S8") - assertThat(address.state()).isEqualTo("ON") + assertThat(address.country()).isEqualTo("USA") + assertThat(address.postalCode()).isEqualTo("68022") + assertThat(address.state()).isEqualTo("NE") assertThat(address.address2()).contains("address2") } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ApplyParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ApplyParamsTest.kt new file mode 100644 index 00000000..352855f0 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ApplyParamsTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AuthRuleV2ApplyParamsTest { + + @Test + fun createAuthRuleV2ApplyParams() { + AuthRuleV2ApplyParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .forApplyAuthRuleRequestAccountTokens( + AuthRuleV2ApplyParams.ApplyAuthRuleRequestAccountTokens.builder() + .accountTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() + ) + .build() + } + + @Test + fun getPathParam() { + val params = + AuthRuleV2ApplyParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "authRuleToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2CreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2CreateParamsTest.kt new file mode 100644 index 00000000..451cc004 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2CreateParamsTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import org.junit.jupiter.api.Test + +class AuthRuleV2CreateParamsTest { + + @Test + fun createAuthRuleV2CreateParams() { + AuthRuleV2CreateParams.builder() + .forCreateAuthRuleRequestAccountTokens( + AuthRuleV2CreateParams.CreateAuthRuleRequestAccountTokens.builder() + .accountTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .parameters( + AuthRuleV2CreateParams.CreateAuthRuleRequestAccountTokens.AuthRuleParameters + .ofConditionalBlockParameters( + AuthRuleV2CreateParams.CreateAuthRuleRequestAccountTokens + .AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + AuthRuleV2CreateParams + .CreateAuthRuleRequestAccountTokens + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + AuthRuleV2CreateParams + .CreateAuthRuleRequestAccountTokens + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + AuthRuleV2CreateParams + .CreateAuthRuleRequestAccountTokens + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + AuthRuleV2CreateParams + .CreateAuthRuleRequestAccountTokens + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .type( + AuthRuleV2CreateParams.CreateAuthRuleRequestAccountTokens.AuthRuleType + .CONDITIONAL_BLOCK + ) + .build() + ) + .build() + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2DraftParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2DraftParamsTest.kt new file mode 100644 index 00000000..9d18115a --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2DraftParamsTest.kt @@ -0,0 +1,158 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AuthRuleV2DraftParamsTest { + + @Test + fun createAuthRuleV2DraftParams() { + AuthRuleV2DraftParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .parameters( + AuthRuleV2DraftParams.AuthRuleParameters.ofConditionalBlockParameters( + AuthRuleV2DraftParams.AuthRuleParameters.ConditionalBlockParameters.builder() + .conditions( + listOf( + AuthRuleV2DraftParams.AuthRuleParameters.ConditionalBlockParameters + .Condition + .builder() + .attribute( + AuthRuleV2DraftParams.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + AuthRuleV2DraftParams.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + AuthRuleV2DraftParams.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .build() + } + + @Test + fun getBody() { + val params = + AuthRuleV2DraftParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .parameters( + AuthRuleV2DraftParams.AuthRuleParameters.ofConditionalBlockParameters( + AuthRuleV2DraftParams.AuthRuleParameters.ConditionalBlockParameters + .builder() + .conditions( + listOf( + AuthRuleV2DraftParams.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + AuthRuleV2DraftParams.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + AuthRuleV2DraftParams.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + AuthRuleV2DraftParams.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.parameters()) + .isEqualTo( + AuthRuleV2DraftParams.AuthRuleParameters.ofConditionalBlockParameters( + AuthRuleV2DraftParams.AuthRuleParameters.ConditionalBlockParameters.builder() + .conditions( + listOf( + AuthRuleV2DraftParams.AuthRuleParameters.ConditionalBlockParameters + .Condition + .builder() + .attribute( + AuthRuleV2DraftParams.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + AuthRuleV2DraftParams.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + AuthRuleV2DraftParams.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + AuthRuleV2DraftParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + } + + @Test + fun getPathParam() { + val params = + AuthRuleV2DraftParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "authRuleToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListParamsTest.kt new file mode 100644 index 00000000..20ded119 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListParamsTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AuthRuleV2ListParamsTest { + + @Test + fun createAuthRuleV2ListParams() { + AuthRuleV2ListParams.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endingBefore("ending_before") + .pageSize(100L) + .startingAfter("starting_after") + .build() + } + + @Test + fun getQueryParams() { + val params = + AuthRuleV2ListParams.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .endingBefore("ending_before") + .pageSize(100L) + .startingAfter("starting_after") + .build() + val expected = mutableMapOf>() + expected.put("account_token", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("card_token", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("ending_before", listOf("ending_before")) + expected.put("page_size", listOf("100")) + expected.put("starting_after", listOf("starting_after")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = AuthRuleV2ListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2PromoteParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2PromoteParamsTest.kt new file mode 100644 index 00000000..90cc5365 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2PromoteParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AuthRuleV2PromoteParamsTest { + + @Test + fun createAuthRuleV2PromoteParams() { + AuthRuleV2PromoteParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + AuthRuleV2PromoteParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "authRuleToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ReportParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ReportParamsTest.kt new file mode 100644 index 00000000..2a215054 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ReportParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AuthRuleV2ReportParamsTest { + + @Test + fun createAuthRuleV2ReportParams() { + AuthRuleV2ReportParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + AuthRuleV2ReportParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "authRuleToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2RetrieveParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2RetrieveParamsTest.kt new file mode 100644 index 00000000..2af1bc57 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2RetrieveParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AuthRuleV2RetrieveParamsTest { + + @Test + fun createAuthRuleV2RetrieveParams() { + AuthRuleV2RetrieveParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + AuthRuleV2RetrieveParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "authRuleToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2UpdateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2UpdateParamsTest.kt new file mode 100644 index 00000000..74a6b3ca --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2UpdateParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AuthRuleV2UpdateParamsTest { + + @Test + fun createAuthRuleV2UpdateParams() { + AuthRuleV2UpdateParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .state(AuthRuleV2UpdateParams.State.INACTIVE) + .build() + } + + @Test + fun getBody() { + val params = + AuthRuleV2UpdateParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .state(AuthRuleV2UpdateParams.State.INACTIVE) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.state()).isEqualTo(AuthRuleV2UpdateParams.State.INACTIVE) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + AuthRuleV2UpdateParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + } + + @Test + fun getPathParam() { + val params = + AuthRuleV2UpdateParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "authRuleToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentCancelParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentCancelParamsTest.kt new file mode 100644 index 00000000..05446eae --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentCancelParamsTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ExternalPaymentCancelParamsTest { + + @Test + fun createExternalPaymentCancelParams() { + ExternalPaymentCancelParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .build() + } + + @Test + fun getBody() { + val params = + ExternalPaymentCancelParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.effectiveDate()).isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(body.memo()).isEqualTo("memo") + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ExternalPaymentCancelParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.effectiveDate()).isEqualTo(LocalDate.parse("2019-12-27")) + } + + @Test + fun getPathParam() { + val params = + ExternalPaymentCancelParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .build() + assertThat(params).isNotNull + // path param "externalPaymentToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentCreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentCreateParamsTest.kt new file mode 100644 index 00000000..b2ddacf0 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentCreateParamsTest.kt @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ExternalPaymentCreateParamsTest { + + @Test + fun createExternalPaymentCreateParams() { + ExternalPaymentCreateParams.builder() + .amount(123L) + .category(ExternalPaymentCreateParams.ExternalPaymentCategory.EXTERNAL_WIRE) + .effectiveDate(LocalDate.parse("2019-12-27")) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPaymentCreateParams.ExternalPaymentDirection.DEPOSIT) + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .memo("memo") + .progressTo(ExternalPaymentCreateParams.ExternalPaymentProgressTo.SETTLED) + .userDefinedId("user_defined_id") + .build() + } + + @Test + fun getBody() { + val params = + ExternalPaymentCreateParams.builder() + .amount(123L) + .category(ExternalPaymentCreateParams.ExternalPaymentCategory.EXTERNAL_WIRE) + .effectiveDate(LocalDate.parse("2019-12-27")) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPaymentCreateParams.ExternalPaymentDirection.DEPOSIT) + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .memo("memo") + .progressTo(ExternalPaymentCreateParams.ExternalPaymentProgressTo.SETTLED) + .userDefinedId("user_defined_id") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.amount()).isEqualTo(123L) + assertThat(body.category()) + .isEqualTo(ExternalPaymentCreateParams.ExternalPaymentCategory.EXTERNAL_WIRE) + assertThat(body.effectiveDate()).isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(body.financialAccountToken()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.paymentType()) + .isEqualTo(ExternalPaymentCreateParams.ExternalPaymentDirection.DEPOSIT) + assertThat(body.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.memo()).isEqualTo("memo") + assertThat(body.progressTo()) + .isEqualTo(ExternalPaymentCreateParams.ExternalPaymentProgressTo.SETTLED) + assertThat(body.userDefinedId()).isEqualTo("user_defined_id") + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ExternalPaymentCreateParams.builder() + .amount(123L) + .category(ExternalPaymentCreateParams.ExternalPaymentCategory.EXTERNAL_WIRE) + .effectiveDate(LocalDate.parse("2019-12-27")) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPaymentCreateParams.ExternalPaymentDirection.DEPOSIT) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.amount()).isEqualTo(123L) + assertThat(body.category()) + .isEqualTo(ExternalPaymentCreateParams.ExternalPaymentCategory.EXTERNAL_WIRE) + assertThat(body.effectiveDate()).isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(body.financialAccountToken()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.paymentType()) + .isEqualTo(ExternalPaymentCreateParams.ExternalPaymentDirection.DEPOSIT) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentListParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentListParamsTest.kt new file mode 100644 index 00000000..4878b12e --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentListParamsTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ExternalPaymentListParamsTest { + + @Test + fun createExternalPaymentListParams() { + ExternalPaymentListParams.builder() + .begin(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ExternalPaymentListParams.ExternalPaymentCategory.EXTERNAL_WIRE) + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endingBefore("ending_before") + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pageSize(100L) + .result(ExternalPaymentListParams.TransactionResult.APPROVED) + .startingAfter("starting_after") + .status(ExternalPaymentListParams.TransactionStatus.PENDING) + .build() + } + + @Test + fun getQueryParams() { + val params = + ExternalPaymentListParams.builder() + .begin(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ExternalPaymentListParams.ExternalPaymentCategory.EXTERNAL_WIRE) + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endingBefore("ending_before") + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pageSize(100L) + .result(ExternalPaymentListParams.TransactionResult.APPROVED) + .startingAfter("starting_after") + .status(ExternalPaymentListParams.TransactionStatus.PENDING) + .build() + val expected = mutableMapOf>() + expected.put("begin", listOf("2019-12-27T18:11:19.117Z")) + expected.put( + "category", + listOf(ExternalPaymentListParams.ExternalPaymentCategory.EXTERNAL_WIRE.toString()) + ) + expected.put("end", listOf("2019-12-27T18:11:19.117Z")) + expected.put("ending_before", listOf("ending_before")) + expected.put("financial_account_token", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + expected.put("page_size", listOf("100")) + expected.put( + "result", + listOf(ExternalPaymentListParams.TransactionResult.APPROVED.toString()) + ) + expected.put("starting_after", listOf("starting_after")) + expected.put( + "status", + listOf(ExternalPaymentListParams.TransactionStatus.PENDING.toString()) + ) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = ExternalPaymentListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentReleaseParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentReleaseParamsTest.kt new file mode 100644 index 00000000..fbc4bed1 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentReleaseParamsTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ExternalPaymentReleaseParamsTest { + + @Test + fun createExternalPaymentReleaseParams() { + ExternalPaymentReleaseParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .build() + } + + @Test + fun getBody() { + val params = + ExternalPaymentReleaseParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.effectiveDate()).isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(body.memo()).isEqualTo("memo") + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ExternalPaymentReleaseParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.effectiveDate()).isEqualTo(LocalDate.parse("2019-12-27")) + } + + @Test + fun getPathParam() { + val params = + ExternalPaymentReleaseParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .build() + assertThat(params).isNotNull + // path param "externalPaymentToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentRetrieveParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentRetrieveParamsTest.kt new file mode 100644 index 00000000..2f784875 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentRetrieveParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ExternalPaymentRetrieveParamsTest { + + @Test + fun createExternalPaymentRetrieveParams() { + ExternalPaymentRetrieveParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + ExternalPaymentRetrieveParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "externalPaymentToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentReverseParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentReverseParamsTest.kt new file mode 100644 index 00000000..1415dfda --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentReverseParamsTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ExternalPaymentReverseParamsTest { + + @Test + fun createExternalPaymentReverseParams() { + ExternalPaymentReverseParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .build() + } + + @Test + fun getBody() { + val params = + ExternalPaymentReverseParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.effectiveDate()).isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(body.memo()).isEqualTo("memo") + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ExternalPaymentReverseParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.effectiveDate()).isEqualTo(LocalDate.parse("2019-12-27")) + } + + @Test + fun getPathParam() { + val params = + ExternalPaymentReverseParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .build() + assertThat(params).isNotNull + // path param "externalPaymentToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentSettleParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentSettleParamsTest.kt new file mode 100644 index 00000000..327d8a9f --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentSettleParamsTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ExternalPaymentSettleParamsTest { + + @Test + fun createExternalPaymentSettleParams() { + ExternalPaymentSettleParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .progressTo(ExternalPaymentSettleParams.ExternalPaymentProgressTo.SETTLED) + .build() + } + + @Test + fun getBody() { + val params = + ExternalPaymentSettleParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .progressTo(ExternalPaymentSettleParams.ExternalPaymentProgressTo.SETTLED) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.effectiveDate()).isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(body.memo()).isEqualTo("memo") + assertThat(body.progressTo()) + .isEqualTo(ExternalPaymentSettleParams.ExternalPaymentProgressTo.SETTLED) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ExternalPaymentSettleParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.effectiveDate()).isEqualTo(LocalDate.parse("2019-12-27")) + } + + @Test + fun getPathParam() { + val params = + ExternalPaymentSettleParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .build() + assertThat(params).isNotNull + // path param "externalPaymentToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentTest.kt new file mode 100644 index 00000000..862f52a5 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentTest.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ExternalPaymentTest { + + @Test + fun createExternalPayment() { + val externalPayment = + ExternalPayment.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .events( + listOf( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(123L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .detailedResults( + listOf( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + ) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + .pendingAmount(123L) + .result(ExternalPayment.TransactionResult.APPROVED) + .settledAmount(123L) + .status(ExternalPayment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .userDefinedId("user_defined_id") + .build() + assertThat(externalPayment).isNotNull + assertThat(externalPayment.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(externalPayment.category()) + .isEqualTo(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + assertThat(externalPayment.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(externalPayment.currency()).isEqualTo("currency") + assertThat(externalPayment.events()) + .containsExactly( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(123L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .detailedResults( + listOf(ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED) + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + assertThat(externalPayment.financialAccountToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(externalPayment.paymentType()) + .isEqualTo(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + assertThat(externalPayment.pendingAmount()).isEqualTo(123L) + assertThat(externalPayment.result()).isEqualTo(ExternalPayment.TransactionResult.APPROVED) + assertThat(externalPayment.settledAmount()).isEqualTo(123L) + assertThat(externalPayment.status()).isEqualTo(ExternalPayment.TransactionStatus.PENDING) + assertThat(externalPayment.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(externalPayment.userDefinedId()).contains("user_defined_id") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountCreditConfigTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountCreditConfigTest.kt index ad2666f3..874a33d8 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountCreditConfigTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountCreditConfigTest.kt @@ -15,8 +15,8 @@ class FinancialAccountCreditConfigTest { .creditLimit(123L) .creditProductToken("credit_product_token") .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .financialAccountState("financial_account_state") .tier("tier") + .financialAccountState(FinancialAccountCreditConfig.FinancialAccountState.PENDING) .build() assertThat(financialAccountCreditConfig).isNotNull assertThat(financialAccountCreditConfig.accountToken()) @@ -26,8 +26,8 @@ class FinancialAccountCreditConfigTest { .contains("credit_product_token") assertThat(financialAccountCreditConfig.externalBankAccountToken()) .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(financialAccountCreditConfig.financialAccountState()) - .contains("financial_account_state") assertThat(financialAccountCreditConfig.tier()).contains("tier") + assertThat(financialAccountCreditConfig.financialAccountState()) + .contains(FinancialAccountCreditConfig.FinancialAccountState.PENDING) } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountTest.kt index db92a4cb..e97dd6d8 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountTest.kt @@ -12,27 +12,51 @@ class FinancialAccountTest { fun createFinancialAccount() { val financialAccount = FinancialAccount.builder() - .token("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .token("b68b7424-aa69-4cbc-a946-30d90181b621") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditConfiguration( + FinancialAccount.FinancialAccountCreditConfig.builder() + .creditLimit(123L) + .creditProductToken("credit_product_token") + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tier("tier") + .financialAccountState( + FinancialAccount.FinancialAccountCreditConfig.FinancialAccountState + .PENDING + ) + .build() + ) .isForBenefitOf(true) + .nickname("nickname") .type(FinancialAccount.Type.ISSUING) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .accountNumber("account_number") - .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .nickname("nickname") .routingNumber("routing_number") .build() assertThat(financialAccount).isNotNull - assertThat(financialAccount.token()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(financialAccount.token()).isEqualTo("b68b7424-aa69-4cbc-a946-30d90181b621") + assertThat(financialAccount.accountToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(financialAccount.created()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(financialAccount.creditConfiguration()) + .contains( + FinancialAccount.FinancialAccountCreditConfig.builder() + .creditLimit(123L) + .creditProductToken("credit_product_token") + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tier("tier") + .financialAccountState( + FinancialAccount.FinancialAccountCreditConfig.FinancialAccountState.PENDING + ) + .build() + ) assertThat(financialAccount.isForBenefitOf()).isEqualTo(true) + assertThat(financialAccount.nickname()).contains("nickname") assertThat(financialAccount.type()).isEqualTo(FinancialAccount.Type.ISSUING) assertThat(financialAccount.updated()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(financialAccount.accountNumber()).contains("account_number") - assertThat(financialAccount.accountToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(financialAccount.nickname()).contains("nickname") assertThat(financialAccount.routingNumber()).contains("routing_number") } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/KybTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/KybTest.kt index abc2ce2a..b350a9ae 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/KybTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/KybTest.kt @@ -18,9 +18,9 @@ class KybTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -39,9 +39,9 @@ class KybTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -60,9 +60,9 @@ class KybTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -79,9 +79,9 @@ class KybTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -108,9 +108,9 @@ class KybTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -128,9 +128,9 @@ class KybTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -149,9 +149,9 @@ class KybTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -169,9 +169,9 @@ class KybTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/KycExemptTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/KycExemptTest.kt index 9624f18c..7230e7f3 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/KycExemptTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/KycExemptTest.kt @@ -15,9 +15,9 @@ class KycExemptTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -36,9 +36,9 @@ class KycExemptTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/KycTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/KycTest.kt index 701992d9..5897f134 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/KycTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/KycTest.kt @@ -17,9 +17,9 @@ class KycTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -44,9 +44,9 @@ class KycTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/RequiredDocumentTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/RequiredDocumentTest.kt new file mode 100644 index 00000000..f70f81fc --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/RequiredDocumentTest.kt @@ -0,0 +1,23 @@ +// 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 + +class RequiredDocumentTest { + + @Test + fun createRequiredDocument() { + val requiredDocument = + RequiredDocument.builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .statusReasons(listOf("string")) + .validDocuments(listOf("string")) + .build() + assertThat(requiredDocument).isNotNull + assertThat(requiredDocument.entityToken()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(requiredDocument.statusReasons()).containsExactly("string") + assertThat(requiredDocument.validDocuments()).containsExactly("string") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ApplyResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ApplyResponseTest.kt new file mode 100644 index 00000000..76f9c2a9 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ApplyResponseTest.kt @@ -0,0 +1,218 @@ +// 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 + +class V2ApplyResponseTest { + + @Test + fun createV2ApplyResponse() { + val v2ApplyResponse = + V2ApplyResponse.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .cardTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .currentVersion( + V2ApplyResponse.CurrentVersion.builder() + .parameters( + V2ApplyResponse.CurrentVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2ApplyResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2ApplyResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2ApplyResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2ApplyResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2ApplyResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + .draftVersion( + V2ApplyResponse.DraftVersion.builder() + .parameters( + V2ApplyResponse.DraftVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2ApplyResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2ApplyResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2ApplyResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2ApplyResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2ApplyResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + .programLevel(true) + .state(V2ApplyResponse.AuthRuleState.ACTIVE) + .type(V2ApplyResponse.AuthRuleType.CONDITIONAL_BLOCK) + .build() + assertThat(v2ApplyResponse).isNotNull + assertThat(v2ApplyResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2ApplyResponse.accountTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2ApplyResponse.cardTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2ApplyResponse.currentVersion()) + .contains( + V2ApplyResponse.CurrentVersion.builder() + .parameters( + V2ApplyResponse.CurrentVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2ApplyResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2ApplyResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2ApplyResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2ApplyResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2ApplyResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + assertThat(v2ApplyResponse.draftVersion()) + .contains( + V2ApplyResponse.DraftVersion.builder() + .parameters( + V2ApplyResponse.DraftVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2ApplyResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2ApplyResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2ApplyResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2ApplyResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2ApplyResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + assertThat(v2ApplyResponse.programLevel()).isEqualTo(true) + assertThat(v2ApplyResponse.state()).isEqualTo(V2ApplyResponse.AuthRuleState.ACTIVE) + assertThat(v2ApplyResponse.type()).isEqualTo(V2ApplyResponse.AuthRuleType.CONDITIONAL_BLOCK) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2CreateResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2CreateResponseTest.kt new file mode 100644 index 00000000..81ec51c3 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2CreateResponseTest.kt @@ -0,0 +1,219 @@ +// 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 + +class V2CreateResponseTest { + + @Test + fun createV2CreateResponse() { + val v2CreateResponse = + V2CreateResponse.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .cardTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .currentVersion( + V2CreateResponse.CurrentVersion.builder() + .parameters( + V2CreateResponse.CurrentVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2CreateResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2CreateResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2CreateResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2CreateResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2CreateResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + .draftVersion( + V2CreateResponse.DraftVersion.builder() + .parameters( + V2CreateResponse.DraftVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2CreateResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2CreateResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2CreateResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2CreateResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2CreateResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + .programLevel(true) + .state(V2CreateResponse.AuthRuleState.ACTIVE) + .type(V2CreateResponse.AuthRuleType.CONDITIONAL_BLOCK) + .build() + assertThat(v2CreateResponse).isNotNull + assertThat(v2CreateResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2CreateResponse.accountTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2CreateResponse.cardTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2CreateResponse.currentVersion()) + .contains( + V2CreateResponse.CurrentVersion.builder() + .parameters( + V2CreateResponse.CurrentVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2CreateResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2CreateResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2CreateResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2CreateResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2CreateResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + assertThat(v2CreateResponse.draftVersion()) + .contains( + V2CreateResponse.DraftVersion.builder() + .parameters( + V2CreateResponse.DraftVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2CreateResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2CreateResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2CreateResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2CreateResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2CreateResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + assertThat(v2CreateResponse.programLevel()).isEqualTo(true) + assertThat(v2CreateResponse.state()).isEqualTo(V2CreateResponse.AuthRuleState.ACTIVE) + assertThat(v2CreateResponse.type()) + .isEqualTo(V2CreateResponse.AuthRuleType.CONDITIONAL_BLOCK) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2DraftResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2DraftResponseTest.kt new file mode 100644 index 00000000..aa800a3c --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2DraftResponseTest.kt @@ -0,0 +1,218 @@ +// 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 + +class V2DraftResponseTest { + + @Test + fun createV2DraftResponse() { + val v2DraftResponse = + V2DraftResponse.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .cardTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .currentVersion( + V2DraftResponse.CurrentVersion.builder() + .parameters( + V2DraftResponse.CurrentVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2DraftResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2DraftResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2DraftResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2DraftResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2DraftResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + .draftVersion( + V2DraftResponse.DraftVersion.builder() + .parameters( + V2DraftResponse.DraftVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2DraftResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2DraftResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2DraftResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2DraftResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2DraftResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + .programLevel(true) + .state(V2DraftResponse.AuthRuleState.ACTIVE) + .type(V2DraftResponse.AuthRuleType.CONDITIONAL_BLOCK) + .build() + assertThat(v2DraftResponse).isNotNull + assertThat(v2DraftResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2DraftResponse.accountTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2DraftResponse.cardTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2DraftResponse.currentVersion()) + .contains( + V2DraftResponse.CurrentVersion.builder() + .parameters( + V2DraftResponse.CurrentVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2DraftResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2DraftResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2DraftResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2DraftResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2DraftResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + assertThat(v2DraftResponse.draftVersion()) + .contains( + V2DraftResponse.DraftVersion.builder() + .parameters( + V2DraftResponse.DraftVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2DraftResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2DraftResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2DraftResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2DraftResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2DraftResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + assertThat(v2DraftResponse.programLevel()).isEqualTo(true) + assertThat(v2DraftResponse.state()).isEqualTo(V2DraftResponse.AuthRuleState.ACTIVE) + assertThat(v2DraftResponse.type()).isEqualTo(V2DraftResponse.AuthRuleType.CONDITIONAL_BLOCK) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ListResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ListResponseTest.kt new file mode 100644 index 00000000..40298c08 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ListResponseTest.kt @@ -0,0 +1,214 @@ +// 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 + +class V2ListResponseTest { + + @Test + fun createV2ListResponse() { + val v2ListResponse = + V2ListResponse.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .cardTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .currentVersion( + V2ListResponse.CurrentVersion.builder() + .parameters( + V2ListResponse.CurrentVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2ListResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2ListResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2ListResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2ListResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2ListResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + .draftVersion( + V2ListResponse.DraftVersion.builder() + .parameters( + V2ListResponse.DraftVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2ListResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2ListResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2ListResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2ListResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2ListResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + .programLevel(true) + .state(V2ListResponse.AuthRuleState.ACTIVE) + .type(V2ListResponse.AuthRuleType.CONDITIONAL_BLOCK) + .build() + assertThat(v2ListResponse).isNotNull + assertThat(v2ListResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2ListResponse.accountTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2ListResponse.cardTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2ListResponse.currentVersion()) + .contains( + V2ListResponse.CurrentVersion.builder() + .parameters( + V2ListResponse.CurrentVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2ListResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2ListResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2ListResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2ListResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2ListResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + assertThat(v2ListResponse.draftVersion()) + .contains( + V2ListResponse.DraftVersion.builder() + .parameters( + V2ListResponse.DraftVersion.AuthRuleParameters.ofConditionalBlockParameters( + V2ListResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2ListResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2ListResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2ListResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2ListResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + assertThat(v2ListResponse.programLevel()).isEqualTo(true) + assertThat(v2ListResponse.state()).isEqualTo(V2ListResponse.AuthRuleState.ACTIVE) + assertThat(v2ListResponse.type()).isEqualTo(V2ListResponse.AuthRuleType.CONDITIONAL_BLOCK) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2PromoteResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2PromoteResponseTest.kt new file mode 100644 index 00000000..38d35fa0 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2PromoteResponseTest.kt @@ -0,0 +1,222 @@ +// 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 + +class V2PromoteResponseTest { + + @Test + fun createV2PromoteResponse() { + val v2PromoteResponse = + V2PromoteResponse.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .cardTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .currentVersion( + V2PromoteResponse.CurrentVersion.builder() + .parameters( + V2PromoteResponse.CurrentVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2PromoteResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2PromoteResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2PromoteResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2PromoteResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2PromoteResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + .draftVersion( + V2PromoteResponse.DraftVersion.builder() + .parameters( + V2PromoteResponse.DraftVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2PromoteResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2PromoteResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2PromoteResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2PromoteResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2PromoteResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + .programLevel(true) + .state(V2PromoteResponse.AuthRuleState.ACTIVE) + .type(V2PromoteResponse.AuthRuleType.CONDITIONAL_BLOCK) + .build() + assertThat(v2PromoteResponse).isNotNull + assertThat(v2PromoteResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2PromoteResponse.accountTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2PromoteResponse.cardTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2PromoteResponse.currentVersion()) + .contains( + V2PromoteResponse.CurrentVersion.builder() + .parameters( + V2PromoteResponse.CurrentVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2PromoteResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2PromoteResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2PromoteResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2PromoteResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2PromoteResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + assertThat(v2PromoteResponse.draftVersion()) + .contains( + V2PromoteResponse.DraftVersion.builder() + .parameters( + V2PromoteResponse.DraftVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2PromoteResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2PromoteResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2PromoteResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2PromoteResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2PromoteResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + assertThat(v2PromoteResponse.programLevel()).isEqualTo(true) + assertThat(v2PromoteResponse.state()).isEqualTo(V2PromoteResponse.AuthRuleState.ACTIVE) + assertThat(v2PromoteResponse.type()) + .isEqualTo(V2PromoteResponse.AuthRuleType.CONDITIONAL_BLOCK) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ReportResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ReportResponseTest.kt new file mode 100644 index 00000000..5ef2d075 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ReportResponseTest.kt @@ -0,0 +1,17 @@ +// 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 + +class V2ReportResponseTest { + + @Test + fun createV2ReportResponse() { + val v2ReportResponse = + V2ReportResponse.builder().reportToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(v2ReportResponse).isNotNull + assertThat(v2ReportResponse.reportToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2RetrieveResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2RetrieveResponseTest.kt new file mode 100644 index 00000000..42216370 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2RetrieveResponseTest.kt @@ -0,0 +1,222 @@ +// 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 + +class V2RetrieveResponseTest { + + @Test + fun createV2RetrieveResponse() { + val v2RetrieveResponse = + V2RetrieveResponse.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .cardTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .currentVersion( + V2RetrieveResponse.CurrentVersion.builder() + .parameters( + V2RetrieveResponse.CurrentVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2RetrieveResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2RetrieveResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2RetrieveResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2RetrieveResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2RetrieveResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + .draftVersion( + V2RetrieveResponse.DraftVersion.builder() + .parameters( + V2RetrieveResponse.DraftVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2RetrieveResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2RetrieveResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2RetrieveResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2RetrieveResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2RetrieveResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + .programLevel(true) + .state(V2RetrieveResponse.AuthRuleState.ACTIVE) + .type(V2RetrieveResponse.AuthRuleType.CONDITIONAL_BLOCK) + .build() + assertThat(v2RetrieveResponse).isNotNull + assertThat(v2RetrieveResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2RetrieveResponse.accountTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2RetrieveResponse.cardTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2RetrieveResponse.currentVersion()) + .contains( + V2RetrieveResponse.CurrentVersion.builder() + .parameters( + V2RetrieveResponse.CurrentVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2RetrieveResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2RetrieveResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2RetrieveResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2RetrieveResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2RetrieveResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + assertThat(v2RetrieveResponse.draftVersion()) + .contains( + V2RetrieveResponse.DraftVersion.builder() + .parameters( + V2RetrieveResponse.DraftVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2RetrieveResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2RetrieveResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2RetrieveResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2RetrieveResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2RetrieveResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + assertThat(v2RetrieveResponse.programLevel()).isEqualTo(true) + assertThat(v2RetrieveResponse.state()).isEqualTo(V2RetrieveResponse.AuthRuleState.ACTIVE) + assertThat(v2RetrieveResponse.type()) + .isEqualTo(V2RetrieveResponse.AuthRuleType.CONDITIONAL_BLOCK) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2UpdateResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2UpdateResponseTest.kt new file mode 100644 index 00000000..3e6d8359 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2UpdateResponseTest.kt @@ -0,0 +1,219 @@ +// 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 + +class V2UpdateResponseTest { + + @Test + fun createV2UpdateResponse() { + val v2UpdateResponse = + V2UpdateResponse.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .cardTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .currentVersion( + V2UpdateResponse.CurrentVersion.builder() + .parameters( + V2UpdateResponse.CurrentVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2UpdateResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2UpdateResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2UpdateResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2UpdateResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2UpdateResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + .draftVersion( + V2UpdateResponse.DraftVersion.builder() + .parameters( + V2UpdateResponse.DraftVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2UpdateResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2UpdateResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2UpdateResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2UpdateResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2UpdateResponse.DraftVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + .programLevel(true) + .state(V2UpdateResponse.AuthRuleState.ACTIVE) + .type(V2UpdateResponse.AuthRuleType.CONDITIONAL_BLOCK) + .build() + assertThat(v2UpdateResponse).isNotNull + assertThat(v2UpdateResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2UpdateResponse.accountTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2UpdateResponse.cardTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(v2UpdateResponse.currentVersion()) + .contains( + V2UpdateResponse.CurrentVersion.builder() + .parameters( + V2UpdateResponse.CurrentVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2UpdateResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2UpdateResponse.CurrentVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2UpdateResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2UpdateResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2UpdateResponse.CurrentVersion + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + assertThat(v2UpdateResponse.draftVersion()) + .contains( + V2UpdateResponse.DraftVersion.builder() + .parameters( + V2UpdateResponse.DraftVersion.AuthRuleParameters + .ofConditionalBlockParameters( + V2UpdateResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + V2UpdateResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + V2UpdateResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + V2UpdateResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + V2UpdateResponse.DraftVersion.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .version(123L) + .build() + ) + assertThat(v2UpdateResponse.programLevel()).isEqualTo(true) + assertThat(v2UpdateResponse.state()).isEqualTo(V2UpdateResponse.AuthRuleState.ACTIVE) + assertThat(v2UpdateResponse.type()) + .isEqualTo(V2UpdateResponse.AuthRuleType.CONDITIONAL_BLOCK) + } +} 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 new file mode 100644 index 00000000..4f9aede7 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/VelocityLimitParamsTest.kt @@ -0,0 +1,39 @@ +// 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 + +class VelocityLimitParamsTest { + + @Test + fun createVelocityLimitParams() { + val velocityLimitParams = + VelocityLimitParams.builder() + .filters( + VelocityLimitParams.Filters.builder() + .includeCountries(listOf("USD")) + .includeMccs(listOf("5542")) + .build() + ) + .period(VelocityLimitParams.Period.ofDouble(42.23)) + .scope(VelocityLimitParams.Scope.CARD) + .limitAmount(42.23) + .limitCount(42.23) + .build() + assertThat(velocityLimitParams).isNotNull + assertThat(velocityLimitParams.filters()) + .isEqualTo( + VelocityLimitParams.Filters.builder() + .includeCountries(listOf("USD")) + .includeMccs(listOf("5542")) + .build() + ) + assertThat(velocityLimitParams.period()) + .isEqualTo(VelocityLimitParams.Period.ofDouble(42.23)) + assertThat(velocityLimitParams.scope()).isEqualTo(VelocityLimitParams.Scope.CARD) + assertThat(velocityLimitParams.limitAmount()).contains(42.23) + assertThat(velocityLimitParams.limitCount()).contains(42.23) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountHolderServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountHolderServiceTest.kt index 4d2f7806..8c1b6c2d 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountHolderServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountHolderServiceTest.kt @@ -32,9 +32,9 @@ class AccountHolderServiceTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -53,9 +53,9 @@ class AccountHolderServiceTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -74,9 +74,9 @@ class AccountHolderServiceTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -93,9 +93,9 @@ class AccountHolderServiceTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) @@ -211,9 +211,9 @@ class AccountHolderServiceTest { Address.builder() .address1("123 Old Forest Way") .city("Omaha") - .country("CAN") - .postalCode("M5V 1S8") - .state("ON") + .country("USA") + .postalCode("68022") + .state("NE") .address2("address2") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ExternalPaymentServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ExternalPaymentServiceTest.kt new file mode 100644 index 00000000..4d887114 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ExternalPaymentServiceTest.kt @@ -0,0 +1,154 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClient +import com.lithic.api.models.* +import com.lithic.api.models.ExternalPaymentListParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class ExternalPaymentServiceTest { + + @Test + fun callCreate() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val externalPaymentService = client.externalPayments() + val externalPayment = + externalPaymentService.create( + ExternalPaymentCreateParams.builder() + .amount(123L) + .category(ExternalPaymentCreateParams.ExternalPaymentCategory.EXTERNAL_WIRE) + .effectiveDate(LocalDate.parse("2019-12-27")) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPaymentCreateParams.ExternalPaymentDirection.DEPOSIT) + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .memo("memo") + .progressTo(ExternalPaymentCreateParams.ExternalPaymentProgressTo.SETTLED) + .userDefinedId("user_defined_id") + .build() + ) + println(externalPayment) + externalPayment.validate() + } + + @Test + fun callRetrieve() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val externalPaymentService = client.externalPayments() + val externalPayment = + externalPaymentService.retrieve( + ExternalPaymentRetrieveParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(externalPayment) + externalPayment.validate() + } + + @Test + fun callList() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val externalPaymentService = client.externalPayments() + val externalPaymentsResponse = + externalPaymentService.list(ExternalPaymentListParams.builder().build()) + println(externalPaymentsResponse) + externalPaymentsResponse.data().forEach { it.validate() } + } + + @Test + fun callCancel() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val externalPaymentService = client.externalPayments() + val externalPayment = + externalPaymentService.cancel( + ExternalPaymentCancelParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .build() + ) + println(externalPayment) + externalPayment.validate() + } + + @Test + fun callRelease() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val externalPaymentService = client.externalPayments() + val externalPayment = + externalPaymentService.release( + ExternalPaymentReleaseParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .build() + ) + println(externalPayment) + externalPayment.validate() + } + + @Test + fun callReverse() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val externalPaymentService = client.externalPayments() + val externalPayment = + externalPaymentService.reverse( + ExternalPaymentReverseParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .build() + ) + println(externalPayment) + externalPayment.validate() + } + + @Test + fun callSettle() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val externalPaymentService = client.externalPayments() + val externalPayment = + externalPaymentService.settle( + ExternalPaymentSettleParams.builder() + .externalPaymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .progressTo(ExternalPaymentSettleParams.ExternalPaymentProgressTo.SETTLED) + .build() + ) + println(externalPayment) + externalPayment.validate() + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceTest.kt index bc1c99ba..294dad15 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceTest.kt @@ -78,8 +78,9 @@ class FinancialAccountServiceTest { .apiKey("My Lithic API Key") .build() val financialAccountService = client.financialAccounts() - val response = financialAccountService.list(FinancialAccountListParams.builder().build()) - println(response) - response.data().forEach { it.validate() } + val financialAccountsResponse = + financialAccountService.list(FinancialAccountListParams.builder().build()) + println(financialAccountsResponse) + financialAccountsResponse.data().forEach { it.validate() } } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceTest.kt new file mode 100644 index 00000000..2fa3e07c --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceTest.kt @@ -0,0 +1,254 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.authRules + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClient +import com.lithic.api.models.* +import com.lithic.api.models.AuthRuleV2ListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class V2ServiceTest { + + @Test + fun callCreate() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val v2Service = client.authRules().v2() + val v2CreateResponse = + v2Service.create( + AuthRuleV2CreateParams.builder() + .forCreateAuthRuleRequestAccountTokens( + AuthRuleV2CreateParams.CreateAuthRuleRequestAccountTokens.builder() + .accountTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .parameters( + AuthRuleV2CreateParams.CreateAuthRuleRequestAccountTokens + .AuthRuleParameters + .ofConditionalBlockParameters( + AuthRuleV2CreateParams.CreateAuthRuleRequestAccountTokens + .AuthRuleParameters + .ConditionalBlockParameters + .builder() + .conditions( + listOf( + AuthRuleV2CreateParams + .CreateAuthRuleRequestAccountTokens + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + AuthRuleV2CreateParams + .CreateAuthRuleRequestAccountTokens + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + AuthRuleV2CreateParams + .CreateAuthRuleRequestAccountTokens + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + AuthRuleV2CreateParams + .CreateAuthRuleRequestAccountTokens + .AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .type( + AuthRuleV2CreateParams.CreateAuthRuleRequestAccountTokens + .AuthRuleType + .CONDITIONAL_BLOCK + ) + .build() + ) + .build() + ) + println(v2CreateResponse) + v2CreateResponse.validate() + } + + @Test + fun callRetrieve() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val v2Service = client.authRules().v2() + val v2RetrieveResponse = + v2Service.retrieve( + AuthRuleV2RetrieveParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(v2RetrieveResponse) + v2RetrieveResponse.validate() + } + + @Test + fun callUpdate() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val v2Service = client.authRules().v2() + val v2UpdateResponse = + v2Service.update( + AuthRuleV2UpdateParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .state(AuthRuleV2UpdateParams.State.INACTIVE) + .build() + ) + println(v2UpdateResponse) + v2UpdateResponse.validate() + } + + @Test + fun callList() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val v2Service = client.authRules().v2() + val response = v2Service.list(AuthRuleV2ListParams.builder().build()) + println(response) + response.data().forEach { it.validate() } + } + + @Test + fun callApply() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val v2Service = client.authRules().v2() + val v2ApplyResponse = + v2Service.apply( + AuthRuleV2ApplyParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .forApplyAuthRuleRequestAccountTokens( + AuthRuleV2ApplyParams.ApplyAuthRuleRequestAccountTokens.builder() + .accountTokens(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .build() + ) + .build() + ) + println(v2ApplyResponse) + v2ApplyResponse.validate() + } + + @Test + fun callDraft() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val v2Service = client.authRules().v2() + val v2DraftResponse = + v2Service.draft( + AuthRuleV2DraftParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .parameters( + AuthRuleV2DraftParams.AuthRuleParameters.ofConditionalBlockParameters( + AuthRuleV2DraftParams.AuthRuleParameters.ConditionalBlockParameters + .builder() + .conditions( + listOf( + AuthRuleV2DraftParams.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .builder() + .attribute( + AuthRuleV2DraftParams.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Attribute + .MCC + ) + .operation( + AuthRuleV2DraftParams.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Operation + .IS_ONE_OF + ) + .value( + AuthRuleV2DraftParams.AuthRuleParameters + .ConditionalBlockParameters + .Condition + .Value + .ofString("string") + ) + .build() + ) + ) + .build() + ) + ) + .build() + ) + println(v2DraftResponse) + v2DraftResponse.validate() + } + + @Test + fun callPromote() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val v2Service = client.authRules().v2() + val v2PromoteResponse = + v2Service.promote( + AuthRuleV2PromoteParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(v2PromoteResponse) + v2PromoteResponse.validate() + } + + @Test + fun callReport() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val v2Service = client.authRules().v2() + val v2ReportResponse = + v2Service.report( + AuthRuleV2ReportParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(v2ReportResponse) + v2ReportResponse.validate() + } +}