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

com.lithic.api.models.FinancialAccount.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.72.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.time.OffsetDateTime
import java.util.Objects

/** 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 updated: JsonField,
    private val isForBenefitOf: JsonField,
    private val additionalProperties: Map,
) {

    private var validated: Boolean = false

    private var hashCode: Int = 0

    /** Account number for your Lithic-assigned bank account number, if applicable. */
    fun accountNumber(): String? = accountNumber.getNullable("account_number")

    /** Account token of the financial account if applicable. */
    fun accountToken(): String? = accountToken.getNullable("account_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(): String? = nickname.getNullable("nickname")

    /** Routing number for your Lithic-assigned bank account number, if applicable. */
    fun routingNumber(): String? = routingNumber.getNullable("routing_number")

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

    /** Type of financial account */
    fun type(): Type = type.getRequired("type")

    /** Date and time for when the financial account was last updated. */
    fun updated(): OffsetDateTime = updated.getRequired("updated")

    /** Whether the financial account holds funds for benefit of another party. */
    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

    /** Account token of the financial account if applicable. */
    @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken

    /** 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

    /** 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

    /** Type of financial account */
    @JsonProperty("type") @ExcludeMissing fun _type() = type

    /** Date and time for when the financial account was last updated. */
    @JsonProperty("updated") @ExcludeMissing fun _updated() = updated

    /** Whether the financial account holds funds for benefit of another party. */
    @JsonProperty("is_for_benefit_of") @ExcludeMissing fun _isForBenefitOf() = isForBenefitOf

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

    fun validate(): FinancialAccount = apply {
        if (!validated) {
            accountNumber()
            accountToken()
            created()
            nickname()
            routingNumber()
            token()
            type()
            updated()
            isForBenefitOf()
            validated = true
        }
    }

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

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

        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.updated == other.updated &&
            this.isForBenefitOf == other.isForBenefitOf &&
            this.additionalProperties == other.additionalProperties
    }

    override fun hashCode(): Int {
        if (hashCode == 0) {
            hashCode =
                Objects.hash(
                    accountNumber,
                    accountToken,
                    created,
                    nickname,
                    routingNumber,
                    token,
                    type,
                    updated,
                    isForBenefitOf,
                    additionalProperties,
                )
        }
        return hashCode
    }

    override fun toString() =
        "FinancialAccount{accountNumber=$accountNumber, accountToken=$accountToken, created=$created, nickname=$nickname, routingNumber=$routingNumber, token=$token, type=$type, updated=$updated, isForBenefitOf=$isForBenefitOf, additionalProperties=$additionalProperties}"

    companion object {

        fun builder() = Builder()
    }

    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 updated: JsonField = JsonMissing.of()
        private var isForBenefitOf: JsonField = JsonMissing.of()
        private var additionalProperties: MutableMap = mutableMapOf()

        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.updated = financialAccount.updated
            this.isForBenefitOf = financialAccount.isForBenefitOf
            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))

        /** Account token of the financial account if applicable. */
        @JsonProperty("account_token")
        @ExcludeMissing
        fun accountToken(accountToken: JsonField) = apply {
            this.accountToken = accountToken
        }

        /** 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))

        /** User-defined nickname for the financial account. */
        @JsonProperty("nickname")
        @ExcludeMissing
        fun nickname(nickname: JsonField) = apply { this.nickname = nickname }

        /** 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))

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

        /** Type of financial account */
        fun type(type: Type) = type(JsonField.of(type))

        /** Type of financial account */
        @JsonProperty("type")
        @ExcludeMissing
        fun type(type: JsonField) = apply { this.type = type }

        /** Date and time for when the financial account was last updated. */
        fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated))

        /** Date and time for when the financial account was last updated. */
        @JsonProperty("updated")
        @ExcludeMissing
        fun updated(updated: JsonField) = apply { this.updated = updated }

        /** Whether the financial account holds funds for benefit of another party. */
        fun isForBenefitOf(isForBenefitOf: Boolean) = isForBenefitOf(JsonField.of(isForBenefitOf))

        /** Whether the financial account holds funds for benefit of another party. */
        @JsonProperty("is_for_benefit_of")
        @ExcludeMissing
        fun isForBenefitOf(isForBenefitOf: JsonField) = apply {
            this.isForBenefitOf = isForBenefitOf
        }

        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(): FinancialAccount =
            FinancialAccount(
                accountNumber,
                accountToken,
                created,
                nickname,
                routingNumber,
                token,
                type,
                updated,
                isForBenefitOf,
                additionalProperties.toUnmodifiable(),
            )
    }

    class Type
    @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 Type && this.value == other.value
        }

        override fun hashCode() = value.hashCode()

        override fun toString() = value.toString()

        companion object {

            val ISSUING = Type(JsonField.of("ISSUING"))

            val OPERATING = Type(JsonField.of("OPERATING"))

            val RESERVE = Type(JsonField.of("RESERVE"))

            fun of(value: String) = Type(JsonField.of(value))
        }

        enum class Known {
            ISSUING,
            OPERATING,
            RESERVE,
        }

        enum class Value {
            ISSUING,
            OPERATING,
            RESERVE,
            _UNKNOWN,
        }

        fun value(): Value =
            when (this) {
                ISSUING -> Value.ISSUING
                OPERATING -> Value.OPERATING
                RESERVE -> Value.RESERVE
                else -> Value._UNKNOWN
            }

        fun known(): Known =
            when (this) {
                ISSUING -> Known.ISSUING
                OPERATING -> Known.OPERATING
                RESERVE -> Known.RESERVE
                else -> throw LithicInvalidDataException("Unknown Type: $value")
            }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy