All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lithic.api.models.TokenizationSimulateParams.kt Maven / Gradle / Ivy

Go to download

The Lithic Developer API is designed to provide a predictable programmatic interface for accessing your Lithic account through an API and transaction webhooks. Note that your API key is a secret and should be treated as such. Don't share it with anyone, including us. We will never ask you for it.

There is a newer version: 0.71.0
Show newest version
// 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 TokenizationSimulateParams
constructor(
    private val cvv: String,
    private val expirationDate: String,
    private val pan: String,
    private val tokenizationSource: TokenizationSource,
    private val accountScore: Long?,
    private val deviceScore: Long?,
    private val entity: String?,
    private val walletRecommendedDecision: WalletRecommendedDecision?,
    private val additionalQueryParams: Map>,
    private val additionalHeaders: Map>,
    private val additionalBodyProperties: Map,
) {

    fun cvv(): String = cvv

    fun expirationDate(): String = expirationDate

    fun pan(): String = pan

    fun tokenizationSource(): TokenizationSource = tokenizationSource

    fun accountScore(): Optional = Optional.ofNullable(accountScore)

    fun deviceScore(): Optional = Optional.ofNullable(deviceScore)

    fun entity(): Optional = Optional.ofNullable(entity)

    fun walletRecommendedDecision(): Optional =
        Optional.ofNullable(walletRecommendedDecision)

    @JvmSynthetic
    internal fun getBody(): TokenizationSimulateBody {
        return TokenizationSimulateBody(
            cvv,
            expirationDate,
            pan,
            tokenizationSource,
            accountScore,
            deviceScore,
            entity,
            walletRecommendedDecision,
            additionalBodyProperties,
        )
    }

    @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams

    @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders

    @JsonDeserialize(builder = TokenizationSimulateBody.Builder::class)
    @NoAutoDetect
    class TokenizationSimulateBody
    internal constructor(
        private val cvv: String?,
        private val expirationDate: String?,
        private val pan: String?,
        private val tokenizationSource: TokenizationSource?,
        private val accountScore: Long?,
        private val deviceScore: Long?,
        private val entity: String?,
        private val walletRecommendedDecision: WalletRecommendedDecision?,
        private val additionalProperties: Map,
    ) {

        /** The three digit cvv for the card. */
        @JsonProperty("cvv") fun cvv(): String? = cvv

        /** The expiration date of the card in 'MM/YY' format. */
        @JsonProperty("expiration_date") fun expirationDate(): String? = expirationDate

        /** The sixteen digit card number. */
        @JsonProperty("pan") fun pan(): String? = pan

        /** The source of the tokenization request. */
        @JsonProperty("tokenization_source")
        fun tokenizationSource(): TokenizationSource? = tokenizationSource

        /**
         * The account score (1-5) that represents how the Digital Wallet's view on how reputable an
         * end user's account is.
         */
        @JsonProperty("account_score") fun accountScore(): Long? = accountScore

        /**
         * The device score (1-5) that represents how the Digital Wallet's view on how reputable an
         * end user's device is.
         */
        @JsonProperty("device_score") fun deviceScore(): Long? = deviceScore

        /**
         * Optional field to specify the token requestor name for a merchant token simulation.
         * Ignored when tokenization_source is not MERCHANT.
         */
        @JsonProperty("entity") fun entity(): String? = entity

        /** The decision that the Digital Wallet's recommend */
        @JsonProperty("wallet_recommended_decision")
        fun walletRecommendedDecision(): WalletRecommendedDecision? = walletRecommendedDecision

        @JsonAnyGetter
        @ExcludeMissing
        fun _additionalProperties(): Map = additionalProperties

        fun toBuilder() = Builder().from(this)

        companion object {

            @JvmStatic fun builder() = Builder()
        }

        class Builder {

            private var cvv: String? = null
            private var expirationDate: String? = null
            private var pan: String? = null
            private var tokenizationSource: TokenizationSource? = null
            private var accountScore: Long? = null
            private var deviceScore: Long? = null
            private var entity: String? = null
            private var walletRecommendedDecision: WalletRecommendedDecision? = null
            private var additionalProperties: MutableMap = mutableMapOf()

            @JvmSynthetic
            internal fun from(tokenizationSimulateBody: TokenizationSimulateBody) = apply {
                this.cvv = tokenizationSimulateBody.cvv
                this.expirationDate = tokenizationSimulateBody.expirationDate
                this.pan = tokenizationSimulateBody.pan
                this.tokenizationSource = tokenizationSimulateBody.tokenizationSource
                this.accountScore = tokenizationSimulateBody.accountScore
                this.deviceScore = tokenizationSimulateBody.deviceScore
                this.entity = tokenizationSimulateBody.entity
                this.walletRecommendedDecision = tokenizationSimulateBody.walletRecommendedDecision
                additionalProperties(tokenizationSimulateBody.additionalProperties)
            }

            /** The three digit cvv for the card. */
            @JsonProperty("cvv") fun cvv(cvv: String) = apply { this.cvv = cvv }

            /** The expiration date of the card in 'MM/YY' format. */
            @JsonProperty("expiration_date")
            fun expirationDate(expirationDate: String) = apply {
                this.expirationDate = expirationDate
            }

            /** The sixteen digit card number. */
            @JsonProperty("pan") fun pan(pan: String) = apply { this.pan = pan }

            /** The source of the tokenization request. */
            @JsonProperty("tokenization_source")
            fun tokenizationSource(tokenizationSource: TokenizationSource) = apply {
                this.tokenizationSource = tokenizationSource
            }

            /**
             * The account score (1-5) that represents how the Digital Wallet's view on how
             * reputable an end user's account is.
             */
            @JsonProperty("account_score")
            fun accountScore(accountScore: Long) = apply { this.accountScore = accountScore }

            /**
             * The device score (1-5) that represents how the Digital Wallet's view on how reputable
             * an end user's device is.
             */
            @JsonProperty("device_score")
            fun deviceScore(deviceScore: Long) = apply { this.deviceScore = deviceScore }

            /**
             * Optional field to specify the token requestor name for a merchant token simulation.
             * Ignored when tokenization_source is not MERCHANT.
             */
            @JsonProperty("entity") fun entity(entity: String) = apply { this.entity = entity }

            /** The decision that the Digital Wallet's recommend */
            @JsonProperty("wallet_recommended_decision")
            fun walletRecommendedDecision(walletRecommendedDecision: WalletRecommendedDecision) =
                apply {
                    this.walletRecommendedDecision = walletRecommendedDecision
                }

            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(): TokenizationSimulateBody =
                TokenizationSimulateBody(
                    checkNotNull(cvv) { "`cvv` is required but was not set" },
                    checkNotNull(expirationDate) { "`expirationDate` is required but was not set" },
                    checkNotNull(pan) { "`pan` is required but was not set" },
                    checkNotNull(tokenizationSource) {
                        "`tokenizationSource` is required but was not set"
                    },
                    accountScore,
                    deviceScore,
                    entity,
                    walletRecommendedDecision,
                    additionalProperties.toUnmodifiable(),
                )
        }

        override fun equals(other: Any?): Boolean {
            if (this === other) {
                return true
            }

            return /* spotless:off */ other is TokenizationSimulateBody && this.cvv == other.cvv && this.expirationDate == other.expirationDate && this.pan == other.pan && this.tokenizationSource == other.tokenizationSource && this.accountScore == other.accountScore && this.deviceScore == other.deviceScore && this.entity == other.entity && this.walletRecommendedDecision == other.walletRecommendedDecision && this.additionalProperties == other.additionalProperties /* spotless:on */
        }

        private var hashCode: Int = 0

        override fun hashCode(): Int {
            if (hashCode == 0) {
                hashCode = /* spotless:off */ Objects.hash(cvv, expirationDate, pan, tokenizationSource, accountScore, deviceScore, entity, walletRecommendedDecision, additionalProperties) /* spotless:on */
            }
            return hashCode
        }

        override fun toString() =
            "TokenizationSimulateBody{cvv=$cvv, expirationDate=$expirationDate, pan=$pan, tokenizationSource=$tokenizationSource, accountScore=$accountScore, deviceScore=$deviceScore, entity=$entity, walletRecommendedDecision=$walletRecommendedDecision, additionalProperties=$additionalProperties}"
    }

    fun _additionalQueryParams(): Map> = additionalQueryParams

    fun _additionalHeaders(): Map> = additionalHeaders

    fun _additionalBodyProperties(): Map = additionalBodyProperties

    override fun equals(other: Any?): Boolean {
        if (this === other) {
            return true
        }

        return /* spotless:off */ other is TokenizationSimulateParams && this.cvv == other.cvv && this.expirationDate == other.expirationDate && this.pan == other.pan && this.tokenizationSource == other.tokenizationSource && this.accountScore == other.accountScore && this.deviceScore == other.deviceScore && this.entity == other.entity && this.walletRecommendedDecision == other.walletRecommendedDecision && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */
    }

    override fun hashCode(): Int {
        return /* spotless:off */ Objects.hash(cvv, expirationDate, pan, tokenizationSource, accountScore, deviceScore, entity, walletRecommendedDecision, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */
    }

    override fun toString() =
        "TokenizationSimulateParams{cvv=$cvv, expirationDate=$expirationDate, pan=$pan, tokenizationSource=$tokenizationSource, accountScore=$accountScore, deviceScore=$deviceScore, entity=$entity, walletRecommendedDecision=$walletRecommendedDecision, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}"

    fun toBuilder() = Builder().from(this)

    companion object {

        @JvmStatic fun builder() = Builder()
    }

    @NoAutoDetect
    class Builder {

        private var cvv: String? = null
        private var expirationDate: String? = null
        private var pan: String? = null
        private var tokenizationSource: TokenizationSource? = null
        private var accountScore: Long? = null
        private var deviceScore: Long? = null
        private var entity: String? = null
        private var walletRecommendedDecision: WalletRecommendedDecision? = null
        private var additionalQueryParams: MutableMap> = mutableMapOf()
        private var additionalHeaders: MutableMap> = mutableMapOf()
        private var additionalBodyProperties: MutableMap = mutableMapOf()

        @JvmSynthetic
        internal fun from(tokenizationSimulateParams: TokenizationSimulateParams) = apply {
            this.cvv = tokenizationSimulateParams.cvv
            this.expirationDate = tokenizationSimulateParams.expirationDate
            this.pan = tokenizationSimulateParams.pan
            this.tokenizationSource = tokenizationSimulateParams.tokenizationSource
            this.accountScore = tokenizationSimulateParams.accountScore
            this.deviceScore = tokenizationSimulateParams.deviceScore
            this.entity = tokenizationSimulateParams.entity
            this.walletRecommendedDecision = tokenizationSimulateParams.walletRecommendedDecision
            additionalQueryParams(tokenizationSimulateParams.additionalQueryParams)
            additionalHeaders(tokenizationSimulateParams.additionalHeaders)
            additionalBodyProperties(tokenizationSimulateParams.additionalBodyProperties)
        }

        /** The three digit cvv for the card. */
        fun cvv(cvv: String) = apply { this.cvv = cvv }

        /** The expiration date of the card in 'MM/YY' format. */
        fun expirationDate(expirationDate: String) = apply { this.expirationDate = expirationDate }

        /** The sixteen digit card number. */
        fun pan(pan: String) = apply { this.pan = pan }

        /** The source of the tokenization request. */
        fun tokenizationSource(tokenizationSource: TokenizationSource) = apply {
            this.tokenizationSource = tokenizationSource
        }

        /**
         * The account score (1-5) that represents how the Digital Wallet's view on how reputable an
         * end user's account is.
         */
        fun accountScore(accountScore: Long) = apply { this.accountScore = accountScore }

        /**
         * The device score (1-5) that represents how the Digital Wallet's view on how reputable an
         * end user's device is.
         */
        fun deviceScore(deviceScore: Long) = apply { this.deviceScore = deviceScore }

        /**
         * Optional field to specify the token requestor name for a merchant token simulation.
         * Ignored when tokenization_source is not MERCHANT.
         */
        fun entity(entity: String) = apply { this.entity = entity }

        /** The decision that the Digital Wallet's recommend */
        fun walletRecommendedDecision(walletRecommendedDecision: WalletRecommendedDecision) =
            apply {
                this.walletRecommendedDecision = walletRecommendedDecision
            }

        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(): TokenizationSimulateParams =
            TokenizationSimulateParams(
                checkNotNull(cvv) { "`cvv` is required but was not set" },
                checkNotNull(expirationDate) { "`expirationDate` is required but was not set" },
                checkNotNull(pan) { "`pan` is required but was not set" },
                checkNotNull(tokenizationSource) {
                    "`tokenizationSource` is required but was not set"
                },
                accountScore,
                deviceScore,
                entity,
                walletRecommendedDecision,
                additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
                additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
                additionalBodyProperties.toUnmodifiable(),
            )
    }

    class TokenizationSource
    @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 /* spotless:off */ other is TokenizationSource && this.value == other.value /* spotless:on */
        }

        override fun hashCode() = value.hashCode()

        override fun toString() = value.toString()

        companion object {

            @JvmField val APPLE_PAY = TokenizationSource(JsonField.of("APPLE_PAY"))

            @JvmField val GOOGLE = TokenizationSource(JsonField.of("GOOGLE"))

            @JvmField val SAMSUNG_PAY = TokenizationSource(JsonField.of("SAMSUNG_PAY"))

            @JvmField val MERCHANT = TokenizationSource(JsonField.of("MERCHANT"))

            @JvmStatic fun of(value: String) = TokenizationSource(JsonField.of(value))
        }

        enum class Known {
            APPLE_PAY,
            GOOGLE,
            SAMSUNG_PAY,
            MERCHANT,
        }

        enum class Value {
            APPLE_PAY,
            GOOGLE,
            SAMSUNG_PAY,
            MERCHANT,
            _UNKNOWN,
        }

        fun value(): Value =
            when (this) {
                APPLE_PAY -> Value.APPLE_PAY
                GOOGLE -> Value.GOOGLE
                SAMSUNG_PAY -> Value.SAMSUNG_PAY
                MERCHANT -> Value.MERCHANT
                else -> Value._UNKNOWN
            }

        fun known(): Known =
            when (this) {
                APPLE_PAY -> Known.APPLE_PAY
                GOOGLE -> Known.GOOGLE
                SAMSUNG_PAY -> Known.SAMSUNG_PAY
                MERCHANT -> Known.MERCHANT
                else -> throw LithicInvalidDataException("Unknown TokenizationSource: $value")
            }

        fun asString(): String = _value().asStringOrThrow()
    }

    class WalletRecommendedDecision
    @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 /* spotless:off */ other is WalletRecommendedDecision && this.value == other.value /* spotless:on */
        }

        override fun hashCode() = value.hashCode()

        override fun toString() = value.toString()

        companion object {

            @JvmField val APPROVED = WalletRecommendedDecision(JsonField.of("APPROVED"))

            @JvmField val DECLINED = WalletRecommendedDecision(JsonField.of("DECLINED"))

            @JvmField
            val REQUIRE_ADDITIONAL_AUTHENTICATION =
                WalletRecommendedDecision(JsonField.of("REQUIRE_ADDITIONAL_AUTHENTICATION"))

            @JvmStatic fun of(value: String) = WalletRecommendedDecision(JsonField.of(value))
        }

        enum class Known {
            APPROVED,
            DECLINED,
            REQUIRE_ADDITIONAL_AUTHENTICATION,
        }

        enum class Value {
            APPROVED,
            DECLINED,
            REQUIRE_ADDITIONAL_AUTHENTICATION,
            _UNKNOWN,
        }

        fun value(): Value =
            when (this) {
                APPROVED -> Value.APPROVED
                DECLINED -> Value.DECLINED
                REQUIRE_ADDITIONAL_AUTHENTICATION -> Value.REQUIRE_ADDITIONAL_AUTHENTICATION
                else -> Value._UNKNOWN
            }

        fun known(): Known =
            when (this) {
                APPROVED -> Known.APPROVED
                DECLINED -> Known.DECLINED
                REQUIRE_ADDITIONAL_AUTHENTICATION -> Known.REQUIRE_ADDITIONAL_AUTHENTICATION
                else ->
                    throw LithicInvalidDataException("Unknown WalletRecommendedDecision: $value")
            }

        fun asString(): String = _value().asStringOrThrow()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy