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

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

The 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.toImmutable
import com.lithic.api.errors.LithicInvalidDataException
import java.time.OffsetDateTime
import java.util.Objects

/** Balance */
@JsonDeserialize(builder = Balance.Builder::class)
@NoAutoDetect
class Balance
private constructor(
    private val availableAmount: JsonField,
    private val created: JsonField,
    private val currency: JsonField,
    private val financialAccountToken: JsonField,
    private val financialAccountType: JsonField,
    private val lastTransactionEventToken: JsonField,
    private val lastTransactionToken: JsonField,
    private val pendingAmount: JsonField,
    private val totalAmount: JsonField,
    private val updated: JsonField,
    private val additionalProperties: Map,
) {

    private var validated: Boolean = false

    /** Funds available for spend in the currency's smallest unit (e.g., cents for USD) */
    fun availableAmount(): Long = availableAmount.getRequired("available_amount")

    /** Date and time for when the balance was first created. */
    fun created(): OffsetDateTime = created.getRequired("created")

    /** 3-digit alphabetic ISO 4217 code for the local currency of the balance. */
    fun currency(): String = currency.getRequired("currency")

    /** Globally unique identifier for the financial account that holds this balance. */
    fun financialAccountToken(): String =
        financialAccountToken.getRequired("financial_account_token")

    /** Type of financial account. */
    fun financialAccountType(): FinancialAccountType =
        financialAccountType.getRequired("financial_account_type")

    /**
     * Globally unique identifier for the last financial transaction event that impacted this
     * balance.
     */
    fun lastTransactionEventToken(): String =
        lastTransactionEventToken.getRequired("last_transaction_event_token")

    /** Globally unique identifier for the last financial transaction that impacted this balance. */
    fun lastTransactionToken(): String = lastTransactionToken.getRequired("last_transaction_token")

    /**
     * Funds not available for spend due to card authorizations or pending ACH release. Shown in the
     * currency's smallest unit (e.g., cents for USD).
     */
    fun pendingAmount(): Long = pendingAmount.getRequired("pending_amount")

    /**
     * The sum of available and pending balance in the currency's smallest unit (e.g., cents for
     * USD).
     */
    fun totalAmount(): Long = totalAmount.getRequired("total_amount")

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

    /** Funds available for spend in the currency's smallest unit (e.g., cents for USD) */
    @JsonProperty("available_amount") @ExcludeMissing fun _availableAmount() = availableAmount

    /** Date and time for when the balance was first created. */
    @JsonProperty("created") @ExcludeMissing fun _created() = created

    /** 3-digit alphabetic ISO 4217 code for the local currency of the balance. */
    @JsonProperty("currency") @ExcludeMissing fun _currency() = currency

    /** Globally unique identifier for the financial account that holds this balance. */
    @JsonProperty("financial_account_token")
    @ExcludeMissing
    fun _financialAccountToken() = financialAccountToken

    /** Type of financial account. */
    @JsonProperty("financial_account_type")
    @ExcludeMissing
    fun _financialAccountType() = financialAccountType

    /**
     * Globally unique identifier for the last financial transaction event that impacted this
     * balance.
     */
    @JsonProperty("last_transaction_event_token")
    @ExcludeMissing
    fun _lastTransactionEventToken() = lastTransactionEventToken

    /** Globally unique identifier for the last financial transaction that impacted this balance. */
    @JsonProperty("last_transaction_token")
    @ExcludeMissing
    fun _lastTransactionToken() = lastTransactionToken

    /**
     * Funds not available for spend due to card authorizations or pending ACH release. Shown in the
     * currency's smallest unit (e.g., cents for USD).
     */
    @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount

    /**
     * The sum of available and pending balance in the currency's smallest unit (e.g., cents for
     * USD).
     */
    @JsonProperty("total_amount") @ExcludeMissing fun _totalAmount() = totalAmount

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

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

    fun validate(): Balance = apply {
        if (!validated) {
            availableAmount()
            created()
            currency()
            financialAccountToken()
            financialAccountType()
            lastTransactionEventToken()
            lastTransactionToken()
            pendingAmount()
            totalAmount()
            updated()
            validated = true
        }
    }

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

    companion object {

        fun builder() = Builder()
    }

    class Builder {

        private var availableAmount: JsonField = JsonMissing.of()
        private var created: JsonField = JsonMissing.of()
        private var currency: JsonField = JsonMissing.of()
        private var financialAccountToken: JsonField = JsonMissing.of()
        private var financialAccountType: JsonField = JsonMissing.of()
        private var lastTransactionEventToken: JsonField = JsonMissing.of()
        private var lastTransactionToken: JsonField = JsonMissing.of()
        private var pendingAmount: JsonField = JsonMissing.of()
        private var totalAmount: JsonField = JsonMissing.of()
        private var updated: JsonField = JsonMissing.of()
        private var additionalProperties: MutableMap = mutableMapOf()

        internal fun from(balance: Balance) = apply {
            this.availableAmount = balance.availableAmount
            this.created = balance.created
            this.currency = balance.currency
            this.financialAccountToken = balance.financialAccountToken
            this.financialAccountType = balance.financialAccountType
            this.lastTransactionEventToken = balance.lastTransactionEventToken
            this.lastTransactionToken = balance.lastTransactionToken
            this.pendingAmount = balance.pendingAmount
            this.totalAmount = balance.totalAmount
            this.updated = balance.updated
            additionalProperties(balance.additionalProperties)
        }

        /** Funds available for spend in the currency's smallest unit (e.g., cents for USD) */
        fun availableAmount(availableAmount: Long) = availableAmount(JsonField.of(availableAmount))

        /** Funds available for spend in the currency's smallest unit (e.g., cents for USD) */
        @JsonProperty("available_amount")
        @ExcludeMissing
        fun availableAmount(availableAmount: JsonField) = apply {
            this.availableAmount = availableAmount
        }

        /** Date and time for when the balance was first created. */
        fun created(created: OffsetDateTime) = created(JsonField.of(created))

        /** Date and time for when the balance was first created. */
        @JsonProperty("created")
        @ExcludeMissing
        fun created(created: JsonField) = apply { this.created = created }

        /** 3-digit alphabetic ISO 4217 code for the local currency of the balance. */
        fun currency(currency: String) = currency(JsonField.of(currency))

        /** 3-digit alphabetic ISO 4217 code for the local currency of the balance. */
        @JsonProperty("currency")
        @ExcludeMissing
        fun currency(currency: JsonField) = apply { this.currency = currency }

        /** Globally unique identifier for the financial account that holds this balance. */
        fun financialAccountToken(financialAccountToken: String) =
            financialAccountToken(JsonField.of(financialAccountToken))

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

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

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

        /**
         * Globally unique identifier for the last financial transaction event that impacted this
         * balance.
         */
        fun lastTransactionEventToken(lastTransactionEventToken: String) =
            lastTransactionEventToken(JsonField.of(lastTransactionEventToken))

        /**
         * Globally unique identifier for the last financial transaction event that impacted this
         * balance.
         */
        @JsonProperty("last_transaction_event_token")
        @ExcludeMissing
        fun lastTransactionEventToken(lastTransactionEventToken: JsonField) = apply {
            this.lastTransactionEventToken = lastTransactionEventToken
        }

        /**
         * Globally unique identifier for the last financial transaction that impacted this balance.
         */
        fun lastTransactionToken(lastTransactionToken: String) =
            lastTransactionToken(JsonField.of(lastTransactionToken))

        /**
         * Globally unique identifier for the last financial transaction that impacted this balance.
         */
        @JsonProperty("last_transaction_token")
        @ExcludeMissing
        fun lastTransactionToken(lastTransactionToken: JsonField) = apply {
            this.lastTransactionToken = lastTransactionToken
        }

        /**
         * Funds not available for spend due to card authorizations or pending ACH release. Shown in
         * the currency's smallest unit (e.g., cents for USD).
         */
        fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount))

        /**
         * Funds not available for spend due to card authorizations or pending ACH release. Shown in
         * the currency's smallest unit (e.g., cents for USD).
         */
        @JsonProperty("pending_amount")
        @ExcludeMissing
        fun pendingAmount(pendingAmount: JsonField) = apply {
            this.pendingAmount = pendingAmount
        }

        /**
         * The sum of available and pending balance in the currency's smallest unit (e.g., cents for
         * USD).
         */
        fun totalAmount(totalAmount: Long) = totalAmount(JsonField.of(totalAmount))

        /**
         * The sum of available and pending balance in the currency's smallest unit (e.g., cents for
         * USD).
         */
        @JsonProperty("total_amount")
        @ExcludeMissing
        fun totalAmount(totalAmount: JsonField) = apply { this.totalAmount = totalAmount }

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

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

        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(): Balance =
            Balance(
                availableAmount,
                created,
                currency,
                financialAccountToken,
                financialAccountType,
                lastTransactionEventToken,
                lastTransactionToken,
                pendingAmount,
                totalAmount,
                updated,
                additionalProperties.toImmutable(),
            )
    }

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

        override fun hashCode() = value.hashCode()

        override fun toString() = value.toString()

        companion object {

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

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

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

            fun of(value: String) = FinancialAccountType(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 FinancialAccountType: $value")
            }

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

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

        return /* spotless:off */ other is Balance && this.availableAmount == other.availableAmount && this.created == other.created && this.currency == other.currency && this.financialAccountToken == other.financialAccountToken && this.financialAccountType == other.financialAccountType && this.lastTransactionEventToken == other.lastTransactionEventToken && this.lastTransactionToken == other.lastTransactionToken && this.pendingAmount == other.pendingAmount && this.totalAmount == other.totalAmount && this.updated == other.updated && this.additionalProperties == other.additionalProperties /* spotless:on */
    }

    private var hashCode: Int = 0

    override fun hashCode(): Int {
        if (hashCode == 0) {
            hashCode = /* spotless:off */ Objects.hash(availableAmount, created, currency, financialAccountToken, financialAccountType, lastTransactionEventToken, lastTransactionToken, pendingAmount, totalAmount, updated, additionalProperties) /* spotless:on */
        }
        return hashCode
    }

    override fun toString() =
        "Balance{availableAmount=$availableAmount, created=$created, currency=$currency, financialAccountToken=$financialAccountToken, financialAccountType=$financialAccountType, lastTransactionEventToken=$lastTransactionEventToken, lastTransactionToken=$lastTransactionToken, pendingAmount=$pendingAmount, totalAmount=$totalAmount, updated=$updated, additionalProperties=$additionalProperties}"
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy