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

com.lithic.api.models.FinancialAccountCreditConfig.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.61.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.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

@JsonDeserialize(builder = FinancialAccountCreditConfig.Builder::class)
@NoAutoDetect
class FinancialAccountCreditConfig
private constructor(
    private val accountToken: JsonField,
    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

    /** Globally unique identifier for the account */
    fun accountToken(): String = accountToken.getRequired("account_token")

    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"))

    /** Globally unique identifier for the account */
    @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken

    @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) {
            accountToken()
            creditLimit()
            externalBankAccountToken()
            creditProductToken()
            tier()
            financialAccountState()
            validated = true
        }
    }

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

    companion object {

        @JvmStatic fun builder() = Builder()
    }

    class Builder {

        private var accountToken: JsonField = JsonMissing.of()
        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.accountToken = financialAccountCreditConfig.accountToken
            this.creditLimit = financialAccountCreditConfig.creditLimit
            this.externalBankAccountToken = financialAccountCreditConfig.externalBankAccountToken
            this.creditProductToken = financialAccountCreditConfig.creditProductToken
            this.tier = financialAccountCreditConfig.tier
            this.financialAccountState = financialAccountCreditConfig.financialAccountState
            additionalProperties(financialAccountCreditConfig.additionalProperties)
        }

        /** Globally unique identifier for the account */
        fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken))

        /** Globally unique identifier for the account */
        @JsonProperty("account_token")
        @ExcludeMissing
        fun accountToken(accountToken: JsonField) = apply {
            this.accountToken = accountToken
        }

        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(
                accountToken,
                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()
    }

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

        return other is FinancialAccountCreditConfig &&
            this.accountToken == other.accountToken &&
            this.creditLimit == other.creditLimit &&
            this.externalBankAccountToken == other.externalBankAccountToken &&
            this.creditProductToken == other.creditProductToken &&
            this.tier == other.tier &&
            this.financialAccountState == other.financialAccountState &&
            this.additionalProperties == other.additionalProperties
    }

    private var hashCode: Int = 0

    override fun hashCode(): Int {
        if (hashCode == 0) {
            hashCode =
                Objects.hash(
                    accountToken,
                    creditLimit,
                    externalBankAccountToken,
                    creditProductToken,
                    tier,
                    financialAccountState,
                    additionalProperties,
                )
        }
        return hashCode
    }

    override fun toString() =
        "FinancialAccountCreditConfig{accountToken=$accountToken, creditLimit=$creditLimit, externalBankAccountToken=$externalBankAccountToken, creditProductToken=$creditProductToken, tier=$tier, financialAccountState=$financialAccountState, additionalProperties=$additionalProperties}"
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy