diff --git a/.stats.yml b/.stats.yml index e3378329..3e161690 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 89 +configured_endpoints: 102 diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt index 3af8c97d..35ae8997 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClient.kt @@ -50,6 +50,10 @@ interface LithicClient { fun threeDS(): ThreeDSService + fun reports(): ReportService + + fun cardProduct(): CardProductService + /** API status check */ fun apiStatus( params: ClientApiStatusParams, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt index 6e0c67e8..590bd4b1 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt @@ -50,6 +50,10 @@ interface LithicClientAsync { fun threeDS(): ThreeDSServiceAsync + fun reports(): ReportServiceAsync + + fun cardProduct(): CardProductServiceAsync + /** API status check */ suspend fun apiStatus( params: ClientApiStatusParams, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt index fa472561..69b63f5e 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt @@ -79,6 +79,12 @@ constructor( private val threeDS: ThreeDSServiceAsync by lazy { ThreeDSServiceAsyncImpl(clientOptions) } + private val reports: ReportServiceAsync by lazy { ReportServiceAsyncImpl(clientOptions) } + + private val cardProduct: CardProductServiceAsync by lazy { + CardProductServiceAsyncImpl(clientOptions) + } + override fun sync(): LithicClient = sync override fun accounts(): AccountServiceAsync = accounts @@ -120,6 +126,10 @@ constructor( override fun threeDS(): ThreeDSServiceAsync = threeDS + override fun reports(): ReportServiceAsync = reports + + override fun cardProduct(): CardProductServiceAsync = cardProduct + private val apiStatusHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt index 4f931548..fb8578ef 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt @@ -77,6 +77,10 @@ constructor( private val threeDS: ThreeDSService by lazy { ThreeDSServiceImpl(clientOptions) } + private val reports: ReportService by lazy { ReportServiceImpl(clientOptions) } + + private val cardProduct: CardProductService by lazy { CardProductServiceImpl(clientOptions) } + override fun async(): LithicClientAsync = async override fun accounts(): AccountService = accounts @@ -117,6 +121,10 @@ constructor( override fun threeDS(): ThreeDSService = threeDS + override fun reports(): ReportService = reports + + override fun cardProduct(): CardProductService = cardProduct + private val apiStatusHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountCreditConfigurationRetrieveParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountCreditConfigurationRetrieveParams.kt new file mode 100644 index 00000000..06327603 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountCreditConfigurationRetrieveParams.kt @@ -0,0 +1,127 @@ +// 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 AccountCreditConfigurationRetrieveParams +constructor( + private val accountToken: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun accountToken(): String = accountToken + + internal fun getQueryParams(): Map> = additionalQueryParams + + internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> accountToken + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccountCreditConfigurationRetrieveParams && + this.accountToken == other.accountToken && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders + } + + override fun hashCode(): Int { + return Objects.hash( + accountToken, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "AccountCreditConfigurationRetrieveParams{accountToken=$accountToken, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var accountToken: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + + internal fun from( + accountCreditConfigurationRetrieveParams: AccountCreditConfigurationRetrieveParams + ) = apply { + this.accountToken = accountCreditConfigurationRetrieveParams.accountToken + additionalQueryParams(accountCreditConfigurationRetrieveParams.additionalQueryParams) + additionalHeaders(accountCreditConfigurationRetrieveParams.additionalHeaders) + } + + fun accountToken(accountToken: String) = apply { this.accountToken = accountToken } + + 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(): AccountCreditConfigurationRetrieveParams = + AccountCreditConfigurationRetrieveParams( + checkNotNull(accountToken) { "`accountToken` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountCreditConfigurationUpdateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountCreditConfigurationUpdateParams.kt new file mode 100644 index 00000000..79267e33 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountCreditConfigurationUpdateParams.kt @@ -0,0 +1,343 @@ +// 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.util.Objects + +class AccountCreditConfigurationUpdateParams +constructor( + private val accountToken: String, + private val billingPeriod: Long?, + private val creditLimit: Long?, + private val externalBankAccountToken: String?, + private val paymentPeriod: Long?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun accountToken(): String = accountToken + + fun billingPeriod(): Long? = billingPeriod + + fun creditLimit(): Long? = creditLimit + + fun externalBankAccountToken(): String? = externalBankAccountToken + + fun paymentPeriod(): Long? = paymentPeriod + + internal fun getBody(): AccountCreditConfigurationUpdateBody { + return AccountCreditConfigurationUpdateBody( + billingPeriod, + creditLimit, + externalBankAccountToken, + paymentPeriod, + additionalBodyProperties, + ) + } + + internal fun getQueryParams(): Map> = additionalQueryParams + + internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> accountToken + else -> "" + } + } + + @JsonDeserialize(builder = AccountCreditConfigurationUpdateBody.Builder::class) + @NoAutoDetect + class AccountCreditConfigurationUpdateBody + internal constructor( + private val billingPeriod: Long?, + private val creditLimit: Long?, + private val externalBankAccountToken: String?, + private val paymentPeriod: Long?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** Number of days within the billing period */ + @JsonProperty("billing_period") fun billingPeriod(): Long? = billingPeriod + + /** Credit limit extended to the Business Account */ + @JsonProperty("credit_limit") fun creditLimit(): Long? = creditLimit + + /** The external bank account token to use for auto-collections */ + @JsonProperty("external_bank_account_token") + fun externalBankAccountToken(): String? = externalBankAccountToken + + /** Number of days after the billing period ends that a payment is required */ + @JsonProperty("payment_period") fun paymentPeriod(): Long? = paymentPeriod + + @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 AccountCreditConfigurationUpdateBody && + this.billingPeriod == other.billingPeriod && + this.creditLimit == other.creditLimit && + this.externalBankAccountToken == other.externalBankAccountToken && + this.paymentPeriod == other.paymentPeriod && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + billingPeriod, + creditLimit, + externalBankAccountToken, + paymentPeriod, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "AccountCreditConfigurationUpdateBody{billingPeriod=$billingPeriod, creditLimit=$creditLimit, externalBankAccountToken=$externalBankAccountToken, paymentPeriod=$paymentPeriod, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var billingPeriod: Long? = null + private var creditLimit: Long? = null + private var externalBankAccountToken: String? = null + private var paymentPeriod: Long? = null + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + accountCreditConfigurationUpdateBody: AccountCreditConfigurationUpdateBody + ) = apply { + this.billingPeriod = accountCreditConfigurationUpdateBody.billingPeriod + this.creditLimit = accountCreditConfigurationUpdateBody.creditLimit + this.externalBankAccountToken = + accountCreditConfigurationUpdateBody.externalBankAccountToken + this.paymentPeriod = accountCreditConfigurationUpdateBody.paymentPeriod + additionalProperties(accountCreditConfigurationUpdateBody.additionalProperties) + } + + /** Number of days within the billing period */ + @JsonProperty("billing_period") + fun billingPeriod(billingPeriod: Long) = apply { this.billingPeriod = billingPeriod } + + /** Credit limit extended to the Business Account */ + @JsonProperty("credit_limit") + fun creditLimit(creditLimit: Long) = apply { this.creditLimit = creditLimit } + + /** The external bank account token to use for auto-collections */ + @JsonProperty("external_bank_account_token") + fun externalBankAccountToken(externalBankAccountToken: String) = apply { + this.externalBankAccountToken = externalBankAccountToken + } + + /** Number of days after the billing period ends that a payment is required */ + @JsonProperty("payment_period") + fun paymentPeriod(paymentPeriod: Long) = apply { this.paymentPeriod = paymentPeriod } + + 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(): AccountCreditConfigurationUpdateBody = + AccountCreditConfigurationUpdateBody( + billingPeriod, + creditLimit, + externalBankAccountToken, + paymentPeriod, + 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 AccountCreditConfigurationUpdateParams && + this.accountToken == other.accountToken && + this.billingPeriod == other.billingPeriod && + this.creditLimit == other.creditLimit && + this.externalBankAccountToken == other.externalBankAccountToken && + this.paymentPeriod == other.paymentPeriod && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + accountToken, + billingPeriod, + creditLimit, + externalBankAccountToken, + paymentPeriod, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "AccountCreditConfigurationUpdateParams{accountToken=$accountToken, billingPeriod=$billingPeriod, creditLimit=$creditLimit, externalBankAccountToken=$externalBankAccountToken, paymentPeriod=$paymentPeriod, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var accountToken: String? = null + private var billingPeriod: Long? = null + private var creditLimit: Long? = null + private var externalBankAccountToken: String? = null + private var paymentPeriod: Long? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + internal fun from( + accountCreditConfigurationUpdateParams: AccountCreditConfigurationUpdateParams + ) = apply { + this.accountToken = accountCreditConfigurationUpdateParams.accountToken + this.billingPeriod = accountCreditConfigurationUpdateParams.billingPeriod + this.creditLimit = accountCreditConfigurationUpdateParams.creditLimit + this.externalBankAccountToken = + accountCreditConfigurationUpdateParams.externalBankAccountToken + this.paymentPeriod = accountCreditConfigurationUpdateParams.paymentPeriod + additionalQueryParams(accountCreditConfigurationUpdateParams.additionalQueryParams) + additionalHeaders(accountCreditConfigurationUpdateParams.additionalHeaders) + additionalBodyProperties( + accountCreditConfigurationUpdateParams.additionalBodyProperties + ) + } + + fun accountToken(accountToken: String) = apply { this.accountToken = accountToken } + + /** Number of days within the billing period */ + fun billingPeriod(billingPeriod: Long) = apply { this.billingPeriod = billingPeriod } + + /** Credit limit extended to the Business Account */ + fun creditLimit(creditLimit: Long) = apply { this.creditLimit = creditLimit } + + /** The external bank account token to use for auto-collections */ + fun externalBankAccountToken(externalBankAccountToken: String) = apply { + this.externalBankAccountToken = externalBankAccountToken + } + + /** Number of days after the billing period ends that a payment is required */ + fun paymentPeriod(paymentPeriod: Long) = apply { this.paymentPeriod = paymentPeriod } + + 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(): AccountCreditConfigurationUpdateParams = + AccountCreditConfigurationUpdateParams( + checkNotNull(accountToken) { "`accountToken` is required but was not set" }, + billingPeriod, + creditLimit, + externalBankAccountToken, + paymentPeriod, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountListParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountListParams.kt index a4c4c1cf..0b4fd039 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountListParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AccountListParams.kt @@ -105,13 +105,13 @@ constructor( } /** - * Date string in RFC 3339 format. Only entries created after the specified date will be + * 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 } /** - * Date string in RFC 3339 format. Only entries created before the specified date will be + * 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 } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AggregateBalanceListResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AggregateBalanceListResponse.kt new file mode 100644 index 00000000..b564b359 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AggregateBalanceListResponse.kt @@ -0,0 +1,326 @@ +// 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.time.OffsetDateTime +import java.util.Objects + +/** Card Aggregate Balance across all end-user accounts */ +@JsonDeserialize(builder = AggregateBalanceListResponse.Builder::class) +@NoAutoDetect +class AggregateBalanceListResponse +private constructor( + private val currency: JsonField, + private val availableAmount: JsonField, + private val pendingAmount: JsonField, + private val totalAmount: JsonField, + private val created: JsonField, + private val updated: JsonField, + private val lastTransactionToken: JsonField, + private val lastTransactionEventToken: JsonField, + private val lastCardToken: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** 3-digit alphabetic ISO 4217 code for the local currency of the balance. */ + fun currency(): String = currency.getRequired("currency") + + /** Funds available for spend in the currency's smallest unit (e.g., cents for USD) */ + fun availableAmount(): Long = availableAmount.getRequired("available_amount") + + /** + * 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 first created. */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** Date and time for when the balance was last updated. */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** Globally unique identifier for the last transaction that impacted this balance */ + fun lastTransactionToken(): String = lastTransactionToken.getRequired("last_transaction_token") + + /** Globally unique identifier for the last transaction event that impacted this balance */ + fun lastTransactionEventToken(): String = + lastTransactionEventToken.getRequired("last_transaction_event_token") + + /** Globally unique identifier for the card that had its balance updated most recently */ + fun lastCardToken(): String = lastCardToken.getRequired("last_card_token") + + /** 3-digit alphabetic ISO 4217 code for the local currency of the balance. */ + @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + + /** Funds available for spend in the currency's smallest unit (e.g., cents for USD) */ + @JsonProperty("available_amount") @ExcludeMissing fun _availableAmount() = availableAmount + + /** + * 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 first created. */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** Date and time for when the balance was last updated. */ + @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + + /** Globally unique identifier for the last transaction that impacted this balance */ + @JsonProperty("last_transaction_token") + @ExcludeMissing + fun _lastTransactionToken() = lastTransactionToken + + /** Globally unique identifier for the last transaction event that impacted this balance */ + @JsonProperty("last_transaction_event_token") + @ExcludeMissing + fun _lastTransactionEventToken() = lastTransactionEventToken + + /** Globally unique identifier for the card that had its balance updated most recently */ + @JsonProperty("last_card_token") @ExcludeMissing fun _lastCardToken() = lastCardToken + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AggregateBalanceListResponse = apply { + if (!validated) { + currency() + availableAmount() + pendingAmount() + totalAmount() + created() + updated() + lastTransactionToken() + lastTransactionEventToken() + lastCardToken() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AggregateBalanceListResponse && + this.currency == other.currency && + this.availableAmount == other.availableAmount && + this.pendingAmount == other.pendingAmount && + this.totalAmount == other.totalAmount && + this.created == other.created && + this.updated == other.updated && + this.lastTransactionToken == other.lastTransactionToken && + this.lastTransactionEventToken == other.lastTransactionEventToken && + this.lastCardToken == other.lastCardToken && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + currency, + availableAmount, + pendingAmount, + totalAmount, + created, + updated, + lastTransactionToken, + lastTransactionEventToken, + lastCardToken, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "AggregateBalanceListResponse{currency=$currency, availableAmount=$availableAmount, pendingAmount=$pendingAmount, totalAmount=$totalAmount, created=$created, updated=$updated, lastTransactionToken=$lastTransactionToken, lastTransactionEventToken=$lastTransactionEventToken, lastCardToken=$lastCardToken, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var currency: JsonField = JsonMissing.of() + private var availableAmount: JsonField = JsonMissing.of() + private var pendingAmount: JsonField = JsonMissing.of() + private var totalAmount: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var updated: JsonField = JsonMissing.of() + private var lastTransactionToken: JsonField = JsonMissing.of() + private var lastTransactionEventToken: JsonField = JsonMissing.of() + private var lastCardToken: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(aggregateBalanceListResponse: AggregateBalanceListResponse) = apply { + this.currency = aggregateBalanceListResponse.currency + this.availableAmount = aggregateBalanceListResponse.availableAmount + this.pendingAmount = aggregateBalanceListResponse.pendingAmount + this.totalAmount = aggregateBalanceListResponse.totalAmount + this.created = aggregateBalanceListResponse.created + this.updated = aggregateBalanceListResponse.updated + this.lastTransactionToken = aggregateBalanceListResponse.lastTransactionToken + this.lastTransactionEventToken = aggregateBalanceListResponse.lastTransactionEventToken + this.lastCardToken = aggregateBalanceListResponse.lastCardToken + additionalProperties(aggregateBalanceListResponse.additionalProperties) + } + + /** 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 } + + /** 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 + } + + /** + * 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 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 } + + /** 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 } + + /** Globally unique identifier for the last transaction that impacted this balance */ + fun lastTransactionToken(lastTransactionToken: String) = + lastTransactionToken(JsonField.of(lastTransactionToken)) + + /** Globally unique identifier for the last transaction that impacted this balance */ + @JsonProperty("last_transaction_token") + @ExcludeMissing + fun lastTransactionToken(lastTransactionToken: JsonField) = apply { + this.lastTransactionToken = lastTransactionToken + } + + /** Globally unique identifier for the last transaction event that impacted this balance */ + fun lastTransactionEventToken(lastTransactionEventToken: String) = + lastTransactionEventToken(JsonField.of(lastTransactionEventToken)) + + /** Globally unique identifier for the last 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 card that had its balance updated most recently */ + fun lastCardToken(lastCardToken: String) = lastCardToken(JsonField.of(lastCardToken)) + + /** Globally unique identifier for the card that had its balance updated most recently */ + @JsonProperty("last_card_token") + @ExcludeMissing + fun lastCardToken(lastCardToken: JsonField) = apply { + this.lastCardToken = lastCardToken + } + + 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(): AggregateBalanceListResponse = + AggregateBalanceListResponse( + currency, + availableAmount, + pendingAmount, + totalAmount, + created, + updated, + lastTransactionToken, + lastTransactionEventToken, + lastCardToken, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthenticationRetrieveResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthenticationRetrieveResponse.kt index f0abb666..99414be8 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthenticationRetrieveResponse.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/AuthenticationRetrieveResponse.kt @@ -34,6 +34,7 @@ private constructor( private val created: JsonField, private val decisionMadeBy: JsonField, private val merchant: JsonField, + private val messageCategory: JsonField, private val threeRiRequestType: JsonField, private val token: JsonField, private val transaction: JsonField, @@ -54,7 +55,7 @@ private constructor( * spec (e.g., specific fields that only certain card networks send but are not required across * all 3DS requests). */ - fun additionalData(): AdditionalData = additionalData.getRequired("additional_data") + fun additionalData(): AdditionalData? = additionalData.getNullable("additional_data") /** * Object containing data about the app used in the e-commerce transaction. Present if the @@ -104,6 +105,12 @@ private constructor( /** Object containing data about the merchant involved in the e-commerce transaction. */ fun merchant(): Merchant = merchant.getRequired("merchant") + /** + * Either PAYMENT_AUTHENTICATION or NON_PAYMENT_AUTHENTICATION. For NON_PAYMENT_AUTHENTICATION, + * additional_data and transaction fields are not populated. + */ + fun messageCategory(): MessageCategory = messageCategory.getRequired("message_category") + /** * Type of 3DS Requestor Initiated (3RI) request i.e., a 3DS authentication that takes place at * the initiation of the merchant rather than the cardholder. The most common example of this is @@ -120,7 +127,7 @@ private constructor( * Object containing data about the e-commerce transaction for which the merchant is requesting * authentication. */ - fun transaction(): Transaction = transaction.getRequired("transaction") + fun transaction(): Transaction? = transaction.getNullable("transaction") /** * Type of account/card that is being used for the transaction. Maps to EMV 3DS field acctType. @@ -184,6 +191,12 @@ private constructor( /** Object containing data about the merchant involved in the e-commerce transaction. */ @JsonProperty("merchant") @ExcludeMissing fun _merchant() = merchant + /** + * Either PAYMENT_AUTHENTICATION or NON_PAYMENT_AUTHENTICATION. For NON_PAYMENT_AUTHENTICATION, + * additional_data and transaction fields are not populated. + */ + @JsonProperty("message_category") @ExcludeMissing fun _messageCategory() = messageCategory + /** * Type of 3DS Requestor Initiated (3RI) request i.e., a 3DS authentication that takes place at * the initiation of the merchant rather than the cardholder. The most common example of this is @@ -210,7 +223,7 @@ private constructor( fun validate(): AuthenticationRetrieveResponse = apply { if (!validated) { accountType() - additionalData().validate() + additionalData()?.validate() app()?.validate() authenticationRequestType() authenticationResult() @@ -222,9 +235,10 @@ private constructor( created() decisionMadeBy() merchant().validate() + messageCategory() threeRiRequestType() token() - transaction().validate() + transaction()?.validate() validated = true } } @@ -250,6 +264,7 @@ private constructor( this.created == other.created && this.decisionMadeBy == other.decisionMadeBy && this.merchant == other.merchant && + this.messageCategory == other.messageCategory && this.threeRiRequestType == other.threeRiRequestType && this.token == other.token && this.transaction == other.transaction && @@ -273,6 +288,7 @@ private constructor( created, decisionMadeBy, merchant, + messageCategory, threeRiRequestType, token, transaction, @@ -283,7 +299,7 @@ private constructor( } override fun toString() = - "AuthenticationRetrieveResponse{accountType=$accountType, additionalData=$additionalData, app=$app, authenticationRequestType=$authenticationRequestType, authenticationResult=$authenticationResult, browser=$browser, cardExpiryCheck=$cardExpiryCheck, cardToken=$cardToken, cardholder=$cardholder, channel=$channel, created=$created, decisionMadeBy=$decisionMadeBy, merchant=$merchant, threeRiRequestType=$threeRiRequestType, token=$token, transaction=$transaction, additionalProperties=$additionalProperties}" + "AuthenticationRetrieveResponse{accountType=$accountType, additionalData=$additionalData, app=$app, authenticationRequestType=$authenticationRequestType, authenticationResult=$authenticationResult, browser=$browser, cardExpiryCheck=$cardExpiryCheck, cardToken=$cardToken, cardholder=$cardholder, channel=$channel, created=$created, decisionMadeBy=$decisionMadeBy, merchant=$merchant, messageCategory=$messageCategory, threeRiRequestType=$threeRiRequestType, token=$token, transaction=$transaction, additionalProperties=$additionalProperties}" companion object { @@ -306,6 +322,7 @@ private constructor( private var created: JsonField = JsonMissing.of() private var decisionMadeBy: JsonField = JsonMissing.of() private var merchant: JsonField = JsonMissing.of() + private var messageCategory: JsonField = JsonMissing.of() private var threeRiRequestType: JsonField = JsonMissing.of() private var token: JsonField = JsonMissing.of() private var transaction: JsonField = JsonMissing.of() @@ -326,6 +343,7 @@ private constructor( this.created = authenticationRetrieveResponse.created this.decisionMadeBy = authenticationRetrieveResponse.decisionMadeBy this.merchant = authenticationRetrieveResponse.merchant + this.messageCategory = authenticationRetrieveResponse.messageCategory this.threeRiRequestType = authenticationRetrieveResponse.threeRiRequestType this.token = authenticationRetrieveResponse.token this.transaction = authenticationRetrieveResponse.transaction @@ -491,6 +509,23 @@ private constructor( @ExcludeMissing fun merchant(merchant: JsonField) = apply { this.merchant = merchant } + /** + * Either PAYMENT_AUTHENTICATION or NON_PAYMENT_AUTHENTICATION. For + * NON_PAYMENT_AUTHENTICATION, additional_data and transaction fields are not populated. + */ + fun messageCategory(messageCategory: MessageCategory) = + messageCategory(JsonField.of(messageCategory)) + + /** + * Either PAYMENT_AUTHENTICATION or NON_PAYMENT_AUTHENTICATION. For + * NON_PAYMENT_AUTHENTICATION, additional_data and transaction fields are not populated. + */ + @JsonProperty("message_category") + @ExcludeMissing + fun messageCategory(messageCategory: JsonField) = apply { + this.messageCategory = messageCategory + } + /** * Type of 3DS Requestor Initiated (3RI) request i.e., a 3DS authentication that takes place * at the initiation of the merchant rather than the cardholder. The most common example of @@ -565,6 +600,7 @@ private constructor( created, decisionMadeBy, merchant, + messageCategory, threeRiRequestType, token, transaction, @@ -635,221 +671,6 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - /** - * Object containing additional data about the 3DS request that is beyond the EMV 3DS standard - * spec (e.g., specific fields that only certain card networks send but are not required across - * all 3DS requests). - */ - @JsonDeserialize(builder = AdditionalData.Builder::class) - @NoAutoDetect - class AdditionalData - private constructor( - private val networkDecision: JsonField, - private val networkRiskScore: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - private var hashCode: Int = 0 - - /** - * Mastercard only: Indicates whether the network would have considered the authentication - * request to be low risk or not. - */ - fun networkDecision(): NetworkDecision? = networkDecision.getNullable("network_decision") - - /** - * Mastercard only: Assessment by the network of the authentication risk level, with a - * higher value indicating a higher amount of risk. - */ - fun networkRiskScore(): Double? = networkRiskScore.getNullable("network_risk_score") - - /** - * Mastercard only: Indicates whether the network would have considered the authentication - * request to be low risk or not. - */ - @JsonProperty("network_decision") @ExcludeMissing fun _networkDecision() = networkDecision - - /** - * Mastercard only: Assessment by the network of the authentication risk level, with a - * higher value indicating a higher amount of risk. - */ - @JsonProperty("network_risk_score") - @ExcludeMissing - fun _networkRiskScore() = networkRiskScore - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): AdditionalData = apply { - if (!validated) { - networkDecision() - networkRiskScore() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AdditionalData && - this.networkDecision == other.networkDecision && - this.networkRiskScore == other.networkRiskScore && - this.additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - networkDecision, - networkRiskScore, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "AdditionalData{networkDecision=$networkDecision, networkRiskScore=$networkRiskScore, additionalProperties=$additionalProperties}" - - companion object { - - fun builder() = Builder() - } - - class Builder { - - private var networkDecision: JsonField = JsonMissing.of() - private var networkRiskScore: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - internal fun from(additionalData: AdditionalData) = apply { - this.networkDecision = additionalData.networkDecision - this.networkRiskScore = additionalData.networkRiskScore - additionalProperties(additionalData.additionalProperties) - } - - /** - * Mastercard only: Indicates whether the network would have considered the - * authentication request to be low risk or not. - */ - fun networkDecision(networkDecision: NetworkDecision) = - networkDecision(JsonField.of(networkDecision)) - - /** - * Mastercard only: Indicates whether the network would have considered the - * authentication request to be low risk or not. - */ - @JsonProperty("network_decision") - @ExcludeMissing - fun networkDecision(networkDecision: JsonField) = apply { - this.networkDecision = networkDecision - } - - /** - * Mastercard only: Assessment by the network of the authentication risk level, with a - * higher value indicating a higher amount of risk. - */ - fun networkRiskScore(networkRiskScore: Double) = - networkRiskScore(JsonField.of(networkRiskScore)) - - /** - * Mastercard only: Assessment by the network of the authentication risk level, with a - * higher value indicating a higher amount of risk. - */ - @JsonProperty("network_risk_score") - @ExcludeMissing - fun networkRiskScore(networkRiskScore: JsonField) = apply { - this.networkRiskScore = networkRiskScore - } - - 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(): AdditionalData = - AdditionalData( - networkDecision, - networkRiskScore, - additionalProperties.toUnmodifiable(), - ) - } - - class NetworkDecision - @JsonCreator - private constructor( - private val value: JsonField, - ) { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NetworkDecision && this.value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - - companion object { - - val LOW_RISK = NetworkDecision(JsonField.of("LOW_RISK")) - - val NOT_LOW_RISK = NetworkDecision(JsonField.of("NOT_LOW_RISK")) - - fun of(value: String) = NetworkDecision(JsonField.of(value)) - } - - enum class Known { - LOW_RISK, - NOT_LOW_RISK, - } - - enum class Value { - LOW_RISK, - NOT_LOW_RISK, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LOW_RISK -> Value.LOW_RISK - NOT_LOW_RISK -> Value.NOT_LOW_RISK - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LOW_RISK -> Known.LOW_RISK - NOT_LOW_RISK -> Known.NOT_LOW_RISK - else -> throw LithicInvalidDataException("Unknown NetworkDecision: $value") - } - - fun asString(): String = _value().asStringOrThrow() - } - } - class AuthenticationResult @JsonCreator private constructor( @@ -2610,93 +2431,116 @@ private constructor( } } - /** - * Object containing data about the e-commerce transaction for which the merchant is requesting - * authentication. - */ - @JsonDeserialize(builder = Transaction.Builder::class) - @NoAutoDetect - class Transaction + class MessageCategory + @JsonCreator private constructor( - private val amount: JsonField, - private val currency: JsonField, - private val currencyExponent: JsonField, - private val dateTime: JsonField, - private val type: JsonField, - private val additionalProperties: Map, + private val value: JsonField, ) { - private var validated: Boolean = false + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private var hashCode: Int = 0 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Amount of the purchase in minor units of currency with all punctuation removed. Maps to - * EMV 3DS field purchaseAmount. - */ - fun amount(): Double = amount.getRequired("amount") + return other is MessageCategory && this.value == other.value + } - /** Currency of the purchase. Maps to EMV 3DS field purchaseCurrency. */ - fun currency(): String = currency.getRequired("currency") + override fun hashCode() = value.hashCode() - /** - * Minor units of currency, as specified in ISO 4217 currency exponent. Maps to EMV 3DS - * field purchaseExponent. - */ - fun currencyExponent(): Double = currencyExponent.getRequired("currency_exponent") + override fun toString() = value.toString() - /** - * Date and time when the authentication was generated by the merchant/acquirer's 3DS - * server. Maps to EMV 3DS field purchaseDate. - */ - fun dateTime(): OffsetDateTime = dateTime.getRequired("date_time") + companion object { - /** - * Type of the transaction for which a 3DS authentication request is occurring. Maps to EMV - * 3DS field transType. - */ - fun type(): Type? = type.getNullable("type") + val PAYMENT_AUTHENTICATION = MessageCategory(JsonField.of("PAYMENT_AUTHENTICATION")) + + val NON_PAYMENT_AUTHENTICATION = + MessageCategory(JsonField.of("NON_PAYMENT_AUTHENTICATION")) + + fun of(value: String) = MessageCategory(JsonField.of(value)) + } + + enum class Known { + PAYMENT_AUTHENTICATION, + NON_PAYMENT_AUTHENTICATION, + } + + enum class Value { + PAYMENT_AUTHENTICATION, + NON_PAYMENT_AUTHENTICATION, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + PAYMENT_AUTHENTICATION -> Value.PAYMENT_AUTHENTICATION + NON_PAYMENT_AUTHENTICATION -> Value.NON_PAYMENT_AUTHENTICATION + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + PAYMENT_AUTHENTICATION -> Known.PAYMENT_AUTHENTICATION + NON_PAYMENT_AUTHENTICATION -> Known.NON_PAYMENT_AUTHENTICATION + else -> throw LithicInvalidDataException("Unknown MessageCategory: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + /** + * Object containing additional data about the 3DS request that is beyond the EMV 3DS standard + * spec (e.g., specific fields that only certain card networks send but are not required across + * all 3DS requests). + */ + @JsonDeserialize(builder = AdditionalData.Builder::class) + @NoAutoDetect + class AdditionalData + private constructor( + private val networkDecision: JsonField, + private val networkRiskScore: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 /** - * Amount of the purchase in minor units of currency with all punctuation removed. Maps to - * EMV 3DS field purchaseAmount. + * Mastercard only: Indicates whether the network would have considered the authentication + * request to be low risk or not. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount - - /** Currency of the purchase. Maps to EMV 3DS field purchaseCurrency. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + fun networkDecision(): NetworkDecision? = networkDecision.getNullable("network_decision") /** - * Minor units of currency, as specified in ISO 4217 currency exponent. Maps to EMV 3DS - * field purchaseExponent. + * Mastercard only: Assessment by the network of the authentication risk level, with a + * higher value indicating a higher amount of risk. */ - @JsonProperty("currency_exponent") - @ExcludeMissing - fun _currencyExponent() = currencyExponent + fun networkRiskScore(): Double? = networkRiskScore.getNullable("network_risk_score") /** - * Date and time when the authentication was generated by the merchant/acquirer's 3DS - * server. Maps to EMV 3DS field purchaseDate. + * Mastercard only: Indicates whether the network would have considered the authentication + * request to be low risk or not. */ - @JsonProperty("date_time") @ExcludeMissing fun _dateTime() = dateTime + @JsonProperty("network_decision") @ExcludeMissing fun _networkDecision() = networkDecision /** - * Type of the transaction for which a 3DS authentication request is occurring. Maps to EMV - * 3DS field transType. + * Mastercard only: Assessment by the network of the authentication risk level, with a + * higher value indicating a higher amount of risk. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("network_risk_score") + @ExcludeMissing + fun _networkRiskScore() = networkRiskScore @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun validate(): Transaction = apply { + fun validate(): AdditionalData = apply { if (!validated) { - amount() - currency() - currencyExponent() - dateTime() - type() + networkDecision() + networkRiskScore() validated = true } } @@ -2708,12 +2552,9 @@ private constructor( return true } - return other is Transaction && - this.amount == other.amount && - this.currency == other.currency && - this.currencyExponent == other.currencyExponent && - this.dateTime == other.dateTime && - this.type == other.type && + return other is AdditionalData && + this.networkDecision == other.networkDecision && + this.networkRiskScore == other.networkRiskScore && this.additionalProperties == other.additionalProperties } @@ -2721,11 +2562,8 @@ private constructor( if (hashCode == 0) { hashCode = Objects.hash( - amount, - currency, - currencyExponent, - dateTime, - type, + networkDecision, + networkRiskScore, additionalProperties, ) } @@ -2733,7 +2571,7 @@ private constructor( } override fun toString() = - "Transaction{amount=$amount, currency=$currency, currencyExponent=$currencyExponent, dateTime=$dateTime, type=$type, additionalProperties=$additionalProperties}" + "AdditionalData{networkDecision=$networkDecision, networkRiskScore=$networkRiskScore, additionalProperties=$additionalProperties}" companion object { @@ -2742,88 +2580,49 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var currencyExponent: JsonField = JsonMissing.of() - private var dateTime: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var networkDecision: JsonField = JsonMissing.of() + private var networkRiskScore: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() - internal fun from(transaction: Transaction) = apply { - this.amount = transaction.amount - this.currency = transaction.currency - this.currencyExponent = transaction.currencyExponent - this.dateTime = transaction.dateTime - this.type = transaction.type - additionalProperties(transaction.additionalProperties) + internal fun from(additionalData: AdditionalData) = apply { + this.networkDecision = additionalData.networkDecision + this.networkRiskScore = additionalData.networkRiskScore + additionalProperties(additionalData.additionalProperties) } /** - * Amount of the purchase in minor units of currency with all punctuation removed. Maps - * to EMV 3DS field purchaseAmount. - */ - fun amount(amount: Double) = amount(JsonField.of(amount)) - - /** - * Amount of the purchase in minor units of currency with all punctuation removed. Maps - * to EMV 3DS field purchaseAmount. - */ - @JsonProperty("amount") - @ExcludeMissing - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** Currency of the purchase. Maps to EMV 3DS field purchaseCurrency. */ - fun currency(currency: String) = currency(JsonField.of(currency)) - - /** Currency of the purchase. Maps to EMV 3DS field purchaseCurrency. */ - @JsonProperty("currency") - @ExcludeMissing - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * Minor units of currency, as specified in ISO 4217 currency exponent. Maps to EMV 3DS - * field purchaseExponent. + * Mastercard only: Indicates whether the network would have considered the + * authentication request to be low risk or not. */ - fun currencyExponent(currencyExponent: Double) = - currencyExponent(JsonField.of(currencyExponent)) + fun networkDecision(networkDecision: NetworkDecision) = + networkDecision(JsonField.of(networkDecision)) /** - * Minor units of currency, as specified in ISO 4217 currency exponent. Maps to EMV 3DS - * field purchaseExponent. + * Mastercard only: Indicates whether the network would have considered the + * authentication request to be low risk or not. */ - @JsonProperty("currency_exponent") + @JsonProperty("network_decision") @ExcludeMissing - fun currencyExponent(currencyExponent: JsonField) = apply { - this.currencyExponent = currencyExponent + fun networkDecision(networkDecision: JsonField) = apply { + this.networkDecision = networkDecision } /** - * Date and time when the authentication was generated by the merchant/acquirer's 3DS - * server. Maps to EMV 3DS field purchaseDate. - */ - fun dateTime(dateTime: OffsetDateTime) = dateTime(JsonField.of(dateTime)) - - /** - * Date and time when the authentication was generated by the merchant/acquirer's 3DS - * server. Maps to EMV 3DS field purchaseDate. - */ - @JsonProperty("date_time") - @ExcludeMissing - fun dateTime(dateTime: JsonField) = apply { this.dateTime = dateTime } - - /** - * Type of the transaction for which a 3DS authentication request is occurring. Maps to - * EMV 3DS field transType. + * Mastercard only: Assessment by the network of the authentication risk level, with a + * higher value indicating a higher amount of risk. */ - fun type(type: Type) = type(JsonField.of(type)) + fun networkRiskScore(networkRiskScore: Double) = + networkRiskScore(JsonField.of(networkRiskScore)) /** - * Type of the transaction for which a 3DS authentication request is occurring. Maps to - * EMV 3DS field transType. + * Mastercard only: Assessment by the network of the authentication risk level, with a + * higher value indicating a higher amount of risk. */ - @JsonProperty("type") + @JsonProperty("network_risk_score") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun networkRiskScore(networkRiskScore: JsonField) = apply { + this.networkRiskScore = networkRiskScore + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2839,18 +2638,15 @@ private constructor( this.additionalProperties.putAll(additionalProperties) } - fun build(): Transaction = - Transaction( - amount, - currency, - currencyExponent, - dateTime, - type, + fun build(): AdditionalData = + AdditionalData( + networkDecision, + networkRiskScore, additionalProperties.toUnmodifiable(), ) } - class Type + class NetworkDecision @JsonCreator private constructor( private val value: JsonField, @@ -2863,7 +2659,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return other is NetworkDecision && this.value == other.value } override fun hashCode() = value.hashCode() @@ -2872,54 +2668,36 @@ private constructor( companion object { - val GOODS_SERVICE_PURCHASE = Type(JsonField.of("GOODS_SERVICE_PURCHASE")) - - val CHECK_ACCEPTANCE = Type(JsonField.of("CHECK_ACCEPTANCE")) - - val ACCOUNT_FUNDING = Type(JsonField.of("ACCOUNT_FUNDING")) - - val QUASI_CASH_TRANSACTION = Type(JsonField.of("QUASI_CASH_TRANSACTION")) + val LOW_RISK = NetworkDecision(JsonField.of("LOW_RISK")) - val PREPAID_ACTIVATION_AND_LOAD = Type(JsonField.of("PREPAID_ACTIVATION_AND_LOAD")) + val NOT_LOW_RISK = NetworkDecision(JsonField.of("NOT_LOW_RISK")) - fun of(value: String) = Type(JsonField.of(value)) + fun of(value: String) = NetworkDecision(JsonField.of(value)) } enum class Known { - GOODS_SERVICE_PURCHASE, - CHECK_ACCEPTANCE, - ACCOUNT_FUNDING, - QUASI_CASH_TRANSACTION, - PREPAID_ACTIVATION_AND_LOAD, + LOW_RISK, + NOT_LOW_RISK, } enum class Value { - GOODS_SERVICE_PURCHASE, - CHECK_ACCEPTANCE, - ACCOUNT_FUNDING, - QUASI_CASH_TRANSACTION, - PREPAID_ACTIVATION_AND_LOAD, + LOW_RISK, + NOT_LOW_RISK, _UNKNOWN, } fun value(): Value = when (this) { - GOODS_SERVICE_PURCHASE -> Value.GOODS_SERVICE_PURCHASE - CHECK_ACCEPTANCE -> Value.CHECK_ACCEPTANCE - ACCOUNT_FUNDING -> Value.ACCOUNT_FUNDING - QUASI_CASH_TRANSACTION -> Value.QUASI_CASH_TRANSACTION - PREPAID_ACTIVATION_AND_LOAD -> Value.PREPAID_ACTIVATION_AND_LOAD + LOW_RISK -> Value.LOW_RISK + NOT_LOW_RISK -> Value.NOT_LOW_RISK else -> Value._UNKNOWN } fun known(): Known = when (this) { - GOODS_SERVICE_PURCHASE -> Known.GOODS_SERVICE_PURCHASE - CHECK_ACCEPTANCE -> Known.CHECK_ACCEPTANCE - ACCOUNT_FUNDING -> Known.ACCOUNT_FUNDING - QUASI_CASH_TRANSACTION -> Known.QUASI_CASH_TRANSACTION - PREPAID_ACTIVATION_AND_LOAD -> Known.PREPAID_ACTIVATION_AND_LOAD - else -> throw LithicInvalidDataException("Unknown Type: $value") + LOW_RISK -> Known.LOW_RISK + NOT_LOW_RISK -> Known.NOT_LOW_RISK + else -> throw LithicInvalidDataException("Unknown NetworkDecision: $value") } fun asString(): String = _value().asStringOrThrow() @@ -3608,4 +3386,320 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } + + /** + * Object containing data about the e-commerce transaction for which the merchant is requesting + * authentication. + */ + @JsonDeserialize(builder = Transaction.Builder::class) + @NoAutoDetect + class Transaction + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val currencyExponent: JsonField, + private val dateTime: JsonField, + private val type: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * Amount of the purchase in minor units of currency with all punctuation removed. Maps to + * EMV 3DS field purchaseAmount. + */ + fun amount(): Double = amount.getRequired("amount") + + /** Currency of the purchase. Maps to EMV 3DS field purchaseCurrency. */ + fun currency(): String = currency.getRequired("currency") + + /** + * Minor units of currency, as specified in ISO 4217 currency exponent. Maps to EMV 3DS + * field purchaseExponent. + */ + fun currencyExponent(): Double = currencyExponent.getRequired("currency_exponent") + + /** + * Date and time when the authentication was generated by the merchant/acquirer's 3DS + * server. Maps to EMV 3DS field purchaseDate. + */ + fun dateTime(): OffsetDateTime = dateTime.getRequired("date_time") + + /** + * Type of the transaction for which a 3DS authentication request is occurring. Maps to EMV + * 3DS field transType. + */ + fun type(): Type? = type.getNullable("type") + + /** + * Amount of the purchase in minor units of currency with all punctuation removed. Maps to + * EMV 3DS field purchaseAmount. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + + /** Currency of the purchase. Maps to EMV 3DS field purchaseCurrency. */ + @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + + /** + * Minor units of currency, as specified in ISO 4217 currency exponent. Maps to EMV 3DS + * field purchaseExponent. + */ + @JsonProperty("currency_exponent") + @ExcludeMissing + fun _currencyExponent() = currencyExponent + + /** + * Date and time when the authentication was generated by the merchant/acquirer's 3DS + * server. Maps to EMV 3DS field purchaseDate. + */ + @JsonProperty("date_time") @ExcludeMissing fun _dateTime() = dateTime + + /** + * Type of the transaction for which a 3DS authentication request is occurring. Maps to EMV + * 3DS field transType. + */ + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Transaction = apply { + if (!validated) { + amount() + currency() + currencyExponent() + dateTime() + type() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Transaction && + this.amount == other.amount && + this.currency == other.currency && + this.currencyExponent == other.currencyExponent && + this.dateTime == other.dateTime && + this.type == other.type && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + amount, + currency, + currencyExponent, + dateTime, + type, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Transaction{amount=$amount, currency=$currency, currencyExponent=$currencyExponent, dateTime=$dateTime, type=$type, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var amount: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var currencyExponent: JsonField = JsonMissing.of() + private var dateTime: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(transaction: Transaction) = apply { + this.amount = transaction.amount + this.currency = transaction.currency + this.currencyExponent = transaction.currencyExponent + this.dateTime = transaction.dateTime + this.type = transaction.type + additionalProperties(transaction.additionalProperties) + } + + /** + * Amount of the purchase in minor units of currency with all punctuation removed. Maps + * to EMV 3DS field purchaseAmount. + */ + fun amount(amount: Double) = amount(JsonField.of(amount)) + + /** + * Amount of the purchase in minor units of currency with all punctuation removed. Maps + * to EMV 3DS field purchaseAmount. + */ + @JsonProperty("amount") + @ExcludeMissing + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Currency of the purchase. Maps to EMV 3DS field purchaseCurrency. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** Currency of the purchase. Maps to EMV 3DS field purchaseCurrency. */ + @JsonProperty("currency") + @ExcludeMissing + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * Minor units of currency, as specified in ISO 4217 currency exponent. Maps to EMV 3DS + * field purchaseExponent. + */ + fun currencyExponent(currencyExponent: Double) = + currencyExponent(JsonField.of(currencyExponent)) + + /** + * Minor units of currency, as specified in ISO 4217 currency exponent. Maps to EMV 3DS + * field purchaseExponent. + */ + @JsonProperty("currency_exponent") + @ExcludeMissing + fun currencyExponent(currencyExponent: JsonField) = apply { + this.currencyExponent = currencyExponent + } + + /** + * Date and time when the authentication was generated by the merchant/acquirer's 3DS + * server. Maps to EMV 3DS field purchaseDate. + */ + fun dateTime(dateTime: OffsetDateTime) = dateTime(JsonField.of(dateTime)) + + /** + * Date and time when the authentication was generated by the merchant/acquirer's 3DS + * server. Maps to EMV 3DS field purchaseDate. + */ + @JsonProperty("date_time") + @ExcludeMissing + fun dateTime(dateTime: JsonField) = apply { this.dateTime = dateTime } + + /** + * Type of the transaction for which a 3DS authentication request is occurring. Maps to + * EMV 3DS field transType. + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Type of the transaction for which a 3DS authentication request is occurring. Maps to + * EMV 3DS field transType. + */ + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonField) = apply { this.type = type } + + 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(): Transaction = + Transaction( + amount, + currency, + currencyExponent, + dateTime, + type, + additionalProperties.toUnmodifiable(), + ) + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) { + + @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 GOODS_SERVICE_PURCHASE = Type(JsonField.of("GOODS_SERVICE_PURCHASE")) + + val CHECK_ACCEPTANCE = Type(JsonField.of("CHECK_ACCEPTANCE")) + + val ACCOUNT_FUNDING = Type(JsonField.of("ACCOUNT_FUNDING")) + + val QUASI_CASH_TRANSACTION = Type(JsonField.of("QUASI_CASH_TRANSACTION")) + + val PREPAID_ACTIVATION_AND_LOAD = Type(JsonField.of("PREPAID_ACTIVATION_AND_LOAD")) + + fun of(value: String) = Type(JsonField.of(value)) + } + + enum class Known { + GOODS_SERVICE_PURCHASE, + CHECK_ACCEPTANCE, + ACCOUNT_FUNDING, + QUASI_CASH_TRANSACTION, + PREPAID_ACTIVATION_AND_LOAD, + } + + enum class Value { + GOODS_SERVICE_PURCHASE, + CHECK_ACCEPTANCE, + ACCOUNT_FUNDING, + QUASI_CASH_TRANSACTION, + PREPAID_ACTIVATION_AND_LOAD, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + GOODS_SERVICE_PURCHASE -> Value.GOODS_SERVICE_PURCHASE + CHECK_ACCEPTANCE -> Value.CHECK_ACCEPTANCE + ACCOUNT_FUNDING -> Value.ACCOUNT_FUNDING + QUASI_CASH_TRANSACTION -> Value.QUASI_CASH_TRANSACTION + PREPAID_ACTIVATION_AND_LOAD -> Value.PREPAID_ACTIVATION_AND_LOAD + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + GOODS_SERVICE_PURCHASE -> Known.GOODS_SERVICE_PURCHASE + CHECK_ACCEPTANCE -> Known.CHECK_ACCEPTANCE + ACCOUNT_FUNDING -> Known.ACCOUNT_FUNDING + QUASI_CASH_TRANSACTION -> Known.QUASI_CASH_TRANSACTION + PREPAID_ACTIVATION_AND_LOAD -> Known.PREPAID_ACTIVATION_AND_LOAD + else -> throw LithicInvalidDataException("Unknown Type: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BusinessAccount.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BusinessAccount.kt new file mode 100644 index 00000000..53f703e1 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/BusinessAccount.kt @@ -0,0 +1,316 @@ +// 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 = BusinessAccount.Builder::class) +@NoAutoDetect +class BusinessAccount +private constructor( + private val collectionsConfiguration: JsonField, + private val creditLimit: JsonField, + private val token: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun collectionsConfiguration(): AccountHolderCollectionsConfiguration? = + collectionsConfiguration.getNullable("collections_configuration") + + /** Credit limit extended to the Account */ + fun creditLimit(): Long? = creditLimit.getNullable("credit_limit") + + /** Account token */ + fun token(): String = token.getRequired("token") + + @JsonProperty("collections_configuration") + @ExcludeMissing + fun _collectionsConfiguration() = collectionsConfiguration + + /** Credit limit extended to the Account */ + @JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit() = creditLimit + + /** Account token */ + @JsonProperty("token") @ExcludeMissing fun _token() = token + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BusinessAccount = apply { + if (!validated) { + collectionsConfiguration()?.validate() + creditLimit() + token() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BusinessAccount && + this.collectionsConfiguration == other.collectionsConfiguration && + this.creditLimit == other.creditLimit && + this.token == other.token && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + collectionsConfiguration, + creditLimit, + token, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "BusinessAccount{collectionsConfiguration=$collectionsConfiguration, creditLimit=$creditLimit, token=$token, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var collectionsConfiguration: JsonField = + JsonMissing.of() + private var creditLimit: JsonField = JsonMissing.of() + private var token: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(businessAccount: BusinessAccount) = apply { + this.collectionsConfiguration = businessAccount.collectionsConfiguration + this.creditLimit = businessAccount.creditLimit + this.token = businessAccount.token + additionalProperties(businessAccount.additionalProperties) + } + + fun collectionsConfiguration( + collectionsConfiguration: AccountHolderCollectionsConfiguration + ) = collectionsConfiguration(JsonField.of(collectionsConfiguration)) + + @JsonProperty("collections_configuration") + @ExcludeMissing + fun collectionsConfiguration( + collectionsConfiguration: JsonField + ) = apply { this.collectionsConfiguration = collectionsConfiguration } + + /** Credit limit extended to the Account */ + fun creditLimit(creditLimit: Long) = creditLimit(JsonField.of(creditLimit)) + + /** Credit limit extended to the Account */ + @JsonProperty("credit_limit") + @ExcludeMissing + fun creditLimit(creditLimit: JsonField) = apply { this.creditLimit = creditLimit } + + /** Account token */ + fun token(token: String) = token(JsonField.of(token)) + + /** Account token */ + @JsonProperty("token") + @ExcludeMissing + fun token(token: JsonField) = apply { this.token = token } + + 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(): BusinessAccount = + BusinessAccount( + collectionsConfiguration, + creditLimit, + token, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = AccountHolderCollectionsConfiguration.Builder::class) + @NoAutoDetect + class AccountHolderCollectionsConfiguration + private constructor( + private val billingPeriod: JsonField, + private val externalBankAccountToken: JsonField, + private val paymentPeriod: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Number of days within the billing period */ + fun billingPeriod(): Long = billingPeriod.getRequired("billing_period") + + /** The external bank account token to use for auto-collections */ + fun externalBankAccountToken(): String? = + externalBankAccountToken.getNullable("external_bank_account_token") + + /** Number of days after the billing period ends that a payment is required */ + fun paymentPeriod(): Long = paymentPeriod.getRequired("payment_period") + + /** Number of days within the billing period */ + @JsonProperty("billing_period") @ExcludeMissing fun _billingPeriod() = billingPeriod + + /** The external bank account token to use for auto-collections */ + @JsonProperty("external_bank_account_token") + @ExcludeMissing + fun _externalBankAccountToken() = externalBankAccountToken + + /** Number of days after the billing period ends that a payment is required */ + @JsonProperty("payment_period") @ExcludeMissing fun _paymentPeriod() = paymentPeriod + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): AccountHolderCollectionsConfiguration = apply { + if (!validated) { + billingPeriod() + externalBankAccountToken() + paymentPeriod() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccountHolderCollectionsConfiguration && + this.billingPeriod == other.billingPeriod && + this.externalBankAccountToken == other.externalBankAccountToken && + this.paymentPeriod == other.paymentPeriod && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + billingPeriod, + externalBankAccountToken, + paymentPeriod, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "AccountHolderCollectionsConfiguration{billingPeriod=$billingPeriod, externalBankAccountToken=$externalBankAccountToken, paymentPeriod=$paymentPeriod, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var billingPeriod: JsonField = JsonMissing.of() + private var externalBankAccountToken: JsonField = JsonMissing.of() + private var paymentPeriod: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from( + accountHolderCollectionsConfiguration: AccountHolderCollectionsConfiguration + ) = apply { + this.billingPeriod = accountHolderCollectionsConfiguration.billingPeriod + this.externalBankAccountToken = + accountHolderCollectionsConfiguration.externalBankAccountToken + this.paymentPeriod = accountHolderCollectionsConfiguration.paymentPeriod + additionalProperties(accountHolderCollectionsConfiguration.additionalProperties) + } + + /** Number of days within the billing period */ + fun billingPeriod(billingPeriod: Long) = billingPeriod(JsonField.of(billingPeriod)) + + /** Number of days within the billing period */ + @JsonProperty("billing_period") + @ExcludeMissing + fun billingPeriod(billingPeriod: JsonField) = apply { + this.billingPeriod = billingPeriod + } + + /** The external bank account token to use for auto-collections */ + fun externalBankAccountToken(externalBankAccountToken: String) = + externalBankAccountToken(JsonField.of(externalBankAccountToken)) + + /** The external bank account token to use for auto-collections */ + @JsonProperty("external_bank_account_token") + @ExcludeMissing + fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { + this.externalBankAccountToken = externalBankAccountToken + } + + /** Number of days after the billing period ends that a payment is required */ + fun paymentPeriod(paymentPeriod: Long) = paymentPeriod(JsonField.of(paymentPeriod)) + + /** Number of days after the billing period ends that a payment is required */ + @JsonProperty("payment_period") + @ExcludeMissing + fun paymentPeriod(paymentPeriod: JsonField) = apply { + this.paymentPeriod = paymentPeriod + } + + 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(): AccountHolderCollectionsConfiguration = + AccountHolderCollectionsConfiguration( + billingPeriod, + externalBankAccountToken, + paymentPeriod, + additionalProperties.toUnmodifiable(), + ) + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardAggregateBalanceListPage.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardAggregateBalanceListPage.kt new file mode 100644 index 00000000..21809c58 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardAggregateBalanceListPage.kt @@ -0,0 +1,196 @@ +// 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.cards.AggregateBalanceService +import java.util.Objects + +class CardAggregateBalanceListPage +private constructor( + private val aggregateBalancesService: AggregateBalanceService, + private val params: CardAggregateBalanceListParams, + 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 CardAggregateBalanceListPage && + this.aggregateBalancesService == other.aggregateBalancesService && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + aggregateBalancesService, + params, + response, + ) + } + + override fun toString() = + "CardAggregateBalanceListPage{aggregateBalancesService=$aggregateBalancesService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return data().isEmpty() + } + + fun getNextPageParams(): CardAggregateBalanceListParams? { + return null + } + + fun getNextPage(): CardAggregateBalanceListPage? { + return getNextPageParams()?.let { aggregateBalancesService.list(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + fun of( + aggregateBalancesService: AggregateBalanceService, + params: CardAggregateBalanceListParams, + response: Response + ) = + CardAggregateBalanceListPage( + aggregateBalancesService, + 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(): JsonField>? = data + + @JsonProperty("has_more") fun _hasMore(): JsonField? = 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() = + "CardAggregateBalanceListPage.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + 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: CardAggregateBalanceListPage, + ) : Sequence { + + 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() ?: break + index = 0 + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardAggregateBalanceListPageAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardAggregateBalanceListPageAsync.kt new file mode 100644 index 00000000..6d741e2b --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardAggregateBalanceListPageAsync.kt @@ -0,0 +1,198 @@ +// 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.cards.AggregateBalanceServiceAsync +import java.util.Objects +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector + +class CardAggregateBalanceListPageAsync +private constructor( + private val aggregateBalancesService: AggregateBalanceServiceAsync, + private val params: CardAggregateBalanceListParams, + 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 CardAggregateBalanceListPageAsync && + this.aggregateBalancesService == other.aggregateBalancesService && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + aggregateBalancesService, + params, + response, + ) + } + + override fun toString() = + "CardAggregateBalanceListPageAsync{aggregateBalancesService=$aggregateBalancesService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return data().isEmpty() + } + + fun getNextPageParams(): CardAggregateBalanceListParams? { + return null + } + + suspend fun getNextPage(): CardAggregateBalanceListPageAsync? { + return getNextPageParams()?.let { aggregateBalancesService.list(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + fun of( + aggregateBalancesService: AggregateBalanceServiceAsync, + params: CardAggregateBalanceListParams, + response: Response + ) = + CardAggregateBalanceListPageAsync( + aggregateBalancesService, + 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(): JsonField>? = data + + @JsonProperty("has_more") fun _hasMore(): JsonField? = 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() = + "CardAggregateBalanceListPageAsync.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + 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: CardAggregateBalanceListPageAsync, + ) : Flow { + + override suspend fun collect(collector: FlowCollector) { + var page = firstPage + var index = 0 + while (true) { + while (index < page.data().size) { + collector.emit(page.data()[index++]) + } + page = page.getNextPage() ?: break + index = 0 + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardAggregateBalanceListParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardAggregateBalanceListParams.kt new file mode 100644 index 00000000..87bba758 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardAggregateBalanceListParams.kt @@ -0,0 +1,140 @@ +// 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 CardAggregateBalanceListParams +constructor( + private val accountToken: String?, + private val businessAccountToken: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun accountToken(): String? = accountToken + + fun businessAccountToken(): String? = businessAccountToken + + internal fun getQueryParams(): Map> { + val params = mutableMapOf>() + this.accountToken?.let { params.put("account_token", listOf(it.toString())) } + this.businessAccountToken?.let { + params.put("business_account_token", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() + } + + 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 CardAggregateBalanceListParams && + this.accountToken == other.accountToken && + this.businessAccountToken == other.businessAccountToken && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders + } + + override fun hashCode(): Int { + return Objects.hash( + accountToken, + businessAccountToken, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "CardAggregateBalanceListParams{accountToken=$accountToken, businessAccountToken=$businessAccountToken, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var accountToken: String? = null + private var businessAccountToken: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + + internal fun from(cardAggregateBalanceListParams: CardAggregateBalanceListParams) = apply { + this.accountToken = cardAggregateBalanceListParams.accountToken + this.businessAccountToken = cardAggregateBalanceListParams.businessAccountToken + additionalQueryParams(cardAggregateBalanceListParams.additionalQueryParams) + additionalHeaders(cardAggregateBalanceListParams.additionalHeaders) + } + + /** Cardholder to retrieve aggregate balances for. */ + fun accountToken(accountToken: String) = apply { this.accountToken = accountToken } + + /** Business to retrieve aggregate balances for. */ + fun businessAccountToken(businessAccountToken: String) = apply { + this.businessAccountToken = businessAccountToken + } + + 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(): CardAggregateBalanceListParams = + CardAggregateBalanceListParams( + accountToken, + businessAccountToken, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPage.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPage.kt new file mode 100644 index 00000000..f160dba2 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPage.kt @@ -0,0 +1,190 @@ +// 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.cards.BalanceService +import java.util.Objects + +class CardBalanceListPage +private constructor( + private val balancesService: BalanceService, + private val params: CardBalanceListParams, + 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 CardBalanceListPage && + this.balancesService == other.balancesService && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + balancesService, + params, + response, + ) + } + + override fun toString() = + "CardBalanceListPage{balancesService=$balancesService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return data().isEmpty() + } + + fun getNextPageParams(): CardBalanceListParams? { + return null + } + + fun getNextPage(): CardBalanceListPage? { + return getNextPageParams()?.let { balancesService.list(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + fun of(balancesService: BalanceService, params: CardBalanceListParams, response: Response) = + CardBalanceListPage( + balancesService, + 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(): JsonField>? = data + + @JsonProperty("has_more") fun _hasMore(): JsonField? = 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() = + "CardBalanceListPage.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + 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: CardBalanceListPage, + ) : Sequence { + + 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() ?: break + index = 0 + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPageAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPageAsync.kt new file mode 100644 index 00000000..06c4271e --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPageAsync.kt @@ -0,0 +1,196 @@ +// 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.cards.BalanceServiceAsync +import java.util.Objects +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector + +class CardBalanceListPageAsync +private constructor( + private val balancesService: BalanceServiceAsync, + private val params: CardBalanceListParams, + 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 CardBalanceListPageAsync && + this.balancesService == other.balancesService && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + balancesService, + params, + response, + ) + } + + override fun toString() = + "CardBalanceListPageAsync{balancesService=$balancesService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return data().isEmpty() + } + + fun getNextPageParams(): CardBalanceListParams? { + return null + } + + suspend fun getNextPage(): CardBalanceListPageAsync? { + return getNextPageParams()?.let { balancesService.list(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + fun of( + balancesService: BalanceServiceAsync, + params: CardBalanceListParams, + response: Response + ) = + CardBalanceListPageAsync( + balancesService, + 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(): JsonField>? = data + + @JsonProperty("has_more") fun _hasMore(): JsonField? = 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() = + "CardBalanceListPageAsync.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + 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: CardBalanceListPageAsync, + ) : Flow { + + override suspend fun collect(collector: FlowCollector) { + var page = firstPage + var index = 0 + while (true) { + while (index < page.data().size) { + collector.emit(page.data()[index++]) + } + page = page.getNextPage() ?: break + index = 0 + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardBalanceListParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardBalanceListParams.kt new file mode 100644 index 00000000..633ae20c --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardBalanceListParams.kt @@ -0,0 +1,161 @@ +// 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.time.OffsetDateTime +import java.util.Objects + +class CardBalanceListParams +constructor( + private val cardToken: String, + private val balanceDate: OffsetDateTime?, + private val lastTransactionEventToken: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun cardToken(): String = cardToken + + fun balanceDate(): OffsetDateTime? = balanceDate + + fun lastTransactionEventToken(): String? = lastTransactionEventToken + + internal fun getQueryParams(): Map> { + val params = mutableMapOf>() + this.balanceDate?.let { params.put("balance_date", listOf(it.toString())) } + this.lastTransactionEventToken?.let { + params.put("last_transaction_event_token", listOf(it.toString())) + } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() + } + + internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> cardToken + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardBalanceListParams && + this.cardToken == other.cardToken && + this.balanceDate == other.balanceDate && + this.lastTransactionEventToken == other.lastTransactionEventToken && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders + } + + override fun hashCode(): Int { + return Objects.hash( + cardToken, + balanceDate, + lastTransactionEventToken, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "CardBalanceListParams{cardToken=$cardToken, balanceDate=$balanceDate, lastTransactionEventToken=$lastTransactionEventToken, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var cardToken: String? = null + private var balanceDate: OffsetDateTime? = null + private var lastTransactionEventToken: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + + internal fun from(cardBalanceListParams: CardBalanceListParams) = apply { + this.cardToken = cardBalanceListParams.cardToken + this.balanceDate = cardBalanceListParams.balanceDate + this.lastTransactionEventToken = cardBalanceListParams.lastTransactionEventToken + additionalQueryParams(cardBalanceListParams.additionalQueryParams) + additionalHeaders(cardBalanceListParams.additionalHeaders) + } + + fun cardToken(cardToken: String) = apply { this.cardToken = cardToken } + + /** UTC date of the balance to retrieve. Defaults to latest available balance */ + fun balanceDate(balanceDate: OffsetDateTime) = apply { this.balanceDate = balanceDate } + + /** + * Balance after a given financial event occured. For example, passing the event_token of a + * $5 CARD_CLEARING financial event will return a balance decreased by $5 + */ + fun lastTransactionEventToken(lastTransactionEventToken: String) = apply { + this.lastTransactionEventToken = lastTransactionEventToken + } + + 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(): CardBalanceListParams = + CardBalanceListParams( + checkNotNull(cardToken) { "`cardToken` is required but was not set" }, + balanceDate, + lastTransactionEventToken, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardFinancialTransactionListPage.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardFinancialTransactionListPage.kt new file mode 100644 index 00000000..fe7667b2 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardFinancialTransactionListPage.kt @@ -0,0 +1,194 @@ +// 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.cards.FinancialTransactionService +import java.util.Objects + +class CardFinancialTransactionListPage +private constructor( + private val financialTransactionsService: FinancialTransactionService, + private val params: CardFinancialTransactionListParams, + 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 CardFinancialTransactionListPage && + this.financialTransactionsService == other.financialTransactionsService && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + financialTransactionsService, + params, + response, + ) + } + + override fun toString() = + "CardFinancialTransactionListPage{financialTransactionsService=$financialTransactionsService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return data().isEmpty() + } + + fun getNextPageParams(): CardFinancialTransactionListParams? { + return null + } + + fun getNextPage(): CardFinancialTransactionListPage? { + return getNextPageParams()?.let { financialTransactionsService.list(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + fun of( + financialTransactionsService: FinancialTransactionService, + params: CardFinancialTransactionListParams, + response: Response + ) = + CardFinancialTransactionListPage( + financialTransactionsService, + 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(): JsonField>? = data + + @JsonProperty("has_more") fun _hasMore(): JsonField? = 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() = + "CardFinancialTransactionListPage.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + 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: CardFinancialTransactionListPage, + ) : Sequence { + + 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() ?: break + index = 0 + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardFinancialTransactionListPageAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardFinancialTransactionListPageAsync.kt new file mode 100644 index 00000000..918b72d2 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardFinancialTransactionListPageAsync.kt @@ -0,0 +1,196 @@ +// 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.cards.FinancialTransactionServiceAsync +import java.util.Objects +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector + +class CardFinancialTransactionListPageAsync +private constructor( + private val financialTransactionsService: FinancialTransactionServiceAsync, + private val params: CardFinancialTransactionListParams, + 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 CardFinancialTransactionListPageAsync && + this.financialTransactionsService == other.financialTransactionsService && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + financialTransactionsService, + params, + response, + ) + } + + override fun toString() = + "CardFinancialTransactionListPageAsync{financialTransactionsService=$financialTransactionsService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return data().isEmpty() + } + + fun getNextPageParams(): CardFinancialTransactionListParams? { + return null + } + + suspend fun getNextPage(): CardFinancialTransactionListPageAsync? { + return getNextPageParams()?.let { financialTransactionsService.list(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + fun of( + financialTransactionsService: FinancialTransactionServiceAsync, + params: CardFinancialTransactionListParams, + response: Response + ) = + CardFinancialTransactionListPageAsync( + financialTransactionsService, + 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(): JsonField>? = data + + @JsonProperty("has_more") fun _hasMore(): JsonField? = 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() = + "CardFinancialTransactionListPageAsync.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + 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: CardFinancialTransactionListPageAsync, + ) : Flow { + + override suspend fun collect(collector: FlowCollector) { + var page = firstPage + var index = 0 + while (true) { + while (index < page.data().size) { + collector.emit(page.data()[index++]) + } + page = page.getNextPage() ?: break + index = 0 + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardFinancialTransactionListParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardFinancialTransactionListParams.kt new file mode 100644 index 00000000..dbfb91a4 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardFinancialTransactionListParams.kt @@ -0,0 +1,426 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonCreator +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.util.Objects + +class CardFinancialTransactionListParams +constructor( + private val cardToken: String, + private val begin: OffsetDateTime?, + private val category: Category?, + private val end: OffsetDateTime?, + private val endingBefore: String?, + private val result: Result?, + private val startingAfter: String?, + private val status: Status?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun cardToken(): String = cardToken + + fun begin(): OffsetDateTime? = begin + + fun category(): Category? = category + + fun end(): OffsetDateTime? = end + + fun endingBefore(): String? = endingBefore + + fun result(): Result? = result + + fun startingAfter(): String? = startingAfter + + fun status(): Status? = status + + internal fun getQueryParams(): Map> { + val params = mutableMapOf>() + this.begin?.let { params.put("begin", listOf(it.toString())) } + this.category?.let { params.put("category", listOf(it.toString())) } + this.end?.let { params.put("end", listOf(it.toString())) } + this.endingBefore?.let { params.put("ending_before", 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() + } + + internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> cardToken + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardFinancialTransactionListParams && + this.cardToken == other.cardToken && + this.begin == other.begin && + this.category == other.category && + this.end == other.end && + this.endingBefore == other.endingBefore && + 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( + cardToken, + begin, + category, + end, + endingBefore, + result, + startingAfter, + status, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "CardFinancialTransactionListParams{cardToken=$cardToken, begin=$begin, category=$category, end=$end, endingBefore=$endingBefore, result=$result, startingAfter=$startingAfter, status=$status, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var cardToken: String? = null + private var begin: OffsetDateTime? = null + private var category: Category? = null + private var end: OffsetDateTime? = null + private var endingBefore: String? = null + private var result: Result? = null + private var startingAfter: String? = null + private var status: Status? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + + internal fun from(cardFinancialTransactionListParams: CardFinancialTransactionListParams) = + apply { + this.cardToken = cardFinancialTransactionListParams.cardToken + this.begin = cardFinancialTransactionListParams.begin + this.category = cardFinancialTransactionListParams.category + this.end = cardFinancialTransactionListParams.end + this.endingBefore = cardFinancialTransactionListParams.endingBefore + this.result = cardFinancialTransactionListParams.result + this.startingAfter = cardFinancialTransactionListParams.startingAfter + this.status = cardFinancialTransactionListParams.status + additionalQueryParams(cardFinancialTransactionListParams.additionalQueryParams) + additionalHeaders(cardFinancialTransactionListParams.additionalHeaders) + } + + fun cardToken(cardToken: String) = apply { this.cardToken = cardToken } + + /** + * 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 } + + /** Financial Transaction category to be returned. */ + fun category(category: Category) = 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 } + + /** Financial Transaction result to be returned. */ + fun result(result: Result) = 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 } + + /** Financial Transaction status to be returned. */ + fun status(status: Status) = 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(): CardFinancialTransactionListParams = + CardFinancialTransactionListParams( + checkNotNull(cardToken) { "`cardToken` is required but was not set" }, + begin, + category, + end, + endingBefore, + result, + startingAfter, + status, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } + + class Category + @JsonCreator + private constructor( + private val value: JsonField, + ) { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Category && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + val CARD = Category(JsonField.of("CARD")) + + val TRANSFER = Category(JsonField.of("TRANSFER")) + + fun of(value: String) = Category(JsonField.of(value)) + } + + enum class Known { + CARD, + TRANSFER, + } + + enum class Value { + CARD, + TRANSFER, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CARD -> Value.CARD + TRANSFER -> Value.TRANSFER + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CARD -> Known.CARD + TRANSFER -> Known.TRANSFER + else -> throw LithicInvalidDataException("Unknown Category: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Result + @JsonCreator + private constructor( + private val value: JsonField, + ) { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + val APPROVED = Result(JsonField.of("APPROVED")) + + val DECLINED = Result(JsonField.of("DECLINED")) + + fun of(value: String) = Result(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 Result: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + val DECLINED = Status(JsonField.of("DECLINED")) + + val EXPIRED = Status(JsonField.of("EXPIRED")) + + val PENDING = Status(JsonField.of("PENDING")) + + val RETURNED = Status(JsonField.of("RETURNED")) + + val SETTLED = Status(JsonField.of("SETTLED")) + + val VOIDED = Status(JsonField.of("VOIDED")) + + fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + DECLINED, + EXPIRED, + PENDING, + RETURNED, + SETTLED, + VOIDED, + } + + enum class Value { + DECLINED, + EXPIRED, + PENDING, + RETURNED, + SETTLED, + VOIDED, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + DECLINED -> Value.DECLINED + EXPIRED -> Value.EXPIRED + PENDING -> Value.PENDING + RETURNED -> Value.RETURNED + SETTLED -> Value.SETTLED + VOIDED -> Value.VOIDED + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + DECLINED -> Known.DECLINED + EXPIRED -> Known.EXPIRED + PENDING -> Known.PENDING + RETURNED -> Known.RETURNED + SETTLED -> Known.SETTLED + VOIDED -> Known.VOIDED + else -> throw LithicInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardFinancialTransactionRetrieveParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardFinancialTransactionRetrieveParams.kt new file mode 100644 index 00000000..1e90d8d3 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardFinancialTransactionRetrieveParams.kt @@ -0,0 +1,143 @@ +// 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 CardFinancialTransactionRetrieveParams +constructor( + private val cardToken: String, + private val financialTransactionToken: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun cardToken(): String = cardToken + + fun financialTransactionToken(): String = financialTransactionToken + + internal fun getQueryParams(): Map> = additionalQueryParams + + internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> cardToken + 1 -> financialTransactionToken + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardFinancialTransactionRetrieveParams && + this.cardToken == other.cardToken && + this.financialTransactionToken == other.financialTransactionToken && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders + } + + override fun hashCode(): Int { + return Objects.hash( + cardToken, + financialTransactionToken, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "CardFinancialTransactionRetrieveParams{cardToken=$cardToken, financialTransactionToken=$financialTransactionToken, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var cardToken: String? = null + private var financialTransactionToken: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + + internal fun from( + cardFinancialTransactionRetrieveParams: CardFinancialTransactionRetrieveParams + ) = apply { + this.cardToken = cardFinancialTransactionRetrieveParams.cardToken + this.financialTransactionToken = + cardFinancialTransactionRetrieveParams.financialTransactionToken + additionalQueryParams(cardFinancialTransactionRetrieveParams.additionalQueryParams) + additionalHeaders(cardFinancialTransactionRetrieveParams.additionalHeaders) + } + + fun cardToken(cardToken: String) = apply { this.cardToken = cardToken } + + fun financialTransactionToken(financialTransactionToken: String) = apply { + this.financialTransactionToken = financialTransactionToken + } + + 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(): CardFinancialTransactionRetrieveParams = + CardFinancialTransactionRetrieveParams( + checkNotNull(cardToken) { "`cardToken` is required but was not set" }, + checkNotNull(financialTransactionToken) { + "`financialTransactionToken` is required but was not set" + }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardListParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardListParams.kt index 90fbab37..e2b811f4 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardListParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardListParams.kt @@ -128,13 +128,13 @@ constructor( fun accountToken(accountToken: String) = apply { this.accountToken = accountToken } /** - * Date string in RFC 3339 format. Only entries created after the specified date will be + * 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 } /** - * Date string in RFC 3339 format. Only entries created before the specified date will be + * 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 } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProductCreditDetailParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProductCreditDetailParams.kt new file mode 100644 index 00000000..09fff204 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProductCreditDetailParams.kt @@ -0,0 +1,105 @@ +// 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 CardProductCreditDetailParams +constructor( + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + internal fun getQueryParams(): Map> = additionalQueryParams + + 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 CardProductCreditDetailParams && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders + } + + override fun hashCode(): Int { + return Objects.hash(additionalQueryParams, additionalHeaders) + } + + override fun toString() = + "CardProductCreditDetailParams{additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + + internal fun from(cardProductCreditDetailParams: CardProductCreditDetailParams) = apply { + additionalQueryParams(cardProductCreditDetailParams.additionalQueryParams) + additionalHeaders(cardProductCreditDetailParams.additionalHeaders) + } + + 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(): CardProductCreditDetailParams = + CardProductCreditDetailParams( + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable() + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProductCreditDetailResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProductCreditDetailResponse.kt new file mode 100644 index 00000000..e477cb37 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/CardProductCreditDetailResponse.kt @@ -0,0 +1,139 @@ +// 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 = CardProductCreditDetailResponse.Builder::class) +@NoAutoDetect +class CardProductCreditDetailResponse +private constructor( + private val creditLimit: JsonField, + private val creditExtended: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The total credit limit of the program */ + fun creditLimit(): Long = creditLimit.getRequired("credit_limit") + + /** The amount of credit extended within the program */ + fun creditExtended(): Long = creditExtended.getRequired("credit_extended") + + /** The total credit limit of the program */ + @JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit() = creditLimit + + /** The amount of credit extended within the program */ + @JsonProperty("credit_extended") @ExcludeMissing fun _creditExtended() = creditExtended + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CardProductCreditDetailResponse = apply { + if (!validated) { + creditLimit() + creditExtended() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardProductCreditDetailResponse && + this.creditLimit == other.creditLimit && + this.creditExtended == other.creditExtended && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + creditLimit, + creditExtended, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CardProductCreditDetailResponse{creditLimit=$creditLimit, creditExtended=$creditExtended, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var creditLimit: JsonField = JsonMissing.of() + private var creditExtended: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(cardProductCreditDetailResponse: CardProductCreditDetailResponse) = + apply { + this.creditLimit = cardProductCreditDetailResponse.creditLimit + this.creditExtended = cardProductCreditDetailResponse.creditExtended + additionalProperties(cardProductCreditDetailResponse.additionalProperties) + } + + /** The total credit limit of the program */ + fun creditLimit(creditLimit: Long) = creditLimit(JsonField.of(creditLimit)) + + /** The total credit limit of the program */ + @JsonProperty("credit_limit") + @ExcludeMissing + fun creditLimit(creditLimit: JsonField) = apply { this.creditLimit = creditLimit } + + /** The amount of credit extended within the program */ + fun creditExtended(creditExtended: Long) = creditExtended(JsonField.of(creditExtended)) + + /** The amount of credit extended within the program */ + @JsonProperty("credit_extended") + @ExcludeMissing + fun creditExtended(creditExtended: JsonField) = apply { + this.creditExtended = creditExtended + } + + 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(): CardProductCreditDetailResponse = + CardProductCreditDetailResponse( + creditLimit, + creditExtended, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeListEvidencesParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeListEvidencesParams.kt index 7cf9b6d6..1cfa09c6 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeListEvidencesParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeListEvidencesParams.kt @@ -121,13 +121,13 @@ constructor( fun disputeToken(disputeToken: String) = apply { this.disputeToken = disputeToken } /** - * Date string in RFC 3339 format. Only entries created after the specified date will be + * 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 } /** - * Date string in RFC 3339 format. Only entries created before the specified date will be + * 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 } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeListParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeListParams.kt index 0e72ea45..8b3e67e4 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeListParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/DisputeListParams.kt @@ -127,13 +127,13 @@ constructor( } /** - * Date string in RFC 3339 format. Only entries created after the specified date will be + * 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 } /** - * Date string in RFC 3339 format. Only entries created before the specified date will be + * 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 } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventListAttemptsParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventListAttemptsParams.kt index 2d2f513d..37234c1b 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventListAttemptsParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventListAttemptsParams.kt @@ -133,13 +133,13 @@ constructor( fun eventToken(eventToken: String) = apply { this.eventToken = eventToken } /** - * Date string in RFC 3339 format. Only entries created after the specified date will be + * 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 } /** - * Date string in RFC 3339 format. Only entries created before the specified date will be + * 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 } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventListParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventListParams.kt index 3afb2ea9..c9b862b1 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventListParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventListParams.kt @@ -125,13 +125,13 @@ constructor( } /** - * Date string in RFC 3339 format. Only entries created after the specified date will be + * 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 } /** - * Date string in RFC 3339 format. Only entries created before the specified date will be + * 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 } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionListAttemptsParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionListAttemptsParams.kt index 47d29bfc..14cadbe5 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionListAttemptsParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionListAttemptsParams.kt @@ -137,13 +137,13 @@ constructor( } /** - * Date string in RFC 3339 format. Only entries created after the specified date will be + * 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 } /** - * Date string in RFC 3339 format. Only entries created before the specified date will be + * 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 } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionRecoverParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionRecoverParams.kt index 52aa46af..a9019d73 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionRecoverParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionRecoverParams.kt @@ -111,13 +111,13 @@ constructor( } /** - * Date string in RFC 3339 format. Only entries created after the specified date will be + * 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 } /** - * Date string in RFC 3339 format. Only entries created before the specified date will be + * 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 } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionReplayMissingParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionReplayMissingParams.kt index 632e62d0..b9266e69 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionReplayMissingParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/EventSubscriptionReplayMissingParams.kt @@ -114,13 +114,13 @@ constructor( } /** - * Date string in RFC 3339 format. Only entries created after the specified date will be + * 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 } /** - * Date string in RFC 3339 format. Only entries created before the specified date will be + * 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 } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementLineItemListPage.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementLineItemListPage.kt new file mode 100644 index 00000000..2216aa50 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementLineItemListPage.kt @@ -0,0 +1,208 @@ +// 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.financialAccounts.statements.LineItemService +import java.util.Objects + +class FinancialAccountStatementLineItemListPage +private constructor( + private val lineItemsService: LineItemService, + private val params: FinancialAccountStatementLineItemListParams, + 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 FinancialAccountStatementLineItemListPage && + this.lineItemsService == other.lineItemsService && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + lineItemsService, + params, + response, + ) + } + + override fun toString() = + "FinancialAccountStatementLineItemListPage{lineItemsService=$lineItemsService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return data().isEmpty() + } + + fun getNextPageParams(): FinancialAccountStatementLineItemListParams? { + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + FinancialAccountStatementLineItemListParams.builder() + .from(params) + .endingBefore(data().first().token()) + .build() + } else { + FinancialAccountStatementLineItemListParams.builder() + .from(params) + .startingAfter(data().last().token()) + .build() + } + } + + fun getNextPage(): FinancialAccountStatementLineItemListPage? { + return getNextPageParams()?.let { lineItemsService.list(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + fun of( + lineItemsService: LineItemService, + params: FinancialAccountStatementLineItemListParams, + response: Response + ) = + FinancialAccountStatementLineItemListPage( + lineItemsService, + 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(): JsonField>? = data + + @JsonProperty("has_more") fun _hasMore(): JsonField? = 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() = + "FinancialAccountStatementLineItemListPage.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + 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: FinancialAccountStatementLineItemListPage, + ) : Sequence { + + 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() ?: break + index = 0 + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementLineItemListPageAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementLineItemListPageAsync.kt new file mode 100644 index 00000000..a3d780a9 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementLineItemListPageAsync.kt @@ -0,0 +1,210 @@ +// 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.financialAccounts.statements.LineItemServiceAsync +import java.util.Objects +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector + +class FinancialAccountStatementLineItemListPageAsync +private constructor( + private val lineItemsService: LineItemServiceAsync, + private val params: FinancialAccountStatementLineItemListParams, + 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 FinancialAccountStatementLineItemListPageAsync && + this.lineItemsService == other.lineItemsService && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + lineItemsService, + params, + response, + ) + } + + override fun toString() = + "FinancialAccountStatementLineItemListPageAsync{lineItemsService=$lineItemsService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return data().isEmpty() + } + + fun getNextPageParams(): FinancialAccountStatementLineItemListParams? { + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + FinancialAccountStatementLineItemListParams.builder() + .from(params) + .endingBefore(data().first().token()) + .build() + } else { + FinancialAccountStatementLineItemListParams.builder() + .from(params) + .startingAfter(data().last().token()) + .build() + } + } + + suspend fun getNextPage(): FinancialAccountStatementLineItemListPageAsync? { + return getNextPageParams()?.let { lineItemsService.list(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + fun of( + lineItemsService: LineItemServiceAsync, + params: FinancialAccountStatementLineItemListParams, + response: Response + ) = + FinancialAccountStatementLineItemListPageAsync( + lineItemsService, + 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(): JsonField>? = data + + @JsonProperty("has_more") fun _hasMore(): JsonField? = 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() = + "FinancialAccountStatementLineItemListPageAsync.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + 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: FinancialAccountStatementLineItemListPageAsync, + ) : Flow { + + override suspend fun collect(collector: FlowCollector) { + var page = firstPage + var index = 0 + while (true) { + while (index < page.data().size) { + collector.emit(page.data()[index++]) + } + page = page.getNextPage() ?: break + index = 0 + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementLineItemListParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementLineItemListParams.kt new file mode 100644 index 00000000..fa11d681 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementLineItemListParams.kt @@ -0,0 +1,189 @@ +// 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 FinancialAccountStatementLineItemListParams +constructor( + private val financialAccountToken: String, + private val statementToken: String, + private val endingBefore: String?, + private val pageSize: Long?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun financialAccountToken(): String = financialAccountToken + + fun statementToken(): String = statementToken + + fun endingBefore(): String? = endingBefore + + fun pageSize(): Long? = pageSize + + fun startingAfter(): String? = startingAfter + + internal fun getQueryParams(): Map> { + val params = mutableMapOf>() + 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() + } + + internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> financialAccountToken + 1 -> statementToken + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FinancialAccountStatementLineItemListParams && + this.financialAccountToken == other.financialAccountToken && + this.statementToken == other.statementToken && + 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( + financialAccountToken, + statementToken, + endingBefore, + pageSize, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "FinancialAccountStatementLineItemListParams{financialAccountToken=$financialAccountToken, statementToken=$statementToken, endingBefore=$endingBefore, pageSize=$pageSize, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var financialAccountToken: String? = null + private var statementToken: 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() + + internal fun from( + financialAccountStatementLineItemListParams: FinancialAccountStatementLineItemListParams + ) = apply { + this.financialAccountToken = + financialAccountStatementLineItemListParams.financialAccountToken + this.statementToken = financialAccountStatementLineItemListParams.statementToken + this.endingBefore = financialAccountStatementLineItemListParams.endingBefore + this.pageSize = financialAccountStatementLineItemListParams.pageSize + this.startingAfter = financialAccountStatementLineItemListParams.startingAfter + additionalQueryParams(financialAccountStatementLineItemListParams.additionalQueryParams) + additionalHeaders(financialAccountStatementLineItemListParams.additionalHeaders) + } + + fun financialAccountToken(financialAccountToken: String) = apply { + this.financialAccountToken = financialAccountToken + } + + fun statementToken(statementToken: String) = apply { this.statementToken = statementToken } + + /** + * 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(): FinancialAccountStatementLineItemListParams = + FinancialAccountStatementLineItemListParams( + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + checkNotNull(statementToken) { "`statementToken` is required but was not set" }, + endingBefore, + pageSize, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementListPage.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementListPage.kt new file mode 100644 index 00000000..8f6f9f2f --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementListPage.kt @@ -0,0 +1,208 @@ +// 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.financialAccounts.StatementService +import java.util.Objects + +class FinancialAccountStatementListPage +private constructor( + private val statementsService: StatementService, + private val params: FinancialAccountStatementListParams, + 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 FinancialAccountStatementListPage && + this.statementsService == other.statementsService && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + statementsService, + params, + response, + ) + } + + override fun toString() = + "FinancialAccountStatementListPage{statementsService=$statementsService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return data().isEmpty() + } + + fun getNextPageParams(): FinancialAccountStatementListParams? { + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + FinancialAccountStatementListParams.builder() + .from(params) + .endingBefore(data().first().token()) + .build() + } else { + FinancialAccountStatementListParams.builder() + .from(params) + .startingAfter(data().last().token()) + .build() + } + } + + fun getNextPage(): FinancialAccountStatementListPage? { + return getNextPageParams()?.let { statementsService.list(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + fun of( + statementsService: StatementService, + params: FinancialAccountStatementListParams, + response: Response + ) = + FinancialAccountStatementListPage( + statementsService, + 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(): JsonField>? = data + + @JsonProperty("has_more") fun _hasMore(): JsonField? = 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() = + "FinancialAccountStatementListPage.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + 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: FinancialAccountStatementListPage, + ) : Sequence { + + 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() ?: break + index = 0 + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementListPageAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementListPageAsync.kt new file mode 100644 index 00000000..d0fa1c6b --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementListPageAsync.kt @@ -0,0 +1,210 @@ +// 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.financialAccounts.StatementServiceAsync +import java.util.Objects +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector + +class FinancialAccountStatementListPageAsync +private constructor( + private val statementsService: StatementServiceAsync, + private val params: FinancialAccountStatementListParams, + 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 FinancialAccountStatementListPageAsync && + this.statementsService == other.statementsService && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + statementsService, + params, + response, + ) + } + + override fun toString() = + "FinancialAccountStatementListPageAsync{statementsService=$statementsService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return data().isEmpty() + } + + fun getNextPageParams(): FinancialAccountStatementListParams? { + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + FinancialAccountStatementListParams.builder() + .from(params) + .endingBefore(data().first().token()) + .build() + } else { + FinancialAccountStatementListParams.builder() + .from(params) + .startingAfter(data().last().token()) + .build() + } + } + + suspend fun getNextPage(): FinancialAccountStatementListPageAsync? { + return getNextPageParams()?.let { statementsService.list(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + fun of( + statementsService: StatementServiceAsync, + params: FinancialAccountStatementListParams, + response: Response + ) = + FinancialAccountStatementListPageAsync( + statementsService, + 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(): JsonField>? = data + + @JsonProperty("has_more") fun _hasMore(): JsonField? = 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() = + "FinancialAccountStatementListPageAsync.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + 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: FinancialAccountStatementListPageAsync, + ) : Flow { + + override suspend fun collect(collector: FlowCollector) { + var page = firstPage + var index = 0 + while (true) { + while (index < page.data().size) { + collector.emit(page.data()[index++]) + } + page = page.getNextPage() ?: break + index = 0 + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementListParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementListParams.kt new file mode 100644 index 00000000..d8523b86 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementListParams.kt @@ -0,0 +1,208 @@ +// 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.time.LocalDate +import java.util.Objects + +class FinancialAccountStatementListParams +constructor( + private val financialAccountToken: String, + private val begin: LocalDate?, + private val end: LocalDate?, + private val endingBefore: String?, + private val pageSize: Long?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun financialAccountToken(): String = financialAccountToken + + fun begin(): LocalDate? = begin + + fun end(): LocalDate? = end + + fun endingBefore(): String? = endingBefore + + fun pageSize(): Long? = pageSize + + fun startingAfter(): String? = startingAfter + + internal fun getQueryParams(): Map> { + val params = mutableMapOf>() + this.begin?.let { params.put("begin", listOf(it.toString())) } + this.end?.let { params.put("end", 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() + } + + internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> financialAccountToken + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FinancialAccountStatementListParams && + this.financialAccountToken == other.financialAccountToken && + this.begin == other.begin && + this.end == other.end && + 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( + financialAccountToken, + begin, + end, + endingBefore, + pageSize, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "FinancialAccountStatementListParams{financialAccountToken=$financialAccountToken, begin=$begin, end=$end, endingBefore=$endingBefore, pageSize=$pageSize, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var financialAccountToken: String? = null + private var begin: LocalDate? = null + private var end: LocalDate? = 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() + + internal fun from( + financialAccountStatementListParams: FinancialAccountStatementListParams + ) = apply { + this.financialAccountToken = financialAccountStatementListParams.financialAccountToken + this.begin = financialAccountStatementListParams.begin + this.end = financialAccountStatementListParams.end + this.endingBefore = financialAccountStatementListParams.endingBefore + this.pageSize = financialAccountStatementListParams.pageSize + this.startingAfter = financialAccountStatementListParams.startingAfter + additionalQueryParams(financialAccountStatementListParams.additionalQueryParams) + additionalHeaders(financialAccountStatementListParams.additionalHeaders) + } + + fun financialAccountToken(financialAccountToken: String) = apply { + this.financialAccountToken = financialAccountToken + } + + /** + * Date string in RFC 3339 format. Only entries created after the specified date will be + * included. + */ + fun begin(begin: LocalDate) = apply { this.begin = begin } + + /** + * Date string in RFC 3339 format. Only entries created before the specified date will be + * included. + */ + fun end(end: LocalDate) = 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 } + + /** 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(): FinancialAccountStatementListParams = + FinancialAccountStatementListParams( + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + begin, + end, + endingBefore, + pageSize, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementRetrieveParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementRetrieveParams.kt new file mode 100644 index 00000000..210f7379 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialAccountStatementRetrieveParams.kt @@ -0,0 +1,143 @@ +// 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 FinancialAccountStatementRetrieveParams +constructor( + private val financialAccountToken: String, + private val statementToken: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun financialAccountToken(): String = financialAccountToken + + fun statementToken(): String = statementToken + + internal fun getQueryParams(): Map> = additionalQueryParams + + internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> financialAccountToken + 1 -> statementToken + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FinancialAccountStatementRetrieveParams && + this.financialAccountToken == other.financialAccountToken && + this.statementToken == other.statementToken && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders + } + + override fun hashCode(): Int { + return Objects.hash( + financialAccountToken, + statementToken, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "FinancialAccountStatementRetrieveParams{financialAccountToken=$financialAccountToken, statementToken=$statementToken, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var financialAccountToken: String? = null + private var statementToken: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + + internal fun from( + financialAccountStatementRetrieveParams: FinancialAccountStatementRetrieveParams + ) = apply { + this.financialAccountToken = + financialAccountStatementRetrieveParams.financialAccountToken + this.statementToken = financialAccountStatementRetrieveParams.statementToken + additionalQueryParams(financialAccountStatementRetrieveParams.additionalQueryParams) + additionalHeaders(financialAccountStatementRetrieveParams.additionalHeaders) + } + + fun financialAccountToken(financialAccountToken: String) = apply { + this.financialAccountToken = financialAccountToken + } + + fun statementToken(statementToken: String) = apply { this.statementToken = statementToken } + + 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(): FinancialAccountStatementRetrieveParams = + FinancialAccountStatementRetrieveParams( + checkNotNull(financialAccountToken) { + "`financialAccountToken` is required but was not set" + }, + checkNotNull(statementToken) { "`statementToken` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialTransaction.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialTransaction.kt index db190dd5..6d17b68c 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialTransaction.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialTransaction.kt @@ -515,7 +515,7 @@ private constructor( private val created: JsonField, private val result: JsonField, private val token: JsonField, - private val type: JsonField, + private val type: JsonField, private val additionalProperties: Map, ) { @@ -576,7 +576,7 @@ private constructor( * - `TRANSFER_INSUFFICIENT_FUNDS` - Declined internl transfer of funds due to insufficient * balance of the sender. */ - fun type(): Type? = type.getNullable("type") + fun type(): FinancialEventType? = type.getNullable("type") /** * Amount of the financial event that has been settled in the currency's smallest unit @@ -693,7 +693,7 @@ private constructor( private var created: JsonField = JsonMissing.of() private var result: JsonField = JsonMissing.of() private var token: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(financialEvent: FinancialEvent) = apply { @@ -784,7 +784,7 @@ private constructor( * - `TRANSFER_INSUFFICIENT_FUNDS` - Declined internl transfer of funds due to * insufficient balance of the sender. */ - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: FinancialEventType) = type(JsonField.of(type)) /** * Event types: @@ -823,7 +823,7 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -907,7 +907,7 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - class Type + class FinancialEventType @JsonCreator private constructor( private val value: JsonField, @@ -920,7 +920,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return other is FinancialEventType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -929,52 +929,59 @@ private constructor( companion object { - val ACH_INSUFFICIENT_FUNDS = Type(JsonField.of("ACH_INSUFFICIENT_FUNDS")) + val ACH_INSUFFICIENT_FUNDS = + FinancialEventType(JsonField.of("ACH_INSUFFICIENT_FUNDS")) - val ACH_ORIGINATION_PENDING = Type(JsonField.of("ACH_ORIGINATION_PENDING")) + val ACH_ORIGINATION_PENDING = + FinancialEventType(JsonField.of("ACH_ORIGINATION_PENDING")) - val ACH_ORIGINATION_RELEASED = Type(JsonField.of("ACH_ORIGINATION_RELEASED")) + val ACH_ORIGINATION_RELEASED = + FinancialEventType(JsonField.of("ACH_ORIGINATION_RELEASED")) - val ACH_RECEIPT_PENDING = Type(JsonField.of("ACH_RECEIPT_PENDING")) + val ACH_RECEIPT_PENDING = FinancialEventType(JsonField.of("ACH_RECEIPT_PENDING")) - val ACH_RECEIPT_RELEASED = Type(JsonField.of("ACH_RECEIPT_RELEASED")) + val ACH_RECEIPT_RELEASED = FinancialEventType(JsonField.of("ACH_RECEIPT_RELEASED")) - val ACH_RETURN = Type(JsonField.of("ACH_RETURN")) + val ACH_RETURN = FinancialEventType(JsonField.of("ACH_RETURN")) - val AUTHORIZATION = Type(JsonField.of("AUTHORIZATION")) + val AUTHORIZATION = FinancialEventType(JsonField.of("AUTHORIZATION")) - val AUTHORIZATION_ADVICE = Type(JsonField.of("AUTHORIZATION_ADVICE")) + val AUTHORIZATION_ADVICE = FinancialEventType(JsonField.of("AUTHORIZATION_ADVICE")) - val AUTHORIZATION_EXPIRY = Type(JsonField.of("AUTHORIZATION_EXPIRY")) + val AUTHORIZATION_EXPIRY = FinancialEventType(JsonField.of("AUTHORIZATION_EXPIRY")) - val AUTHORIZATION_REVERSAL = Type(JsonField.of("AUTHORIZATION_REVERSAL")) + val AUTHORIZATION_REVERSAL = + FinancialEventType(JsonField.of("AUTHORIZATION_REVERSAL")) - val BALANCE_INQUIRY = Type(JsonField.of("BALANCE_INQUIRY")) + val BALANCE_INQUIRY = FinancialEventType(JsonField.of("BALANCE_INQUIRY")) - val CLEARING = Type(JsonField.of("CLEARING")) + val CLEARING = FinancialEventType(JsonField.of("CLEARING")) - val CORRECTION_DEBIT = Type(JsonField.of("CORRECTION_DEBIT")) + val CORRECTION_DEBIT = FinancialEventType(JsonField.of("CORRECTION_DEBIT")) - val CORRECTION_CREDIT = Type(JsonField.of("CORRECTION_CREDIT")) + val CORRECTION_CREDIT = FinancialEventType(JsonField.of("CORRECTION_CREDIT")) - val CREDIT_AUTHORIZATION = Type(JsonField.of("CREDIT_AUTHORIZATION")) + val CREDIT_AUTHORIZATION = FinancialEventType(JsonField.of("CREDIT_AUTHORIZATION")) - val CREDIT_AUTHORIZATION_ADVICE = Type(JsonField.of("CREDIT_AUTHORIZATION_ADVICE")) + val CREDIT_AUTHORIZATION_ADVICE = + FinancialEventType(JsonField.of("CREDIT_AUTHORIZATION_ADVICE")) - val FINANCIAL_AUTHORIZATION = Type(JsonField.of("FINANCIAL_AUTHORIZATION")) + val FINANCIAL_AUTHORIZATION = + FinancialEventType(JsonField.of("FINANCIAL_AUTHORIZATION")) val FINANCIAL_CREDIT_AUTHORIZATION = - Type(JsonField.of("FINANCIAL_CREDIT_AUTHORIZATION")) + FinancialEventType(JsonField.of("FINANCIAL_CREDIT_AUTHORIZATION")) - val RETURN = Type(JsonField.of("RETURN")) + val RETURN = FinancialEventType(JsonField.of("RETURN")) - val RETURN_REVERSAL = Type(JsonField.of("RETURN_REVERSAL")) + val RETURN_REVERSAL = FinancialEventType(JsonField.of("RETURN_REVERSAL")) - val TRANSFER = Type(JsonField.of("TRANSFER")) + val TRANSFER = FinancialEventType(JsonField.of("TRANSFER")) - val TRANSFER_INSUFFICIENT_FUNDS = Type(JsonField.of("TRANSFER_INSUFFICIENT_FUNDS")) + val TRANSFER_INSUFFICIENT_FUNDS = + FinancialEventType(JsonField.of("TRANSFER_INSUFFICIENT_FUNDS")) - fun of(value: String) = Type(JsonField.of(value)) + fun of(value: String) = FinancialEventType(JsonField.of(value)) } enum class Known { @@ -1079,7 +1086,7 @@ private constructor( RETURN_REVERSAL -> Known.RETURN_REVERSAL TRANSFER -> Known.TRANSFER TRANSFER_INSUFFICIENT_FUNDS -> Known.TRANSFER_INSUFFICIENT_FUNDS - else -> throw LithicInvalidDataException("Unknown Type: $value") + else -> throw LithicInvalidDataException("Unknown FinancialEventType: $value") } fun asString(): String = _value().asStringOrThrow() diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialTransactionListParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialTransactionListParams.kt index 962f1baa..478e8546 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialTransactionListParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/FinancialTransactionListParams.kt @@ -143,7 +143,7 @@ constructor( } /** - * Date string in RFC 3339 format. Only entries created after the specified date will be + * 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 } @@ -152,7 +152,7 @@ constructor( fun category(category: Category) = apply { this.category = category } /** - * Date string in RFC 3339 format. Only entries created before the specified date will be + * 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 } @@ -380,6 +380,8 @@ constructor( val PENDING = Status(JsonField.of("PENDING")) + val RETURNED = Status(JsonField.of("RETURNED")) + val SETTLED = Status(JsonField.of("SETTLED")) val VOIDED = Status(JsonField.of("VOIDED")) @@ -391,6 +393,7 @@ constructor( DECLINED, EXPIRED, PENDING, + RETURNED, SETTLED, VOIDED, } @@ -399,6 +402,7 @@ constructor( DECLINED, EXPIRED, PENDING, + RETURNED, SETTLED, VOIDED, _UNKNOWN, @@ -409,6 +413,7 @@ constructor( DECLINED -> Value.DECLINED EXPIRED -> Value.EXPIRED PENDING -> Value.PENDING + RETURNED -> Value.RETURNED SETTLED -> Value.SETTLED VOIDED -> Value.VOIDED else -> Value._UNKNOWN @@ -419,6 +424,7 @@ constructor( DECLINED -> Known.DECLINED EXPIRED -> Known.EXPIRED PENDING -> Known.PENDING + RETURNED -> Known.RETURNED SETTLED -> Known.SETTLED VOIDED -> Known.VOIDED else -> throw LithicInvalidDataException("Unknown Status: $value") diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/LineItemListResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/LineItemListResponse.kt new file mode 100644 index 00000000..d8a2cf1f --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/LineItemListResponse.kt @@ -0,0 +1,709 @@ +// 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.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 + +@JsonDeserialize(builder = LineItemListResponse.Builder::class) +@NoAutoDetect +class LineItemListResponse +private constructor( + private val amount: JsonField, + private val cardToken: JsonField, + private val category: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val descriptor: JsonField, + private val eventType: JsonField, + private val financialAccountToken: JsonField, + private val financialTransactionToken: JsonField, + private val settledDate: JsonField, + private val token: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun amount(): Long = amount.getRequired("amount") + + /** Globally unique identifier for a card */ + fun cardToken(): String? = cardToken.getNullable("card_token") + + fun category(): Category = category.getRequired("category") + + /** Timestamp of when the line item was generated */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** 3-digit alphabetic ISO 4217 code for the settling currency of the transaction */ + fun currency(): String = currency.getRequired("currency") + + fun descriptor(): String? = descriptor.getNullable("descriptor") + + /** + * Event types: + * + * - `ACH_INSUFFICIENT_FUNDS` - Attempted ACH origination declined due to insufficient balance. + * - `ACH_ORIGINATION_PENDING` - ACH origination pending release from an ACH hold. + * - `ACH_ORIGINATION_RELEASED` - ACH origination released from pending to available balance. + * - `ACH_RECEIPT_PENDING` - ACH receipt pending release from an ACH holder. + * - `ACH_RECEIPT_RELEASED` - ACH receipt released from pending to available balance. + * - `ACH_RETURN` - ACH origination returned by the Receiving Depository Financial Institution. + * - `AUTHORIZATION` - Authorize a card transaction. + * - `AUTHORIZATION_ADVICE` - Advice on a card transaction. + * - `AUTHORIZATION_EXPIRY` - Card Authorization has expired and reversed by Lithic. + * - `AUTHORIZATION_REVERSAL` - Card Authorization was reversed by the merchant. + * - `BALANCE_INQUIRY` - A card balance inquiry (typically a $0 authorization) has occurred on a + * card. + * - `CLEARING` - Card Transaction is settled. + * - `CORRECTION_DEBIT` - Manual card transaction correction (Debit). + * - `CORRECTION_CREDIT` - Manual card transaction correction (Credit). + * - `CREDIT_AUTHORIZATION` - A refund or credit card authorization from a merchant. + * - `CREDIT_AUTHORIZATION_ADVICE` - A credit card authorization was approved on your behalf by + * the network. + * - `FINANCIAL_AUTHORIZATION` - A request from a merchant to debit card funds without + * additional clearing. + * - `FINANCIAL_CREDIT_AUTHORIZATION` - A request from a merchant to refund or credit card funds + * without additional clearing. + * - `RETURN` - A card refund has been processed on the transaction. + * - `RETURN_REVERSAL` - A card refund has been reversed (e.g., when a merchant reverses an + * incorrect refund). + * - `TRANSFER` - Successful internal transfer of funds between financial accounts. + * - `TRANSFER_INSUFFICIENT_FUNDS` - Declined internl transfer of funds due to insufficient + * balance of the sender. + */ + fun eventType(): FinancialEventType = eventType.getRequired("event_type") + + /** Globally unique identifier for a financial account */ + fun financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + /** Globally unique identifier for a financial transaction */ + fun financialTransactionToken(): String = + financialTransactionToken.getRequired("financial_transaction_token") + + /** Date that the transaction settled */ + fun settledDate(): LocalDate = settledDate.getRequired("settled_date") + + /** Globally unique identifier for a Statement Line Item */ + fun token(): String = token.getRequired("token") + + @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + + /** Globally unique identifier for a card */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken() = cardToken + + @JsonProperty("category") @ExcludeMissing fun _category() = category + + /** Timestamp of when the line item was generated */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** 3-digit alphabetic ISO 4217 code for the settling currency of the transaction */ + @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + + @JsonProperty("descriptor") @ExcludeMissing fun _descriptor() = descriptor + + /** + * Event types: + * + * - `ACH_INSUFFICIENT_FUNDS` - Attempted ACH origination declined due to insufficient balance. + * - `ACH_ORIGINATION_PENDING` - ACH origination pending release from an ACH hold. + * - `ACH_ORIGINATION_RELEASED` - ACH origination released from pending to available balance. + * - `ACH_RECEIPT_PENDING` - ACH receipt pending release from an ACH holder. + * - `ACH_RECEIPT_RELEASED` - ACH receipt released from pending to available balance. + * - `ACH_RETURN` - ACH origination returned by the Receiving Depository Financial Institution. + * - `AUTHORIZATION` - Authorize a card transaction. + * - `AUTHORIZATION_ADVICE` - Advice on a card transaction. + * - `AUTHORIZATION_EXPIRY` - Card Authorization has expired and reversed by Lithic. + * - `AUTHORIZATION_REVERSAL` - Card Authorization was reversed by the merchant. + * - `BALANCE_INQUIRY` - A card balance inquiry (typically a $0 authorization) has occurred on a + * card. + * - `CLEARING` - Card Transaction is settled. + * - `CORRECTION_DEBIT` - Manual card transaction correction (Debit). + * - `CORRECTION_CREDIT` - Manual card transaction correction (Credit). + * - `CREDIT_AUTHORIZATION` - A refund or credit card authorization from a merchant. + * - `CREDIT_AUTHORIZATION_ADVICE` - A credit card authorization was approved on your behalf by + * the network. + * - `FINANCIAL_AUTHORIZATION` - A request from a merchant to debit card funds without + * additional clearing. + * - `FINANCIAL_CREDIT_AUTHORIZATION` - A request from a merchant to refund or credit card funds + * without additional clearing. + * - `RETURN` - A card refund has been processed on the transaction. + * - `RETURN_REVERSAL` - A card refund has been reversed (e.g., when a merchant reverses an + * incorrect refund). + * - `TRANSFER` - Successful internal transfer of funds between financial accounts. + * - `TRANSFER_INSUFFICIENT_FUNDS` - Declined internl transfer of funds due to insufficient + * balance of the sender. + */ + @JsonProperty("event_type") @ExcludeMissing fun _eventType() = eventType + + /** Globally unique identifier for a financial account */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken() = financialAccountToken + + /** Globally unique identifier for a financial transaction */ + @JsonProperty("financial_transaction_token") + @ExcludeMissing + fun _financialTransactionToken() = financialTransactionToken + + /** Date that the transaction settled */ + @JsonProperty("settled_date") @ExcludeMissing fun _settledDate() = settledDate + + /** Globally unique identifier for a Statement Line Item */ + @JsonProperty("token") @ExcludeMissing fun _token() = token + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): LineItemListResponse = apply { + if (!validated) { + amount() + cardToken() + category() + created() + currency() + descriptor() + eventType() + financialAccountToken() + financialTransactionToken() + settledDate() + token() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LineItemListResponse && + this.amount == other.amount && + this.cardToken == other.cardToken && + this.category == other.category && + this.created == other.created && + this.currency == other.currency && + this.descriptor == other.descriptor && + this.eventType == other.eventType && + this.financialAccountToken == other.financialAccountToken && + this.financialTransactionToken == other.financialTransactionToken && + this.settledDate == other.settledDate && + this.token == other.token && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + amount, + cardToken, + category, + created, + currency, + descriptor, + eventType, + financialAccountToken, + financialTransactionToken, + settledDate, + token, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "LineItemListResponse{amount=$amount, cardToken=$cardToken, category=$category, created=$created, currency=$currency, descriptor=$descriptor, eventType=$eventType, financialAccountToken=$financialAccountToken, financialTransactionToken=$financialTransactionToken, settledDate=$settledDate, token=$token, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var amount: JsonField = JsonMissing.of() + private var cardToken: JsonField = JsonMissing.of() + private var category: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var descriptor: JsonField = JsonMissing.of() + private var eventType: JsonField = JsonMissing.of() + private var financialAccountToken: JsonField = JsonMissing.of() + private var financialTransactionToken: JsonField = JsonMissing.of() + private var settledDate: JsonField = JsonMissing.of() + private var token: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(lineItemListResponse: LineItemListResponse) = apply { + this.amount = lineItemListResponse.amount + this.cardToken = lineItemListResponse.cardToken + this.category = lineItemListResponse.category + this.created = lineItemListResponse.created + this.currency = lineItemListResponse.currency + this.descriptor = lineItemListResponse.descriptor + this.eventType = lineItemListResponse.eventType + this.financialAccountToken = lineItemListResponse.financialAccountToken + this.financialTransactionToken = lineItemListResponse.financialTransactionToken + this.settledDate = lineItemListResponse.settledDate + this.token = lineItemListResponse.token + additionalProperties(lineItemListResponse.additionalProperties) + } + + fun amount(amount: Long) = amount(JsonField.of(amount)) + + @JsonProperty("amount") + @ExcludeMissing + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Globally unique identifier for a card */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** Globally unique identifier for a card */ + @JsonProperty("card_token") + @ExcludeMissing + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + fun category(category: Category) = category(JsonField.of(category)) + + @JsonProperty("category") + @ExcludeMissing + fun category(category: JsonField) = apply { this.category = category } + + /** Timestamp of when the line item was generated */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** Timestamp of when the line item was generated */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** 3-digit alphabetic ISO 4217 code for the settling currency of the transaction */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** 3-digit alphabetic ISO 4217 code for the settling currency of the transaction */ + @JsonProperty("currency") + @ExcludeMissing + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun descriptor(descriptor: String) = descriptor(JsonField.of(descriptor)) + + @JsonProperty("descriptor") + @ExcludeMissing + fun descriptor(descriptor: JsonField) = apply { this.descriptor = descriptor } + + /** + * Event types: + * + * - `ACH_INSUFFICIENT_FUNDS` - Attempted ACH origination declined due to insufficient + * balance. + * - `ACH_ORIGINATION_PENDING` - ACH origination pending release from an ACH hold. + * - `ACH_ORIGINATION_RELEASED` - ACH origination released from pending to available + * balance. + * - `ACH_RECEIPT_PENDING` - ACH receipt pending release from an ACH holder. + * - `ACH_RECEIPT_RELEASED` - ACH receipt released from pending to available balance. + * - `ACH_RETURN` - ACH origination returned by the Receiving Depository Financial + * Institution. + * - `AUTHORIZATION` - Authorize a card transaction. + * - `AUTHORIZATION_ADVICE` - Advice on a card transaction. + * - `AUTHORIZATION_EXPIRY` - Card Authorization has expired and reversed by Lithic. + * - `AUTHORIZATION_REVERSAL` - Card Authorization was reversed by the merchant. + * - `BALANCE_INQUIRY` - A card balance inquiry (typically a $0 authorization) has occurred + * on a card. + * - `CLEARING` - Card Transaction is settled. + * - `CORRECTION_DEBIT` - Manual card transaction correction (Debit). + * - `CORRECTION_CREDIT` - Manual card transaction correction (Credit). + * - `CREDIT_AUTHORIZATION` - A refund or credit card authorization from a merchant. + * - `CREDIT_AUTHORIZATION_ADVICE` - A credit card authorization was approved on your behalf + * by the network. + * - `FINANCIAL_AUTHORIZATION` - A request from a merchant to debit card funds without + * additional clearing. + * - `FINANCIAL_CREDIT_AUTHORIZATION` - A request from a merchant to refund or credit card + * funds without additional clearing. + * - `RETURN` - A card refund has been processed on the transaction. + * - `RETURN_REVERSAL` - A card refund has been reversed (e.g., when a merchant reverses an + * incorrect refund). + * - `TRANSFER` - Successful internal transfer of funds between financial accounts. + * - `TRANSFER_INSUFFICIENT_FUNDS` - Declined internl transfer of funds due to insufficient + * balance of the sender. + */ + fun eventType(eventType: FinancialEventType) = eventType(JsonField.of(eventType)) + + /** + * Event types: + * + * - `ACH_INSUFFICIENT_FUNDS` - Attempted ACH origination declined due to insufficient + * balance. + * - `ACH_ORIGINATION_PENDING` - ACH origination pending release from an ACH hold. + * - `ACH_ORIGINATION_RELEASED` - ACH origination released from pending to available + * balance. + * - `ACH_RECEIPT_PENDING` - ACH receipt pending release from an ACH holder. + * - `ACH_RECEIPT_RELEASED` - ACH receipt released from pending to available balance. + * - `ACH_RETURN` - ACH origination returned by the Receiving Depository Financial + * Institution. + * - `AUTHORIZATION` - Authorize a card transaction. + * - `AUTHORIZATION_ADVICE` - Advice on a card transaction. + * - `AUTHORIZATION_EXPIRY` - Card Authorization has expired and reversed by Lithic. + * - `AUTHORIZATION_REVERSAL` - Card Authorization was reversed by the merchant. + * - `BALANCE_INQUIRY` - A card balance inquiry (typically a $0 authorization) has occurred + * on a card. + * - `CLEARING` - Card Transaction is settled. + * - `CORRECTION_DEBIT` - Manual card transaction correction (Debit). + * - `CORRECTION_CREDIT` - Manual card transaction correction (Credit). + * - `CREDIT_AUTHORIZATION` - A refund or credit card authorization from a merchant. + * - `CREDIT_AUTHORIZATION_ADVICE` - A credit card authorization was approved on your behalf + * by the network. + * - `FINANCIAL_AUTHORIZATION` - A request from a merchant to debit card funds without + * additional clearing. + * - `FINANCIAL_CREDIT_AUTHORIZATION` - A request from a merchant to refund or credit card + * funds without additional clearing. + * - `RETURN` - A card refund has been processed on the transaction. + * - `RETURN_REVERSAL` - A card refund has been reversed (e.g., when a merchant reverses an + * incorrect refund). + * - `TRANSFER` - Successful internal transfer of funds between financial accounts. + * - `TRANSFER_INSUFFICIENT_FUNDS` - Declined internl transfer of funds due to insufficient + * balance of the sender. + */ + @JsonProperty("event_type") + @ExcludeMissing + fun eventType(eventType: JsonField) = apply { + this.eventType = eventType + } + + /** Globally unique identifier for a financial account */ + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** Globally unique identifier for a financial account */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + /** Globally unique identifier for a financial transaction */ + fun financialTransactionToken(financialTransactionToken: String) = + financialTransactionToken(JsonField.of(financialTransactionToken)) + + /** Globally unique identifier for a financial transaction */ + @JsonProperty("financial_transaction_token") + @ExcludeMissing + fun financialTransactionToken(financialTransactionToken: JsonField) = apply { + this.financialTransactionToken = financialTransactionToken + } + + /** Date that the transaction settled */ + fun settledDate(settledDate: LocalDate) = settledDate(JsonField.of(settledDate)) + + /** Date that the transaction settled */ + @JsonProperty("settled_date") + @ExcludeMissing + fun settledDate(settledDate: JsonField) = apply { + this.settledDate = settledDate + } + + /** Globally unique identifier for a Statement Line Item */ + fun token(token: String) = token(JsonField.of(token)) + + /** Globally unique identifier for a Statement Line Item */ + @JsonProperty("token") + @ExcludeMissing + fun token(token: JsonField) = apply { this.token = token } + + 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(): LineItemListResponse = + LineItemListResponse( + amount, + cardToken, + category, + created, + currency, + descriptor, + eventType, + financialAccountToken, + financialTransactionToken, + settledDate, + token, + additionalProperties.toUnmodifiable(), + ) + } + + class Category + @JsonCreator + private constructor( + private val value: JsonField, + ) { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Category && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + val CARD = Category(JsonField.of("CARD")) + + val ACH = Category(JsonField.of("ACH")) + + val TRANSFER = Category(JsonField.of("TRANSFER")) + + fun of(value: String) = Category(JsonField.of(value)) + } + + enum class Known { + CARD, + ACH, + TRANSFER, + } + + enum class Value { + CARD, + ACH, + TRANSFER, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + CARD -> Value.CARD + ACH -> Value.ACH + TRANSFER -> Value.TRANSFER + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + CARD -> Known.CARD + ACH -> Known.ACH + TRANSFER -> Known.TRANSFER + else -> throw LithicInvalidDataException("Unknown Category: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + class FinancialEventType + @JsonCreator + private constructor( + private val value: JsonField, + ) { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FinancialEventType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + val ACH_INSUFFICIENT_FUNDS = FinancialEventType(JsonField.of("ACH_INSUFFICIENT_FUNDS")) + + val ACH_ORIGINATION_PENDING = + FinancialEventType(JsonField.of("ACH_ORIGINATION_PENDING")) + + val ACH_ORIGINATION_RELEASED = + FinancialEventType(JsonField.of("ACH_ORIGINATION_RELEASED")) + + val ACH_RECEIPT_PENDING = FinancialEventType(JsonField.of("ACH_RECEIPT_PENDING")) + + val ACH_RECEIPT_RELEASED = FinancialEventType(JsonField.of("ACH_RECEIPT_RELEASED")) + + val ACH_RETURN = FinancialEventType(JsonField.of("ACH_RETURN")) + + val AUTHORIZATION = FinancialEventType(JsonField.of("AUTHORIZATION")) + + val AUTHORIZATION_ADVICE = FinancialEventType(JsonField.of("AUTHORIZATION_ADVICE")) + + val AUTHORIZATION_EXPIRY = FinancialEventType(JsonField.of("AUTHORIZATION_EXPIRY")) + + val AUTHORIZATION_REVERSAL = FinancialEventType(JsonField.of("AUTHORIZATION_REVERSAL")) + + val BALANCE_INQUIRY = FinancialEventType(JsonField.of("BALANCE_INQUIRY")) + + val CLEARING = FinancialEventType(JsonField.of("CLEARING")) + + val CORRECTION_DEBIT = FinancialEventType(JsonField.of("CORRECTION_DEBIT")) + + val CORRECTION_CREDIT = FinancialEventType(JsonField.of("CORRECTION_CREDIT")) + + val CREDIT_AUTHORIZATION = FinancialEventType(JsonField.of("CREDIT_AUTHORIZATION")) + + val CREDIT_AUTHORIZATION_ADVICE = + FinancialEventType(JsonField.of("CREDIT_AUTHORIZATION_ADVICE")) + + val FINANCIAL_AUTHORIZATION = + FinancialEventType(JsonField.of("FINANCIAL_AUTHORIZATION")) + + val FINANCIAL_CREDIT_AUTHORIZATION = + FinancialEventType(JsonField.of("FINANCIAL_CREDIT_AUTHORIZATION")) + + val RETURN = FinancialEventType(JsonField.of("RETURN")) + + val RETURN_REVERSAL = FinancialEventType(JsonField.of("RETURN_REVERSAL")) + + val TRANSFER = FinancialEventType(JsonField.of("TRANSFER")) + + val TRANSFER_INSUFFICIENT_FUNDS = + FinancialEventType(JsonField.of("TRANSFER_INSUFFICIENT_FUNDS")) + + fun of(value: String) = FinancialEventType(JsonField.of(value)) + } + + enum class Known { + ACH_INSUFFICIENT_FUNDS, + ACH_ORIGINATION_PENDING, + ACH_ORIGINATION_RELEASED, + ACH_RECEIPT_PENDING, + ACH_RECEIPT_RELEASED, + ACH_RETURN, + AUTHORIZATION, + AUTHORIZATION_ADVICE, + AUTHORIZATION_EXPIRY, + AUTHORIZATION_REVERSAL, + BALANCE_INQUIRY, + CLEARING, + CORRECTION_DEBIT, + CORRECTION_CREDIT, + CREDIT_AUTHORIZATION, + CREDIT_AUTHORIZATION_ADVICE, + FINANCIAL_AUTHORIZATION, + FINANCIAL_CREDIT_AUTHORIZATION, + RETURN, + RETURN_REVERSAL, + TRANSFER, + TRANSFER_INSUFFICIENT_FUNDS, + } + + enum class Value { + ACH_INSUFFICIENT_FUNDS, + ACH_ORIGINATION_PENDING, + ACH_ORIGINATION_RELEASED, + ACH_RECEIPT_PENDING, + ACH_RECEIPT_RELEASED, + ACH_RETURN, + AUTHORIZATION, + AUTHORIZATION_ADVICE, + AUTHORIZATION_EXPIRY, + AUTHORIZATION_REVERSAL, + BALANCE_INQUIRY, + CLEARING, + CORRECTION_DEBIT, + CORRECTION_CREDIT, + CREDIT_AUTHORIZATION, + CREDIT_AUTHORIZATION_ADVICE, + FINANCIAL_AUTHORIZATION, + FINANCIAL_CREDIT_AUTHORIZATION, + RETURN, + RETURN_REVERSAL, + TRANSFER, + TRANSFER_INSUFFICIENT_FUNDS, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + ACH_INSUFFICIENT_FUNDS -> Value.ACH_INSUFFICIENT_FUNDS + ACH_ORIGINATION_PENDING -> Value.ACH_ORIGINATION_PENDING + ACH_ORIGINATION_RELEASED -> Value.ACH_ORIGINATION_RELEASED + ACH_RECEIPT_PENDING -> Value.ACH_RECEIPT_PENDING + ACH_RECEIPT_RELEASED -> Value.ACH_RECEIPT_RELEASED + ACH_RETURN -> Value.ACH_RETURN + AUTHORIZATION -> Value.AUTHORIZATION + AUTHORIZATION_ADVICE -> Value.AUTHORIZATION_ADVICE + AUTHORIZATION_EXPIRY -> Value.AUTHORIZATION_EXPIRY + AUTHORIZATION_REVERSAL -> Value.AUTHORIZATION_REVERSAL + BALANCE_INQUIRY -> Value.BALANCE_INQUIRY + CLEARING -> Value.CLEARING + CORRECTION_DEBIT -> Value.CORRECTION_DEBIT + CORRECTION_CREDIT -> Value.CORRECTION_CREDIT + CREDIT_AUTHORIZATION -> Value.CREDIT_AUTHORIZATION + CREDIT_AUTHORIZATION_ADVICE -> Value.CREDIT_AUTHORIZATION_ADVICE + FINANCIAL_AUTHORIZATION -> Value.FINANCIAL_AUTHORIZATION + FINANCIAL_CREDIT_AUTHORIZATION -> Value.FINANCIAL_CREDIT_AUTHORIZATION + RETURN -> Value.RETURN + RETURN_REVERSAL -> Value.RETURN_REVERSAL + TRANSFER -> Value.TRANSFER + TRANSFER_INSUFFICIENT_FUNDS -> Value.TRANSFER_INSUFFICIENT_FUNDS + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + ACH_INSUFFICIENT_FUNDS -> Known.ACH_INSUFFICIENT_FUNDS + ACH_ORIGINATION_PENDING -> Known.ACH_ORIGINATION_PENDING + ACH_ORIGINATION_RELEASED -> Known.ACH_ORIGINATION_RELEASED + ACH_RECEIPT_PENDING -> Known.ACH_RECEIPT_PENDING + ACH_RECEIPT_RELEASED -> Known.ACH_RECEIPT_RELEASED + ACH_RETURN -> Known.ACH_RETURN + AUTHORIZATION -> Known.AUTHORIZATION + AUTHORIZATION_ADVICE -> Known.AUTHORIZATION_ADVICE + AUTHORIZATION_EXPIRY -> Known.AUTHORIZATION_EXPIRY + AUTHORIZATION_REVERSAL -> Known.AUTHORIZATION_REVERSAL + BALANCE_INQUIRY -> Known.BALANCE_INQUIRY + CLEARING -> Known.CLEARING + CORRECTION_DEBIT -> Known.CORRECTION_DEBIT + CORRECTION_CREDIT -> Known.CORRECTION_CREDIT + CREDIT_AUTHORIZATION -> Known.CREDIT_AUTHORIZATION + CREDIT_AUTHORIZATION_ADVICE -> Known.CREDIT_AUTHORIZATION_ADVICE + FINANCIAL_AUTHORIZATION -> Known.FINANCIAL_AUTHORIZATION + FINANCIAL_CREDIT_AUTHORIZATION -> Known.FINANCIAL_CREDIT_AUTHORIZATION + RETURN -> Known.RETURN + RETURN_REVERSAL -> Known.RETURN_REVERSAL + TRANSFER -> Known.TRANSFER + TRANSFER_INSUFFICIENT_FUNDS -> Known.TRANSFER_INSUFFICIENT_FUNDS + else -> throw LithicInvalidDataException("Unknown FinancialEventType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Payment.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Payment.kt index b230fb13..82f6a542 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Payment.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Payment.kt @@ -695,6 +695,8 @@ private constructor( @NoAutoDetect class PaymentMethodAttributes private constructor( + private val retries: JsonField, + private val returnReasonCode: JsonField, private val secCode: JsonField, private val additionalProperties: Map, ) { @@ -703,8 +705,18 @@ private constructor( private var hashCode: Int = 0 + fun retries(): Long? = retries.getNullable("retries") + + fun returnReasonCode(): String? = returnReasonCode.getNullable("return_reason_code") + fun secCode(): SecCode = secCode.getRequired("sec_code") + @JsonProperty("retries") @ExcludeMissing fun _retries() = retries + + @JsonProperty("return_reason_code") + @ExcludeMissing + fun _returnReasonCode() = returnReasonCode + @JsonProperty("sec_code") @ExcludeMissing fun _secCode() = secCode @JsonAnyGetter @@ -713,6 +725,8 @@ private constructor( fun validate(): PaymentMethodAttributes = apply { if (!validated) { + retries() + returnReasonCode() secCode() validated = true } @@ -726,19 +740,27 @@ private constructor( } return other is PaymentMethodAttributes && + this.retries == other.retries && + this.returnReasonCode == other.returnReasonCode && this.secCode == other.secCode && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { if (hashCode == 0) { - hashCode = Objects.hash(secCode, additionalProperties) + hashCode = + Objects.hash( + retries, + returnReasonCode, + secCode, + additionalProperties, + ) } return hashCode } override fun toString() = - "PaymentMethodAttributes{secCode=$secCode, additionalProperties=$additionalProperties}" + "PaymentMethodAttributes{retries=$retries, returnReasonCode=$returnReasonCode, secCode=$secCode, additionalProperties=$additionalProperties}" companion object { @@ -747,14 +769,33 @@ private constructor( class Builder { + private var retries: JsonField = JsonMissing.of() + private var returnReasonCode: JsonField = JsonMissing.of() private var secCode: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentMethodAttributes: PaymentMethodAttributes) = apply { + this.retries = paymentMethodAttributes.retries + this.returnReasonCode = paymentMethodAttributes.returnReasonCode this.secCode = paymentMethodAttributes.secCode additionalProperties(paymentMethodAttributes.additionalProperties) } + fun retries(retries: Long) = retries(JsonField.of(retries)) + + @JsonProperty("retries") + @ExcludeMissing + fun retries(retries: JsonField) = apply { this.retries = retries } + + fun returnReasonCode(returnReasonCode: String) = + returnReasonCode(JsonField.of(returnReasonCode)) + + @JsonProperty("return_reason_code") + @ExcludeMissing + fun returnReasonCode(returnReasonCode: JsonField) = apply { + this.returnReasonCode = returnReasonCode + } + fun secCode(secCode: SecCode) = secCode(JsonField.of(secCode)) @JsonProperty("sec_code") @@ -776,7 +817,12 @@ private constructor( } fun build(): PaymentMethodAttributes = - PaymentMethodAttributes(secCode, additionalProperties.toUnmodifiable()) + PaymentMethodAttributes( + retries, + returnReasonCode, + secCode, + additionalProperties.toUnmodifiable(), + ) } class SecCode diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentCreateParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentCreateParams.kt index bfeb9b70..4d3fd004 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentCreateParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentCreateParams.kt @@ -493,12 +493,18 @@ constructor( @NoAutoDetect class PaymentMethodAttributes private constructor( + private val retries: Long?, + private val returnReasonCode: String?, private val secCode: SecCode?, private val additionalProperties: Map, ) { private var hashCode: Int = 0 + @JsonProperty("retries") fun retries(): Long? = retries + + @JsonProperty("return_reason_code") fun returnReasonCode(): String? = returnReasonCode + @JsonProperty("sec_code") fun secCode(): SecCode? = secCode @JsonAnyGetter @@ -513,19 +519,27 @@ constructor( } return other is PaymentMethodAttributes && + this.retries == other.retries && + this.returnReasonCode == other.returnReasonCode && this.secCode == other.secCode && this.additionalProperties == other.additionalProperties } override fun hashCode(): Int { if (hashCode == 0) { - hashCode = Objects.hash(secCode, additionalProperties) + hashCode = + Objects.hash( + retries, + returnReasonCode, + secCode, + additionalProperties, + ) } return hashCode } override fun toString() = - "PaymentMethodAttributes{secCode=$secCode, additionalProperties=$additionalProperties}" + "PaymentMethodAttributes{retries=$retries, returnReasonCode=$returnReasonCode, secCode=$secCode, additionalProperties=$additionalProperties}" companion object { @@ -534,14 +548,25 @@ constructor( class Builder { + private var retries: Long? = null + private var returnReasonCode: String? = null private var secCode: SecCode? = null private var additionalProperties: MutableMap = mutableMapOf() internal fun from(paymentMethodAttributes: PaymentMethodAttributes) = apply { + this.retries = paymentMethodAttributes.retries + this.returnReasonCode = paymentMethodAttributes.returnReasonCode this.secCode = paymentMethodAttributes.secCode additionalProperties(paymentMethodAttributes.additionalProperties) } + @JsonProperty("retries") fun retries(retries: Long) = apply { this.retries = retries } + + @JsonProperty("return_reason_code") + fun returnReasonCode(returnReasonCode: String) = apply { + this.returnReasonCode = returnReasonCode + } + @JsonProperty("sec_code") fun secCode(secCode: SecCode) = apply { this.secCode = secCode } @@ -561,8 +586,10 @@ constructor( fun build(): PaymentMethodAttributes = PaymentMethodAttributes( + retries, + returnReasonCode, checkNotNull(secCode) { "`secCode` is required but was not set" }, - additionalProperties.toUnmodifiable() + additionalProperties.toUnmodifiable(), ) } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentRetryParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentRetryParams.kt new file mode 100644 index 00000000..4b1e8f89 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentRetryParams.kt @@ -0,0 +1,152 @@ +// 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 + +class PaymentRetryParams +constructor( + private val paymentToken: String, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun paymentToken(): String = paymentToken + + internal fun getBody(): Map? { + return additionalBodyProperties.ifEmpty { null } + } + + internal fun getQueryParams(): Map> = additionalQueryParams + + internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> paymentToken + 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 PaymentRetryParams && + this.paymentToken == other.paymentToken && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + paymentToken, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "PaymentRetryParams{paymentToken=$paymentToken, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var paymentToken: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + internal fun from(paymentRetryParams: PaymentRetryParams) = apply { + this.paymentToken = paymentRetryParams.paymentToken + additionalQueryParams(paymentRetryParams.additionalQueryParams) + additionalHeaders(paymentRetryParams.additionalHeaders) + additionalBodyProperties(paymentRetryParams.additionalBodyProperties) + } + + fun paymentToken(paymentToken: String) = apply { this.paymentToken = paymentToken } + + 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(): PaymentRetryParams = + PaymentRetryParams( + checkNotNull(paymentToken) { "`paymentToken` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentRetryResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentRetryResponse.kt new file mode 100644 index 00000000..346293eb --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/PaymentRetryResponse.kt @@ -0,0 +1,606 @@ +// 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.time.OffsetDateTime +import java.util.Objects + +@JsonDeserialize(builder = PaymentRetryResponse.Builder::class) +@NoAutoDetect +class PaymentRetryResponse +private constructor( + private val category: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val descriptor: JsonField, + private val events: JsonField>, + private val pendingAmount: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val status: JsonField, + private val token: JsonField, + private val updated: JsonField, + private val methodAttributes: JsonField, + private val externalBankAccountToken: JsonField, + private val direction: JsonField, + private val source: JsonField, + private val method: JsonField, + private val userDefinedId: JsonField, + private val balance: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** + * Status types: + * + * - `CARD` - Issuing card transaction. + * - `ACH` - Transaction over ACH. + * - `TRANSFER` - Internal transfer of funds between financial accounts in your program. + */ + fun category(): FinancialTransaction.Category = category.getRequired("category") + + /** Date and time when the financial transaction first occurred. UTC time zone. */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** 3-digit alphabetic ISO 4217 code for the settling currency of the transaction. */ + fun currency(): String = currency.getRequired("currency") + + /** + * A string that provides a description of the financial transaction; may be useful to display + * to users. + */ + fun descriptor(): String = descriptor.getRequired("descriptor") + + /** A list of all financial events that have modified this financial transaction. */ + fun events(): List = events.getRequired("events") + + /** + * Pending amount of the transaction in the currency's smallest unit (e.g., cents), including + * any acquirer fees. The value of this field will go to zero over time once the financial + * transaction is settled. + */ + fun pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + /** + * APPROVED transactions were successful while DECLINED transactions were declined by user, + * Lithic, or the network. + */ + fun result(): FinancialTransaction.Result = result.getRequired("result") + + /** + * Amount of the transaction that has been settled in the currency's smallest unit (e.g., + * cents), including any acquirer fees. This may change over time. + */ + fun settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * Status types: + * + * - `DECLINED` - The card transaction was declined. + * - `EXPIRED` - Lithic reversed the card authorization as it has passed its expiration time. + * - `PENDING` - Authorization is pending completion from the merchant or pending release from + * ACH hold period + * - `SETTLED` - The financial transaction is completed. + * - `VOIDED` - The merchant has voided the previously pending card authorization. + */ + fun status(): FinancialTransaction.Status = status.getRequired("status") + + /** Globally unique identifier. */ + fun token(): String = token.getRequired("token") + + /** Date and time when the financial transaction was last updated. UTC time zone. */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + fun methodAttributes(): Payment.PaymentMethodAttributes = + methodAttributes.getRequired("method_attributes") + + fun externalBankAccountToken(): String? = + externalBankAccountToken.getNullable("external_bank_account_token") + + fun direction(): Payment.Direction = direction.getRequired("direction") + + fun source(): Payment.Source = source.getRequired("source") + + fun method(): Payment.Method = method.getRequired("method") + + fun userDefinedId(): String? = userDefinedId.getNullable("user_defined_id") + + /** Balance of a Financial Account */ + fun balance(): Balance? = balance.getNullable("balance") + + fun toPayment(): Payment = + Payment.builder() + .category(category) + .created(created) + .currency(currency) + .descriptor(descriptor) + .events(events) + .pendingAmount(pendingAmount) + .result(result) + .settledAmount(settledAmount) + .status(status) + .token(token) + .updated(updated) + .methodAttributes(methodAttributes) + .externalBankAccountToken(externalBankAccountToken) + .direction(direction) + .source(source) + .method(method) + .userDefinedId(userDefinedId) + .build() + + /** + * Status types: + * + * - `CARD` - Issuing card transaction. + * - `ACH` - Transaction over ACH. + * - `TRANSFER` - Internal transfer of funds between financial accounts in your program. + */ + @JsonProperty("category") @ExcludeMissing fun _category() = category + + /** Date and time when the financial transaction first occurred. UTC time zone. */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** 3-digit alphabetic ISO 4217 code for the settling currency of the transaction. */ + @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + + /** + * A string that provides a description of the financial transaction; may be useful to display + * to users. + */ + @JsonProperty("descriptor") @ExcludeMissing fun _descriptor() = descriptor + + /** A list of all financial events that have modified this financial transaction. */ + @JsonProperty("events") @ExcludeMissing fun _events() = events + + /** + * Pending amount of the transaction in the currency's smallest unit (e.g., cents), including + * any acquirer fees. The value of this field will go to zero over time once the financial + * transaction is settled. + */ + @JsonProperty("pending_amount") @ExcludeMissing fun _pendingAmount() = pendingAmount + + /** + * APPROVED transactions were successful while DECLINED transactions were declined by user, + * Lithic, or the network. + */ + @JsonProperty("result") @ExcludeMissing fun _result() = result + + /** + * Amount of the transaction that has been settled in the currency's smallest unit (e.g., + * cents), including any acquirer fees. This may change over time. + */ + @JsonProperty("settled_amount") @ExcludeMissing fun _settledAmount() = settledAmount + + /** + * Status types: + * + * - `DECLINED` - The card transaction was declined. + * - `EXPIRED` - Lithic reversed the card authorization as it has passed its expiration time. + * - `PENDING` - Authorization is pending completion from the merchant or pending release from + * ACH hold period + * - `SETTLED` - The financial transaction is completed. + * - `VOIDED` - The merchant has voided the previously pending card authorization. + */ + @JsonProperty("status") @ExcludeMissing fun _status() = status + + /** Globally unique identifier. */ + @JsonProperty("token") @ExcludeMissing fun _token() = token + + /** Date and time when the financial transaction was last updated. UTC time zone. */ + @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + + @JsonProperty("method_attributes") @ExcludeMissing fun _methodAttributes() = methodAttributes + + @JsonProperty("external_bank_account_token") + @ExcludeMissing + fun _externalBankAccountToken() = externalBankAccountToken + + @JsonProperty("direction") @ExcludeMissing fun _direction() = direction + + @JsonProperty("source") @ExcludeMissing fun _source() = source + + @JsonProperty("method") @ExcludeMissing fun _method() = method + + @JsonProperty("user_defined_id") @ExcludeMissing fun _userDefinedId() = userDefinedId + + /** Balance of a Financial Account */ + @JsonProperty("balance") @ExcludeMissing fun _balance() = balance + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): PaymentRetryResponse = apply { + if (!validated) { + category() + created() + currency() + descriptor() + events().forEach { it.validate() } + pendingAmount() + result() + settledAmount() + status() + token() + updated() + methodAttributes().validate() + externalBankAccountToken() + direction() + source() + method() + userDefinedId() + balance()?.validate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentRetryResponse && + this.category == other.category && + this.created == other.created && + this.currency == other.currency && + this.descriptor == other.descriptor && + this.events == other.events && + this.pendingAmount == other.pendingAmount && + this.result == other.result && + this.settledAmount == other.settledAmount && + this.status == other.status && + this.token == other.token && + this.updated == other.updated && + this.methodAttributes == other.methodAttributes && + this.externalBankAccountToken == other.externalBankAccountToken && + this.direction == other.direction && + this.source == other.source && + this.method == other.method && + this.userDefinedId == other.userDefinedId && + this.balance == other.balance && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + category, + created, + currency, + descriptor, + events, + pendingAmount, + result, + settledAmount, + status, + token, + updated, + methodAttributes, + externalBankAccountToken, + direction, + source, + method, + userDefinedId, + balance, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "PaymentRetryResponse{category=$category, created=$created, currency=$currency, descriptor=$descriptor, events=$events, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, status=$status, token=$token, updated=$updated, methodAttributes=$methodAttributes, externalBankAccountToken=$externalBankAccountToken, direction=$direction, source=$source, method=$method, userDefinedId=$userDefinedId, balance=$balance, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var category: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var descriptor: JsonField = JsonMissing.of() + private var events: JsonField> = JsonMissing.of() + private var pendingAmount: JsonField = JsonMissing.of() + private var result: JsonField = JsonMissing.of() + private var settledAmount: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var token: JsonField = JsonMissing.of() + private var updated: JsonField = JsonMissing.of() + private var methodAttributes: JsonField = JsonMissing.of() + private var externalBankAccountToken: JsonField = JsonMissing.of() + private var direction: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var method: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() + private var balance: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(paymentRetryResponse: PaymentRetryResponse) = apply { + this.category = paymentRetryResponse.category + this.created = paymentRetryResponse.created + this.currency = paymentRetryResponse.currency + this.descriptor = paymentRetryResponse.descriptor + this.events = paymentRetryResponse.events + this.pendingAmount = paymentRetryResponse.pendingAmount + this.result = paymentRetryResponse.result + this.settledAmount = paymentRetryResponse.settledAmount + this.status = paymentRetryResponse.status + this.token = paymentRetryResponse.token + this.updated = paymentRetryResponse.updated + this.methodAttributes = paymentRetryResponse.methodAttributes + this.externalBankAccountToken = paymentRetryResponse.externalBankAccountToken + this.direction = paymentRetryResponse.direction + this.source = paymentRetryResponse.source + this.method = paymentRetryResponse.method + this.userDefinedId = paymentRetryResponse.userDefinedId + this.balance = paymentRetryResponse.balance + additionalProperties(paymentRetryResponse.additionalProperties) + } + + /** + * Status types: + * + * - `CARD` - Issuing card transaction. + * - `ACH` - Transaction over ACH. + * - `TRANSFER` - Internal transfer of funds between financial accounts in your program. + */ + fun category(category: FinancialTransaction.Category) = category(JsonField.of(category)) + + /** + * Status types: + * + * - `CARD` - Issuing card transaction. + * - `ACH` - Transaction over ACH. + * - `TRANSFER` - Internal transfer of funds between financial accounts in your program. + */ + @JsonProperty("category") + @ExcludeMissing + fun category(category: JsonField) = apply { + this.category = category + } + + /** Date and time when the financial transaction first occurred. UTC time zone. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** Date and time when the financial transaction first occurred. UTC time zone. */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** 3-digit alphabetic ISO 4217 code for the settling currency of the transaction. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** 3-digit alphabetic ISO 4217 code for the settling currency of the transaction. */ + @JsonProperty("currency") + @ExcludeMissing + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * A string that provides a description of the financial transaction; may be useful to + * display to users. + */ + fun descriptor(descriptor: String) = descriptor(JsonField.of(descriptor)) + + /** + * A string that provides a description of the financial transaction; may be useful to + * display to users. + */ + @JsonProperty("descriptor") + @ExcludeMissing + fun descriptor(descriptor: JsonField) = apply { this.descriptor = descriptor } + + /** A list of all financial events that have modified this financial transaction. */ + fun events(events: List) = events(JsonField.of(events)) + + /** A list of all financial events that have modified this financial transaction. */ + @JsonProperty("events") + @ExcludeMissing + fun events(events: JsonField>) = apply { + this.events = events + } + + /** + * Pending amount of the transaction in the currency's smallest unit (e.g., cents), + * including any acquirer fees. The value of this field will go to zero over time once the + * financial transaction is settled. + */ + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Pending amount of the transaction in the currency's smallest unit (e.g., cents), + * including any acquirer fees. The value of this field will go to zero over time once the + * financial transaction is settled. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + /** + * APPROVED transactions were successful while DECLINED transactions were declined by user, + * Lithic, or the network. + */ + fun result(result: FinancialTransaction.Result) = result(JsonField.of(result)) + + /** + * APPROVED transactions were successful while DECLINED transactions were declined by user, + * Lithic, or the network. + */ + @JsonProperty("result") + @ExcludeMissing + fun result(result: JsonField) = apply { this.result = result } + + /** + * Amount of the transaction that has been settled in the currency's smallest unit (e.g., + * cents), including any acquirer fees. This may change over time. + */ + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Amount of the transaction that has been settled in the currency's smallest unit (e.g., + * cents), including any acquirer fees. This may change over time. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** + * Status types: + * + * - `DECLINED` - The card transaction was declined. + * - `EXPIRED` - Lithic reversed the card authorization as it has passed its expiration + * time. + * - `PENDING` - Authorization is pending completion from the merchant or pending release + * from ACH hold period + * - `SETTLED` - The financial transaction is completed. + * - `VOIDED` - The merchant has voided the previously pending card authorization. + */ + fun status(status: FinancialTransaction.Status) = status(JsonField.of(status)) + + /** + * Status types: + * + * - `DECLINED` - The card transaction was declined. + * - `EXPIRED` - Lithic reversed the card authorization as it has passed its expiration + * time. + * - `PENDING` - Authorization is pending completion from the merchant or pending release + * from ACH hold period + * - `SETTLED` - The financial transaction is completed. + * - `VOIDED` - The merchant has voided the previously pending card authorization. + */ + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + /** Globally unique identifier. */ + fun token(token: String) = token(JsonField.of(token)) + + /** Globally unique identifier. */ + @JsonProperty("token") + @ExcludeMissing + fun token(token: JsonField) = apply { this.token = token } + + /** Date and time when the financial transaction was last updated. UTC time zone. */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** Date and time when the financial transaction was last updated. UTC time zone. */ + @JsonProperty("updated") + @ExcludeMissing + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun methodAttributes(methodAttributes: Payment.PaymentMethodAttributes) = + methodAttributes(JsonField.of(methodAttributes)) + + @JsonProperty("method_attributes") + @ExcludeMissing + fun methodAttributes(methodAttributes: JsonField) = apply { + this.methodAttributes = methodAttributes + } + + fun externalBankAccountToken(externalBankAccountToken: String) = + externalBankAccountToken(JsonField.of(externalBankAccountToken)) + + @JsonProperty("external_bank_account_token") + @ExcludeMissing + fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { + this.externalBankAccountToken = externalBankAccountToken + } + + fun direction(direction: Payment.Direction) = direction(JsonField.of(direction)) + + @JsonProperty("direction") + @ExcludeMissing + fun direction(direction: JsonField) = apply { + this.direction = direction + } + + fun source(source: Payment.Source) = source(JsonField.of(source)) + + @JsonProperty("source") + @ExcludeMissing + fun source(source: JsonField) = apply { this.source = source } + + fun method(method: Payment.Method) = method(JsonField.of(method)) + + @JsonProperty("method") + @ExcludeMissing + fun method(method: JsonField) = apply { this.method = method } + + fun userDefinedId(userDefinedId: String) = userDefinedId(JsonField.of(userDefinedId)) + + @JsonProperty("user_defined_id") + @ExcludeMissing + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } + + /** Balance of a Financial Account */ + fun balance(balance: Balance) = balance(JsonField.of(balance)) + + /** Balance of a Financial Account */ + @JsonProperty("balance") + @ExcludeMissing + fun balance(balance: JsonField) = apply { this.balance = balance } + + 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(): PaymentRetryResponse = + PaymentRetryResponse( + category, + created, + currency, + descriptor, + events.map { it.toUnmodifiable() }, + pendingAmount, + result, + settledAmount, + status, + token, + updated, + methodAttributes, + externalBankAccountToken, + direction, + source, + method, + userDefinedId, + balance, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ReportSettlementListDetailsPage.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ReportSettlementListDetailsPage.kt new file mode 100644 index 00000000..21aac814 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ReportSettlementListDetailsPage.kt @@ -0,0 +1,208 @@ +// 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.reports.SettlementService +import java.util.Objects + +class ReportSettlementListDetailsPage +private constructor( + private val settlementService: SettlementService, + private val params: ReportSettlementListDetailsParams, + 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 ReportSettlementListDetailsPage && + this.settlementService == other.settlementService && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + settlementService, + params, + response, + ) + } + + override fun toString() = + "ReportSettlementListDetailsPage{settlementService=$settlementService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return data().isEmpty() + } + + fun getNextPageParams(): ReportSettlementListDetailsParams? { + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + ReportSettlementListDetailsParams.builder() + .from(params) + .endingBefore(data().first().token()) + .build() + } else { + ReportSettlementListDetailsParams.builder() + .from(params) + .startingAfter(data().last().token()) + .build() + } + } + + fun getNextPage(): ReportSettlementListDetailsPage? { + return getNextPageParams()?.let { settlementService.listDetails(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + fun of( + settlementService: SettlementService, + params: ReportSettlementListDetailsParams, + response: Response + ) = + ReportSettlementListDetailsPage( + settlementService, + 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(): JsonField>? = data + + @JsonProperty("has_more") fun _hasMore(): JsonField? = 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() = + "ReportSettlementListDetailsPage.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + 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: ReportSettlementListDetailsPage, + ) : Sequence { + + 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() ?: break + index = 0 + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ReportSettlementListDetailsPageAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ReportSettlementListDetailsPageAsync.kt new file mode 100644 index 00000000..6ed3fa9f --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ReportSettlementListDetailsPageAsync.kt @@ -0,0 +1,210 @@ +// 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.reports.SettlementServiceAsync +import java.util.Objects +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.FlowCollector + +class ReportSettlementListDetailsPageAsync +private constructor( + private val settlementService: SettlementServiceAsync, + private val params: ReportSettlementListDetailsParams, + 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 ReportSettlementListDetailsPageAsync && + this.settlementService == other.settlementService && + this.params == other.params && + this.response == other.response + } + + override fun hashCode(): Int { + return Objects.hash( + settlementService, + params, + response, + ) + } + + override fun toString() = + "ReportSettlementListDetailsPageAsync{settlementService=$settlementService, params=$params, response=$response}" + + fun hasNextPage(): Boolean { + return data().isEmpty() + } + + fun getNextPageParams(): ReportSettlementListDetailsParams? { + if (!hasNextPage()) { + return null + } + + return if (params.endingBefore() != null) { + ReportSettlementListDetailsParams.builder() + .from(params) + .endingBefore(data().first().token()) + .build() + } else { + ReportSettlementListDetailsParams.builder() + .from(params) + .startingAfter(data().last().token()) + .build() + } + } + + suspend fun getNextPage(): ReportSettlementListDetailsPageAsync? { + return getNextPageParams()?.let { settlementService.listDetails(it) } + } + + fun autoPager(): AutoPager = AutoPager(this) + + companion object { + + fun of( + settlementService: SettlementServiceAsync, + params: ReportSettlementListDetailsParams, + response: Response + ) = + ReportSettlementListDetailsPageAsync( + settlementService, + 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(): JsonField>? = data + + @JsonProperty("has_more") fun _hasMore(): JsonField? = 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() = + "ReportSettlementListDetailsPageAsync.Response{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var hasMore: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + 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: ReportSettlementListDetailsPageAsync, + ) : Flow { + + override suspend fun collect(collector: FlowCollector) { + var page = firstPage + var index = 0 + while (true) { + while (index < page.data().size) { + collector.emit(page.data()[index++]) + } + page = page.getNextPage() ?: break + index = 0 + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ReportSettlementListDetailsParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ReportSettlementListDetailsParams.kt new file mode 100644 index 00000000..92b4e82e --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ReportSettlementListDetailsParams.kt @@ -0,0 +1,173 @@ +// 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.time.LocalDate +import java.util.Objects + +class ReportSettlementListDetailsParams +constructor( + private val reportDate: LocalDate, + private val endingBefore: String?, + private val pageSize: Long?, + private val startingAfter: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun reportDate(): LocalDate = reportDate + + fun endingBefore(): String? = endingBefore + + fun pageSize(): Long? = pageSize + + fun startingAfter(): String? = startingAfter + + internal fun getQueryParams(): Map> { + val params = mutableMapOf>() + 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() + } + + internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> reportDate.toString() + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReportSettlementListDetailsParams && + this.reportDate == other.reportDate && + 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( + reportDate, + endingBefore, + pageSize, + startingAfter, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "ReportSettlementListDetailsParams{reportDate=$reportDate, endingBefore=$endingBefore, pageSize=$pageSize, startingAfter=$startingAfter, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var reportDate: LocalDate? = 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() + + internal fun from(reportSettlementListDetailsParams: ReportSettlementListDetailsParams) = + apply { + this.reportDate = reportSettlementListDetailsParams.reportDate + this.endingBefore = reportSettlementListDetailsParams.endingBefore + this.pageSize = reportSettlementListDetailsParams.pageSize + this.startingAfter = reportSettlementListDetailsParams.startingAfter + additionalQueryParams(reportSettlementListDetailsParams.additionalQueryParams) + additionalHeaders(reportSettlementListDetailsParams.additionalHeaders) + } + + fun reportDate(reportDate: LocalDate) = apply { this.reportDate = reportDate } + + /** + * 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(): ReportSettlementListDetailsParams = + ReportSettlementListDetailsParams( + checkNotNull(reportDate) { "`reportDate` is required but was not set" }, + endingBefore, + pageSize, + startingAfter, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ReportSettlementSummaryParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ReportSettlementSummaryParams.kt new file mode 100644 index 00000000..4a957994 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/ReportSettlementSummaryParams.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.time.LocalDate +import java.util.Objects + +class ReportSettlementSummaryParams +constructor( + private val reportDate: LocalDate, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, +) { + + fun reportDate(): LocalDate = reportDate + + internal fun getQueryParams(): Map> = additionalQueryParams + + internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> reportDate.toString() + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReportSettlementSummaryParams && + this.reportDate == other.reportDate && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders + } + + override fun hashCode(): Int { + return Objects.hash( + reportDate, + additionalQueryParams, + additionalHeaders, + ) + } + + override fun toString() = + "ReportSettlementSummaryParams{reportDate=$reportDate, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}" + + fun toBuilder() = Builder().from(this) + + companion object { + + fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var reportDate: LocalDate? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + + internal fun from(reportSettlementSummaryParams: ReportSettlementSummaryParams) = apply { + this.reportDate = reportSettlementSummaryParams.reportDate + additionalQueryParams(reportSettlementSummaryParams.additionalQueryParams) + additionalHeaders(reportSettlementSummaryParams.additionalHeaders) + } + + fun reportDate(reportDate: LocalDate) = apply { this.reportDate = reportDate } + + 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(): ReportSettlementSummaryParams = + ReportSettlementSummaryParams( + checkNotNull(reportDate) { "`reportDate` is required but was not set" }, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementDetail.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementDetail.kt new file mode 100644 index 00000000..5cf93599 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementDetail.kt @@ -0,0 +1,727 @@ +// 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.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 + +@JsonDeserialize(builder = SettlementDetail.Builder::class) +@NoAutoDetect +class SettlementDetail +private constructor( + private val token: JsonField, + private val institution: JsonField, + private val accountToken: JsonField, + private val eventTokens: JsonField>, + private val transactionToken: JsonField, + private val cardToken: JsonField, + private val cardProgramToken: JsonField, + private val currency: JsonField, + private val network: JsonField, + private val transactionsGrossAmount: JsonField, + private val interchangeGrossAmount: JsonField, + private val disputesGrossAmount: JsonField, + private val otherFeesGrossAmount: JsonField, + private val otherFeesDetails: JsonField, + private val created: JsonField, + private val updated: JsonField, + private val settlementDate: JsonField, + private val reportDate: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Globally unique identifier denoting the Settlement Detail. */ + fun token(): String = token.getRequired("token") + + /** The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). */ + fun institution(): String = institution.getRequired("institution") + + /** The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). */ + fun accountToken(): String = accountToken.getRequired("account_token") + + /** Globally unique identifiers denoting the Events associated with this settlement. */ + fun eventTokens(): List = eventTokens.getRequired("event_tokens") + + /** Globally unique identifier denoting the associated Transaction object. */ + fun transactionToken(): String = transactionToken.getRequired("transaction_token") + + /** Globally unique identifier denoting the card that the associated Transaction occurred on. */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Globally unique identifier denoting the card program that the associated Transaction occurred + * on. + */ + fun cardProgramToken(): String = cardProgramToken.getRequired("card_program_token") + + /** Three-digit alphabetic ISO 4217 code. */ + fun currency(): String = currency.getRequired("currency") + + /** Card network where the transaction took place. */ + fun network(): Network = network.getRequired("network") + + /** + * The total amount of settlement impacting transactions (excluding interchange, fees, and + * disputes). + */ + fun transactionsGrossAmount(): Long = + transactionsGrossAmount.getRequired("transactions_gross_amount") + + /** The total amount of interchange. */ + fun interchangeGrossAmount(): Long = + interchangeGrossAmount.getRequired("interchange_gross_amount") + + /** The total gross amount of disputes settlements. */ + fun disputesGrossAmount(): Long = disputesGrossAmount.getRequired("disputes_gross_amount") + + /** Total amount of gross other fees outside of interchange. */ + fun otherFeesGrossAmount(): Long = otherFeesGrossAmount.getRequired("other_fees_gross_amount") + + /** The total gross amount of other fees by type. */ + fun otherFeesDetails(): OtherFeesDetails = otherFeesDetails.getRequired("other_fees_details") + + /** Date and time when the transaction first occurred. UTC time zone. */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** Date and time when the transaction first occurred. UTC time zone. */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** Date of when money movement is triggered for the transaction. */ + fun settlementDate(): String = settlementDate.getRequired("settlement_date") + + /** Date of when the report was first generated. */ + fun reportDate(): String = reportDate.getRequired("report_date") + + /** Globally unique identifier denoting the Settlement Detail. */ + @JsonProperty("token") @ExcludeMissing fun _token() = token + + /** The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). */ + @JsonProperty("institution") @ExcludeMissing fun _institution() = institution + + /** The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). */ + @JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken + + /** Globally unique identifiers denoting the Events associated with this settlement. */ + @JsonProperty("event_tokens") @ExcludeMissing fun _eventTokens() = eventTokens + + /** Globally unique identifier denoting the associated Transaction object. */ + @JsonProperty("transaction_token") @ExcludeMissing fun _transactionToken() = transactionToken + + /** Globally unique identifier denoting the card that the associated Transaction occurred on. */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken() = cardToken + + /** + * Globally unique identifier denoting the card program that the associated Transaction occurred + * on. + */ + @JsonProperty("card_program_token") @ExcludeMissing fun _cardProgramToken() = cardProgramToken + + /** Three-digit alphabetic ISO 4217 code. */ + @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + + /** Card network where the transaction took place. */ + @JsonProperty("network") @ExcludeMissing fun _network() = network + + /** + * The total amount of settlement impacting transactions (excluding interchange, fees, and + * disputes). + */ + @JsonProperty("transactions_gross_amount") + @ExcludeMissing + fun _transactionsGrossAmount() = transactionsGrossAmount + + /** The total amount of interchange. */ + @JsonProperty("interchange_gross_amount") + @ExcludeMissing + fun _interchangeGrossAmount() = interchangeGrossAmount + + /** The total gross amount of disputes settlements. */ + @JsonProperty("disputes_gross_amount") + @ExcludeMissing + fun _disputesGrossAmount() = disputesGrossAmount + + /** Total amount of gross other fees outside of interchange. */ + @JsonProperty("other_fees_gross_amount") + @ExcludeMissing + fun _otherFeesGrossAmount() = otherFeesGrossAmount + + /** The total gross amount of other fees by type. */ + @JsonProperty("other_fees_details") @ExcludeMissing fun _otherFeesDetails() = otherFeesDetails + + /** Date and time when the transaction first occurred. UTC time zone. */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** Date and time when the transaction first occurred. UTC time zone. */ + @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + + /** Date of when money movement is triggered for the transaction. */ + @JsonProperty("settlement_date") @ExcludeMissing fun _settlementDate() = settlementDate + + /** Date of when the report was first generated. */ + @JsonProperty("report_date") @ExcludeMissing fun _reportDate() = reportDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SettlementDetail = apply { + if (!validated) { + token() + institution() + accountToken() + eventTokens() + transactionToken() + cardToken() + cardProgramToken() + currency() + network() + transactionsGrossAmount() + interchangeGrossAmount() + disputesGrossAmount() + otherFeesGrossAmount() + otherFeesDetails().validate() + created() + updated() + settlementDate() + reportDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SettlementDetail && + this.token == other.token && + this.institution == other.institution && + this.accountToken == other.accountToken && + this.eventTokens == other.eventTokens && + this.transactionToken == other.transactionToken && + this.cardToken == other.cardToken && + this.cardProgramToken == other.cardProgramToken && + this.currency == other.currency && + this.network == other.network && + this.transactionsGrossAmount == other.transactionsGrossAmount && + this.interchangeGrossAmount == other.interchangeGrossAmount && + this.disputesGrossAmount == other.disputesGrossAmount && + this.otherFeesGrossAmount == other.otherFeesGrossAmount && + this.otherFeesDetails == other.otherFeesDetails && + this.created == other.created && + this.updated == other.updated && + this.settlementDate == other.settlementDate && + this.reportDate == other.reportDate && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + token, + institution, + accountToken, + eventTokens, + transactionToken, + cardToken, + cardProgramToken, + currency, + network, + transactionsGrossAmount, + interchangeGrossAmount, + disputesGrossAmount, + otherFeesGrossAmount, + otherFeesDetails, + created, + updated, + settlementDate, + reportDate, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "SettlementDetail{token=$token, institution=$institution, accountToken=$accountToken, eventTokens=$eventTokens, transactionToken=$transactionToken, cardToken=$cardToken, cardProgramToken=$cardProgramToken, currency=$currency, network=$network, transactionsGrossAmount=$transactionsGrossAmount, interchangeGrossAmount=$interchangeGrossAmount, disputesGrossAmount=$disputesGrossAmount, otherFeesGrossAmount=$otherFeesGrossAmount, otherFeesDetails=$otherFeesDetails, created=$created, updated=$updated, settlementDate=$settlementDate, reportDate=$reportDate, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var token: JsonField = JsonMissing.of() + private var institution: JsonField = JsonMissing.of() + private var accountToken: JsonField = JsonMissing.of() + private var eventTokens: JsonField> = JsonMissing.of() + private var transactionToken: JsonField = JsonMissing.of() + private var cardToken: JsonField = JsonMissing.of() + private var cardProgramToken: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var network: JsonField = JsonMissing.of() + private var transactionsGrossAmount: JsonField = JsonMissing.of() + private var interchangeGrossAmount: JsonField = JsonMissing.of() + private var disputesGrossAmount: JsonField = JsonMissing.of() + private var otherFeesGrossAmount: JsonField = JsonMissing.of() + private var otherFeesDetails: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var updated: JsonField = JsonMissing.of() + private var settlementDate: JsonField = JsonMissing.of() + private var reportDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(settlementDetail: SettlementDetail) = apply { + this.token = settlementDetail.token + this.institution = settlementDetail.institution + this.accountToken = settlementDetail.accountToken + this.eventTokens = settlementDetail.eventTokens + this.transactionToken = settlementDetail.transactionToken + this.cardToken = settlementDetail.cardToken + this.cardProgramToken = settlementDetail.cardProgramToken + this.currency = settlementDetail.currency + this.network = settlementDetail.network + this.transactionsGrossAmount = settlementDetail.transactionsGrossAmount + this.interchangeGrossAmount = settlementDetail.interchangeGrossAmount + this.disputesGrossAmount = settlementDetail.disputesGrossAmount + this.otherFeesGrossAmount = settlementDetail.otherFeesGrossAmount + this.otherFeesDetails = settlementDetail.otherFeesDetails + this.created = settlementDetail.created + this.updated = settlementDetail.updated + this.settlementDate = settlementDetail.settlementDate + this.reportDate = settlementDetail.reportDate + additionalProperties(settlementDetail.additionalProperties) + } + + /** Globally unique identifier denoting the Settlement Detail. */ + fun token(token: String) = token(JsonField.of(token)) + + /** Globally unique identifier denoting the Settlement Detail. */ + @JsonProperty("token") + @ExcludeMissing + fun token(token: JsonField) = apply { this.token = token } + + /** + * The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). + */ + fun institution(institution: String) = institution(JsonField.of(institution)) + + /** + * The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). + */ + @JsonProperty("institution") + @ExcludeMissing + fun institution(institution: JsonField) = apply { this.institution = institution } + + /** + * The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). + */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). + */ + @JsonProperty("account_token") + @ExcludeMissing + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Globally unique identifiers denoting the Events associated with this settlement. */ + fun eventTokens(eventTokens: List) = eventTokens(JsonField.of(eventTokens)) + + /** Globally unique identifiers denoting the Events associated with this settlement. */ + @JsonProperty("event_tokens") + @ExcludeMissing + fun eventTokens(eventTokens: JsonField>) = apply { + this.eventTokens = eventTokens + } + + /** Globally unique identifier denoting the associated Transaction object. */ + fun transactionToken(transactionToken: String) = + transactionToken(JsonField.of(transactionToken)) + + /** Globally unique identifier denoting the associated Transaction object. */ + @JsonProperty("transaction_token") + @ExcludeMissing + fun transactionToken(transactionToken: JsonField) = apply { + this.transactionToken = transactionToken + } + + /** + * Globally unique identifier denoting the card that the associated Transaction occurred on. + */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Globally unique identifier denoting the card that the associated Transaction occurred on. + */ + @JsonProperty("card_token") + @ExcludeMissing + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** + * Globally unique identifier denoting the card program that the associated Transaction + * occurred on. + */ + fun cardProgramToken(cardProgramToken: String) = + cardProgramToken(JsonField.of(cardProgramToken)) + + /** + * Globally unique identifier denoting the card program that the associated Transaction + * occurred on. + */ + @JsonProperty("card_program_token") + @ExcludeMissing + fun cardProgramToken(cardProgramToken: JsonField) = apply { + this.cardProgramToken = cardProgramToken + } + + /** Three-digit alphabetic ISO 4217 code. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** Three-digit alphabetic ISO 4217 code. */ + @JsonProperty("currency") + @ExcludeMissing + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Card network where the transaction took place. */ + fun network(network: Network) = network(JsonField.of(network)) + + /** Card network where the transaction took place. */ + @JsonProperty("network") + @ExcludeMissing + fun network(network: JsonField) = apply { this.network = network } + + /** + * The total amount of settlement impacting transactions (excluding interchange, fees, and + * disputes). + */ + fun transactionsGrossAmount(transactionsGrossAmount: Long) = + transactionsGrossAmount(JsonField.of(transactionsGrossAmount)) + + /** + * The total amount of settlement impacting transactions (excluding interchange, fees, and + * disputes). + */ + @JsonProperty("transactions_gross_amount") + @ExcludeMissing + fun transactionsGrossAmount(transactionsGrossAmount: JsonField) = apply { + this.transactionsGrossAmount = transactionsGrossAmount + } + + /** The total amount of interchange. */ + fun interchangeGrossAmount(interchangeGrossAmount: Long) = + interchangeGrossAmount(JsonField.of(interchangeGrossAmount)) + + /** The total amount of interchange. */ + @JsonProperty("interchange_gross_amount") + @ExcludeMissing + fun interchangeGrossAmount(interchangeGrossAmount: JsonField) = apply { + this.interchangeGrossAmount = interchangeGrossAmount + } + + /** The total gross amount of disputes settlements. */ + fun disputesGrossAmount(disputesGrossAmount: Long) = + disputesGrossAmount(JsonField.of(disputesGrossAmount)) + + /** The total gross amount of disputes settlements. */ + @JsonProperty("disputes_gross_amount") + @ExcludeMissing + fun disputesGrossAmount(disputesGrossAmount: JsonField) = apply { + this.disputesGrossAmount = disputesGrossAmount + } + + /** Total amount of gross other fees outside of interchange. */ + fun otherFeesGrossAmount(otherFeesGrossAmount: Long) = + otherFeesGrossAmount(JsonField.of(otherFeesGrossAmount)) + + /** Total amount of gross other fees outside of interchange. */ + @JsonProperty("other_fees_gross_amount") + @ExcludeMissing + fun otherFeesGrossAmount(otherFeesGrossAmount: JsonField) = apply { + this.otherFeesGrossAmount = otherFeesGrossAmount + } + + /** The total gross amount of other fees by type. */ + fun otherFeesDetails(otherFeesDetails: OtherFeesDetails) = + otherFeesDetails(JsonField.of(otherFeesDetails)) + + /** The total gross amount of other fees by type. */ + @JsonProperty("other_fees_details") + @ExcludeMissing + fun otherFeesDetails(otherFeesDetails: JsonField) = apply { + this.otherFeesDetails = otherFeesDetails + } + + /** Date and time when the transaction first occurred. UTC time zone. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** Date and time when the transaction first occurred. UTC time zone. */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** Date and time when the transaction first occurred. UTC time zone. */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** Date and time when the transaction first occurred. UTC time zone. */ + @JsonProperty("updated") + @ExcludeMissing + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** Date of when money movement is triggered for the transaction. */ + fun settlementDate(settlementDate: String) = settlementDate(JsonField.of(settlementDate)) + + /** Date of when money movement is triggered for the transaction. */ + @JsonProperty("settlement_date") + @ExcludeMissing + fun settlementDate(settlementDate: JsonField) = apply { + this.settlementDate = settlementDate + } + + /** Date of when the report was first generated. */ + fun reportDate(reportDate: String) = reportDate(JsonField.of(reportDate)) + + /** Date of when the report was first generated. */ + @JsonProperty("report_date") + @ExcludeMissing + fun reportDate(reportDate: JsonField) = apply { this.reportDate = reportDate } + + 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(): SettlementDetail = + SettlementDetail( + token, + institution, + accountToken, + eventTokens.map { it.toUnmodifiable() }, + transactionToken, + cardToken, + cardProgramToken, + currency, + network, + transactionsGrossAmount, + interchangeGrossAmount, + disputesGrossAmount, + otherFeesGrossAmount, + otherFeesDetails, + created, + updated, + settlementDate, + reportDate, + additionalProperties.toUnmodifiable(), + ) + } + + class Network + @JsonCreator + private constructor( + private val value: JsonField, + ) { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Network && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + val MASTERCARD = Network(JsonField.of("MASTERCARD")) + + val VISA = Network(JsonField.of("VISA")) + + val INTERLINK = Network(JsonField.of("INTERLINK")) + + val MAESTRO = Network(JsonField.of("MAESTRO")) + + val UNKNOWN = Network(JsonField.of("UNKNOWN")) + + fun of(value: String) = Network(JsonField.of(value)) + } + + enum class Known { + MASTERCARD, + VISA, + INTERLINK, + MAESTRO, + UNKNOWN, + } + + enum class Value { + MASTERCARD, + VISA, + INTERLINK, + MAESTRO, + UNKNOWN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MASTERCARD -> Value.MASTERCARD + VISA -> Value.VISA + INTERLINK -> Value.INTERLINK + MAESTRO -> Value.MAESTRO + UNKNOWN -> Value.UNKNOWN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MASTERCARD -> Known.MASTERCARD + VISA -> Known.VISA + INTERLINK -> Known.INTERLINK + MAESTRO -> Known.MAESTRO + UNKNOWN -> Known.UNKNOWN + else -> throw LithicInvalidDataException("Unknown Network: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + /** The total gross amount of other fees by type. */ + @JsonDeserialize(builder = OtherFeesDetails.Builder::class) + @NoAutoDetect + class OtherFeesDetails + private constructor( + private val title: JsonValue, + private val type: JsonValue, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + @JsonProperty("title") @ExcludeMissing fun _title() = title + + @JsonProperty("type") @ExcludeMissing fun _type() = type + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): OtherFeesDetails = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OtherFeesDetails && + this.title == other.title && + this.type == other.type && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + title, + type, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "OtherFeesDetails{title=$title, type=$type, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var title: JsonValue = JsonMissing.of() + private var type: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(otherFeesDetails: OtherFeesDetails) = apply { + this.title = otherFeesDetails.title + this.type = otherFeesDetails.type + additionalProperties(otherFeesDetails.additionalProperties) + } + + @JsonProperty("title") + @ExcludeMissing + fun title(title: JsonValue) = apply { this.title = title } + + @JsonProperty("type") + @ExcludeMissing + fun type(type: JsonValue) = apply { this.type = type } + + 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(): OtherFeesDetails = + OtherFeesDetails( + title, + type, + additionalProperties.toUnmodifiable(), + ) + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementReport.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementReport.kt new file mode 100644 index 00000000..5df9671a --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementReport.kt @@ -0,0 +1,350 @@ +// 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.time.OffsetDateTime +import java.util.Objects + +@JsonDeserialize(builder = SettlementReport.Builder::class) +@NoAutoDetect +class SettlementReport +private constructor( + private val currency: JsonField, + private val settledNetAmount: JsonField, + private val transactionsGrossAmount: JsonField, + private val interchangeGrossAmount: JsonField, + private val disputesGrossAmount: JsonField, + private val otherFeesGrossAmount: JsonField, + private val details: JsonField>, + private val created: JsonField, + private val updated: JsonField, + private val reportDate: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Three-digit alphabetic ISO 4217 code. */ + fun currency(): String = currency.getRequired("currency") + + /** + * The total net amount of cash moved. (net value of settled_gross_amount, interchange, fees). + */ + fun settledNetAmount(): Long = settledNetAmount.getRequired("settled_net_amount") + + /** + * The total amount of settlement impacting transactions (excluding interchange, fees, and + * disputes). + */ + fun transactionsGrossAmount(): Long = + transactionsGrossAmount.getRequired("transactions_gross_amount") + + /** The total amount of interchange. */ + fun interchangeGrossAmount(): Long = + interchangeGrossAmount.getRequired("interchange_gross_amount") + + /** The total gross amount of disputes settlements. */ + fun disputesGrossAmount(): Long = disputesGrossAmount.getRequired("disputes_gross_amount") + + /** Total amount of gross other fees outside of interchange. */ + fun otherFeesGrossAmount(): Long = otherFeesGrossAmount.getRequired("other_fees_gross_amount") + + fun details(): List = details.getRequired("details") + + /** Date and time when the transaction first occurred. UTC time zone. */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** Date and time when the transaction first occurred. UTC time zone. */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** Date of when the report was first generated. */ + fun reportDate(): String = reportDate.getRequired("report_date") + + /** Three-digit alphabetic ISO 4217 code. */ + @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + + /** + * The total net amount of cash moved. (net value of settled_gross_amount, interchange, fees). + */ + @JsonProperty("settled_net_amount") @ExcludeMissing fun _settledNetAmount() = settledNetAmount + + /** + * The total amount of settlement impacting transactions (excluding interchange, fees, and + * disputes). + */ + @JsonProperty("transactions_gross_amount") + @ExcludeMissing + fun _transactionsGrossAmount() = transactionsGrossAmount + + /** The total amount of interchange. */ + @JsonProperty("interchange_gross_amount") + @ExcludeMissing + fun _interchangeGrossAmount() = interchangeGrossAmount + + /** The total gross amount of disputes settlements. */ + @JsonProperty("disputes_gross_amount") + @ExcludeMissing + fun _disputesGrossAmount() = disputesGrossAmount + + /** Total amount of gross other fees outside of interchange. */ + @JsonProperty("other_fees_gross_amount") + @ExcludeMissing + fun _otherFeesGrossAmount() = otherFeesGrossAmount + + @JsonProperty("details") @ExcludeMissing fun _details() = details + + /** Date and time when the transaction first occurred. UTC time zone. */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** Date and time when the transaction first occurred. UTC time zone. */ + @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + + /** Date of when the report was first generated. */ + @JsonProperty("report_date") @ExcludeMissing fun _reportDate() = reportDate + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SettlementReport = apply { + if (!validated) { + currency() + settledNetAmount() + transactionsGrossAmount() + interchangeGrossAmount() + disputesGrossAmount() + otherFeesGrossAmount() + details().forEach { it.validate() } + created() + updated() + reportDate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SettlementReport && + this.currency == other.currency && + this.settledNetAmount == other.settledNetAmount && + this.transactionsGrossAmount == other.transactionsGrossAmount && + this.interchangeGrossAmount == other.interchangeGrossAmount && + this.disputesGrossAmount == other.disputesGrossAmount && + this.otherFeesGrossAmount == other.otherFeesGrossAmount && + this.details == other.details && + this.created == other.created && + this.updated == other.updated && + this.reportDate == other.reportDate && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + currency, + settledNetAmount, + transactionsGrossAmount, + interchangeGrossAmount, + disputesGrossAmount, + otherFeesGrossAmount, + details, + created, + updated, + reportDate, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "SettlementReport{currency=$currency, settledNetAmount=$settledNetAmount, transactionsGrossAmount=$transactionsGrossAmount, interchangeGrossAmount=$interchangeGrossAmount, disputesGrossAmount=$disputesGrossAmount, otherFeesGrossAmount=$otherFeesGrossAmount, details=$details, created=$created, updated=$updated, reportDate=$reportDate, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var currency: JsonField = JsonMissing.of() + private var settledNetAmount: JsonField = JsonMissing.of() + private var transactionsGrossAmount: JsonField = JsonMissing.of() + private var interchangeGrossAmount: JsonField = JsonMissing.of() + private var disputesGrossAmount: JsonField = JsonMissing.of() + private var otherFeesGrossAmount: JsonField = JsonMissing.of() + private var details: JsonField> = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var updated: JsonField = JsonMissing.of() + private var reportDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(settlementReport: SettlementReport) = apply { + this.currency = settlementReport.currency + this.settledNetAmount = settlementReport.settledNetAmount + this.transactionsGrossAmount = settlementReport.transactionsGrossAmount + this.interchangeGrossAmount = settlementReport.interchangeGrossAmount + this.disputesGrossAmount = settlementReport.disputesGrossAmount + this.otherFeesGrossAmount = settlementReport.otherFeesGrossAmount + this.details = settlementReport.details + this.created = settlementReport.created + this.updated = settlementReport.updated + this.reportDate = settlementReport.reportDate + additionalProperties(settlementReport.additionalProperties) + } + + /** Three-digit alphabetic ISO 4217 code. */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** Three-digit alphabetic ISO 4217 code. */ + @JsonProperty("currency") + @ExcludeMissing + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * The total net amount of cash moved. (net value of settled_gross_amount, interchange, + * fees). + */ + fun settledNetAmount(settledNetAmount: Long) = + settledNetAmount(JsonField.of(settledNetAmount)) + + /** + * The total net amount of cash moved. (net value of settled_gross_amount, interchange, + * fees). + */ + @JsonProperty("settled_net_amount") + @ExcludeMissing + fun settledNetAmount(settledNetAmount: JsonField) = apply { + this.settledNetAmount = settledNetAmount + } + + /** + * The total amount of settlement impacting transactions (excluding interchange, fees, and + * disputes). + */ + fun transactionsGrossAmount(transactionsGrossAmount: Long) = + transactionsGrossAmount(JsonField.of(transactionsGrossAmount)) + + /** + * The total amount of settlement impacting transactions (excluding interchange, fees, and + * disputes). + */ + @JsonProperty("transactions_gross_amount") + @ExcludeMissing + fun transactionsGrossAmount(transactionsGrossAmount: JsonField) = apply { + this.transactionsGrossAmount = transactionsGrossAmount + } + + /** The total amount of interchange. */ + fun interchangeGrossAmount(interchangeGrossAmount: Long) = + interchangeGrossAmount(JsonField.of(interchangeGrossAmount)) + + /** The total amount of interchange. */ + @JsonProperty("interchange_gross_amount") + @ExcludeMissing + fun interchangeGrossAmount(interchangeGrossAmount: JsonField) = apply { + this.interchangeGrossAmount = interchangeGrossAmount + } + + /** The total gross amount of disputes settlements. */ + fun disputesGrossAmount(disputesGrossAmount: Long) = + disputesGrossAmount(JsonField.of(disputesGrossAmount)) + + /** The total gross amount of disputes settlements. */ + @JsonProperty("disputes_gross_amount") + @ExcludeMissing + fun disputesGrossAmount(disputesGrossAmount: JsonField) = apply { + this.disputesGrossAmount = disputesGrossAmount + } + + /** Total amount of gross other fees outside of interchange. */ + fun otherFeesGrossAmount(otherFeesGrossAmount: Long) = + otherFeesGrossAmount(JsonField.of(otherFeesGrossAmount)) + + /** Total amount of gross other fees outside of interchange. */ + @JsonProperty("other_fees_gross_amount") + @ExcludeMissing + fun otherFeesGrossAmount(otherFeesGrossAmount: JsonField) = apply { + this.otherFeesGrossAmount = otherFeesGrossAmount + } + + fun details(details: List) = details(JsonField.of(details)) + + @JsonProperty("details") + @ExcludeMissing + fun details(details: JsonField>) = apply { + this.details = details + } + + /** Date and time when the transaction first occurred. UTC time zone. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** Date and time when the transaction first occurred. UTC time zone. */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** Date and time when the transaction first occurred. UTC time zone. */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** Date and time when the transaction first occurred. UTC time zone. */ + @JsonProperty("updated") + @ExcludeMissing + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** Date of when the report was first generated. */ + fun reportDate(reportDate: String) = reportDate(JsonField.of(reportDate)) + + /** Date of when the report was first generated. */ + @JsonProperty("report_date") + @ExcludeMissing + fun reportDate(reportDate: JsonField) = apply { this.reportDate = reportDate } + + 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(): SettlementReport = + SettlementReport( + currency, + settledNetAmount, + transactionsGrossAmount, + interchangeGrossAmount, + disputesGrossAmount, + otherFeesGrossAmount, + details.map { it.toUnmodifiable() }, + created, + updated, + reportDate, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementSummaryDetails.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementSummaryDetails.kt new file mode 100644 index 00000000..969cf23b --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementSummaryDetails.kt @@ -0,0 +1,369 @@ +// 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.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 + +@JsonDeserialize(builder = SettlementSummaryDetails.Builder::class) +@NoAutoDetect +class SettlementSummaryDetails +private constructor( + private val network: JsonField, + private val institution: JsonField, + private val settledNetAmount: JsonField, + private val transactionsGrossAmount: JsonField, + private val interchangeGrossAmount: JsonField, + private val disputesGrossAmount: JsonField, + private val otherFeesGrossAmount: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Card network where the transaction took place */ + fun network(): Network? = network.getNullable("network") + + /** The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). */ + fun institution(): String? = institution.getNullable("institution") + + /** + * The total net amount of cash moved. (net value of settled_gross_amount, interchange, fees). + */ + fun settledNetAmount(): Long? = settledNetAmount.getNullable("settled_net_amount") + + /** + * The total amount of settlement impacting transactions (excluding interchange, fees, and + * disputes). + */ + fun transactionsGrossAmount(): Long? = + transactionsGrossAmount.getNullable("transactions_gross_amount") + + /** The total amount of interchange. */ + fun interchangeGrossAmount(): Long? = + interchangeGrossAmount.getNullable("interchange_gross_amount") + + /** The total gross amount of disputes settlements. */ + fun disputesGrossAmount(): Long? = disputesGrossAmount.getNullable("disputes_gross_amount") + + /** Total amount of gross other fees outside of interchange. */ + fun otherFeesGrossAmount(): Long? = otherFeesGrossAmount.getNullable("other_fees_gross_amount") + + /** Card network where the transaction took place */ + @JsonProperty("network") @ExcludeMissing fun _network() = network + + /** The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). */ + @JsonProperty("institution") @ExcludeMissing fun _institution() = institution + + /** + * The total net amount of cash moved. (net value of settled_gross_amount, interchange, fees). + */ + @JsonProperty("settled_net_amount") @ExcludeMissing fun _settledNetAmount() = settledNetAmount + + /** + * The total amount of settlement impacting transactions (excluding interchange, fees, and + * disputes). + */ + @JsonProperty("transactions_gross_amount") + @ExcludeMissing + fun _transactionsGrossAmount() = transactionsGrossAmount + + /** The total amount of interchange. */ + @JsonProperty("interchange_gross_amount") + @ExcludeMissing + fun _interchangeGrossAmount() = interchangeGrossAmount + + /** The total gross amount of disputes settlements. */ + @JsonProperty("disputes_gross_amount") + @ExcludeMissing + fun _disputesGrossAmount() = disputesGrossAmount + + /** Total amount of gross other fees outside of interchange. */ + @JsonProperty("other_fees_gross_amount") + @ExcludeMissing + fun _otherFeesGrossAmount() = otherFeesGrossAmount + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SettlementSummaryDetails = apply { + if (!validated) { + network() + institution() + settledNetAmount() + transactionsGrossAmount() + interchangeGrossAmount() + disputesGrossAmount() + otherFeesGrossAmount() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SettlementSummaryDetails && + this.network == other.network && + this.institution == other.institution && + this.settledNetAmount == other.settledNetAmount && + this.transactionsGrossAmount == other.transactionsGrossAmount && + this.interchangeGrossAmount == other.interchangeGrossAmount && + this.disputesGrossAmount == other.disputesGrossAmount && + this.otherFeesGrossAmount == other.otherFeesGrossAmount && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + network, + institution, + settledNetAmount, + transactionsGrossAmount, + interchangeGrossAmount, + disputesGrossAmount, + otherFeesGrossAmount, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "SettlementSummaryDetails{network=$network, institution=$institution, settledNetAmount=$settledNetAmount, transactionsGrossAmount=$transactionsGrossAmount, interchangeGrossAmount=$interchangeGrossAmount, disputesGrossAmount=$disputesGrossAmount, otherFeesGrossAmount=$otherFeesGrossAmount, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var network: JsonField = JsonMissing.of() + private var institution: JsonField = JsonMissing.of() + private var settledNetAmount: JsonField = JsonMissing.of() + private var transactionsGrossAmount: JsonField = JsonMissing.of() + private var interchangeGrossAmount: JsonField = JsonMissing.of() + private var disputesGrossAmount: JsonField = JsonMissing.of() + private var otherFeesGrossAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(settlementSummaryDetails: SettlementSummaryDetails) = apply { + this.network = settlementSummaryDetails.network + this.institution = settlementSummaryDetails.institution + this.settledNetAmount = settlementSummaryDetails.settledNetAmount + this.transactionsGrossAmount = settlementSummaryDetails.transactionsGrossAmount + this.interchangeGrossAmount = settlementSummaryDetails.interchangeGrossAmount + this.disputesGrossAmount = settlementSummaryDetails.disputesGrossAmount + this.otherFeesGrossAmount = settlementSummaryDetails.otherFeesGrossAmount + additionalProperties(settlementSummaryDetails.additionalProperties) + } + + /** Card network where the transaction took place */ + fun network(network: Network) = network(JsonField.of(network)) + + /** Card network where the transaction took place */ + @JsonProperty("network") + @ExcludeMissing + fun network(network: JsonField) = apply { this.network = network } + + /** + * The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). + */ + fun institution(institution: String) = institution(JsonField.of(institution)) + + /** + * The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). + */ + @JsonProperty("institution") + @ExcludeMissing + fun institution(institution: JsonField) = apply { this.institution = institution } + + /** + * The total net amount of cash moved. (net value of settled_gross_amount, interchange, + * fees). + */ + fun settledNetAmount(settledNetAmount: Long) = + settledNetAmount(JsonField.of(settledNetAmount)) + + /** + * The total net amount of cash moved. (net value of settled_gross_amount, interchange, + * fees). + */ + @JsonProperty("settled_net_amount") + @ExcludeMissing + fun settledNetAmount(settledNetAmount: JsonField) = apply { + this.settledNetAmount = settledNetAmount + } + + /** + * The total amount of settlement impacting transactions (excluding interchange, fees, and + * disputes). + */ + fun transactionsGrossAmount(transactionsGrossAmount: Long) = + transactionsGrossAmount(JsonField.of(transactionsGrossAmount)) + + /** + * The total amount of settlement impacting transactions (excluding interchange, fees, and + * disputes). + */ + @JsonProperty("transactions_gross_amount") + @ExcludeMissing + fun transactionsGrossAmount(transactionsGrossAmount: JsonField) = apply { + this.transactionsGrossAmount = transactionsGrossAmount + } + + /** The total amount of interchange. */ + fun interchangeGrossAmount(interchangeGrossAmount: Long) = + interchangeGrossAmount(JsonField.of(interchangeGrossAmount)) + + /** The total amount of interchange. */ + @JsonProperty("interchange_gross_amount") + @ExcludeMissing + fun interchangeGrossAmount(interchangeGrossAmount: JsonField) = apply { + this.interchangeGrossAmount = interchangeGrossAmount + } + + /** The total gross amount of disputes settlements. */ + fun disputesGrossAmount(disputesGrossAmount: Long) = + disputesGrossAmount(JsonField.of(disputesGrossAmount)) + + /** The total gross amount of disputes settlements. */ + @JsonProperty("disputes_gross_amount") + @ExcludeMissing + fun disputesGrossAmount(disputesGrossAmount: JsonField) = apply { + this.disputesGrossAmount = disputesGrossAmount + } + + /** Total amount of gross other fees outside of interchange. */ + fun otherFeesGrossAmount(otherFeesGrossAmount: Long) = + otherFeesGrossAmount(JsonField.of(otherFeesGrossAmount)) + + /** Total amount of gross other fees outside of interchange. */ + @JsonProperty("other_fees_gross_amount") + @ExcludeMissing + fun otherFeesGrossAmount(otherFeesGrossAmount: JsonField) = apply { + this.otherFeesGrossAmount = otherFeesGrossAmount + } + + 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(): SettlementSummaryDetails = + SettlementSummaryDetails( + network, + institution, + settledNetAmount, + transactionsGrossAmount, + interchangeGrossAmount, + disputesGrossAmount, + otherFeesGrossAmount, + additionalProperties.toUnmodifiable(), + ) + } + + class Network + @JsonCreator + private constructor( + private val value: JsonField, + ) { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Network && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + val MASTERCARD = Network(JsonField.of("MASTERCARD")) + + val VISA = Network(JsonField.of("VISA")) + + val INTERLINK = Network(JsonField.of("INTERLINK")) + + val MAESTRO = Network(JsonField.of("MAESTRO")) + + val UNKNOWN = Network(JsonField.of("UNKNOWN")) + + fun of(value: String) = Network(JsonField.of(value)) + } + + enum class Known { + MASTERCARD, + VISA, + INTERLINK, + MAESTRO, + UNKNOWN, + } + + enum class Value { + MASTERCARD, + VISA, + INTERLINK, + MAESTRO, + UNKNOWN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + MASTERCARD -> Value.MASTERCARD + VISA -> Value.VISA + INTERLINK -> Value.INTERLINK + MAESTRO -> Value.MAESTRO + UNKNOWN -> Value.UNKNOWN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + MASTERCARD -> Known.MASTERCARD + VISA -> Known.VISA + INTERLINK -> Known.INTERLINK + MAESTRO -> Known.MAESTRO + UNKNOWN -> Known.UNKNOWN + else -> throw LithicInvalidDataException("Unknown Network: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementSummaryResponse.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementSummaryResponse.kt new file mode 100644 index 00000000..8d9ad842 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/SettlementSummaryResponse.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 + +@JsonDeserialize(builder = SettlementSummaryResponse.Builder::class) +@NoAutoDetect +class SettlementSummaryResponse +private constructor( + private val data: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun data(): List = data.getRequired("data") + + @JsonProperty("data") @ExcludeMissing fun _data() = data + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SettlementSummaryResponse = apply { + if (!validated) { + data().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SettlementSummaryResponse && + this.data == other.data && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(data, additionalProperties) + } + return hashCode + } + + override fun toString() = + "SettlementSummaryResponse{data=$data, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var data: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(settlementSummaryResponse: SettlementSummaryResponse) = apply { + this.data = settlementSummaryResponse.data + additionalProperties(settlementSummaryResponse.additionalProperties) + } + + fun data(data: List) = data(JsonField.of(data)) + + @JsonProperty("data") + @ExcludeMissing + fun data(data: JsonField>) = apply { this.data = data } + + 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(): SettlementSummaryResponse = + SettlementSummaryResponse( + data.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable() + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Statement.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Statement.kt new file mode 100644 index 00000000..9eadaad6 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Statement.kt @@ -0,0 +1,589 @@ +// 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.time.LocalDate +import java.time.OffsetDateTime +import java.util.Objects + +@JsonDeserialize(builder = Statement.Builder::class) +@NoAutoDetect +class Statement +private constructor( + private val achPeriodTotal: JsonField, + private val achYtdTotal: JsonField, + private val adjustmentsPeriodTotal: JsonField, + private val adjustmentsYtdTotal: JsonField, + private val amountDue: JsonField, + private val availableCredit: JsonField, + private val created: JsonField, + private val creditLimit: JsonField, + private val daysInBillingCycle: JsonField, + private val endingBalance: JsonField, + private val financialAccountToken: JsonField, + private val paymentDueDate: JsonField, + private val purchasesPeriodTotal: JsonField, + private val purchasesYtdTotal: JsonField, + private val startingBalance: JsonField, + private val statementEndDate: JsonField, + private val statementStartDate: JsonField, + private val token: JsonField, + private val updated: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** Total payments during this billing period. */ + fun achPeriodTotal(): Long = achPeriodTotal.getRequired("ach_period_total") + + /** Year-to-date settled payment total */ + fun achYtdTotal(): Long = achYtdTotal.getRequired("ach_ytd_total") + + /** Total adjustments during this billing period. */ + fun adjustmentsPeriodTotal(): Long = + adjustmentsPeriodTotal.getRequired("adjustments_period_total") + + /** Year-to-date settled adjustments total */ + fun adjustmentsYtdTotal(): Long = adjustmentsYtdTotal.getRequired("adjustments_ytd_total") + + /** + * Payment due at the end of the billing period. Negative amount indicates something is owed. If + * the amount owed is positive (e.g., there was a net credit), then payment should be returned + * to the cardholder via ACH. + */ + fun amountDue(): Long = amountDue.getRequired("amount_due") + + /** Amount of credit available to spend */ + fun availableCredit(): Long = availableCredit.getRequired("available_credit") + + /** Timestamp of when the statement was created */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * For prepay accounts, this is the minimum prepay balance that must be maintained. For charge + * card accounts, this is the maximum credit balance extended by a lender. + */ + fun creditLimit(): Long = creditLimit.getRequired("credit_limit") + + /** Number of days in the billing cycle */ + fun daysInBillingCycle(): Long = daysInBillingCycle.getRequired("days_in_billing_cycle") + + /** + * Balance at the end of the billing period. For charge cards, this should be the same at the + * statement amount due. + */ + fun endingBalance(): Long = endingBalance.getRequired("ending_balance") + + /** Globally unique identifier for a financial account */ + fun financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + /** Date when the payment is due */ + fun paymentDueDate(): LocalDate = paymentDueDate.getRequired("payment_due_date") + + /** Total settled card transactions during this billing period, determined by liability date. */ + fun purchasesPeriodTotal(): Long = purchasesPeriodTotal.getRequired("purchases_period_total") + + /** Year-to-date settled card transaction total */ + fun purchasesYtdTotal(): Long = purchasesYtdTotal.getRequired("purchases_ytd_total") + + /** Balance at the start of the billing period */ + fun startingBalance(): Long = startingBalance.getRequired("starting_balance") + + /** Date when the billing period ended */ + fun statementEndDate(): LocalDate = statementEndDate.getRequired("statement_end_date") + + /** Date when the billing period began */ + fun statementStartDate(): LocalDate = statementStartDate.getRequired("statement_start_date") + + /** Globally unique identifier for a statement */ + fun token(): String = token.getRequired("token") + + /** Timestamp of when the statement was updated */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** Total payments during this billing period. */ + @JsonProperty("ach_period_total") @ExcludeMissing fun _achPeriodTotal() = achPeriodTotal + + /** Year-to-date settled payment total */ + @JsonProperty("ach_ytd_total") @ExcludeMissing fun _achYtdTotal() = achYtdTotal + + /** Total adjustments during this billing period. */ + @JsonProperty("adjustments_period_total") + @ExcludeMissing + fun _adjustmentsPeriodTotal() = adjustmentsPeriodTotal + + /** Year-to-date settled adjustments total */ + @JsonProperty("adjustments_ytd_total") + @ExcludeMissing + fun _adjustmentsYtdTotal() = adjustmentsYtdTotal + + /** + * Payment due at the end of the billing period. Negative amount indicates something is owed. If + * the amount owed is positive (e.g., there was a net credit), then payment should be returned + * to the cardholder via ACH. + */ + @JsonProperty("amount_due") @ExcludeMissing fun _amountDue() = amountDue + + /** Amount of credit available to spend */ + @JsonProperty("available_credit") @ExcludeMissing fun _availableCredit() = availableCredit + + /** Timestamp of when the statement was created */ + @JsonProperty("created") @ExcludeMissing fun _created() = created + + /** + * For prepay accounts, this is the minimum prepay balance that must be maintained. For charge + * card accounts, this is the maximum credit balance extended by a lender. + */ + @JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit() = creditLimit + + /** Number of days in the billing cycle */ + @JsonProperty("days_in_billing_cycle") + @ExcludeMissing + fun _daysInBillingCycle() = daysInBillingCycle + + /** + * Balance at the end of the billing period. For charge cards, this should be the same at the + * statement amount due. + */ + @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + + /** Globally unique identifier for a financial account */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken() = financialAccountToken + + /** Date when the payment is due */ + @JsonProperty("payment_due_date") @ExcludeMissing fun _paymentDueDate() = paymentDueDate + + /** Total settled card transactions during this billing period, determined by liability date. */ + @JsonProperty("purchases_period_total") + @ExcludeMissing + fun _purchasesPeriodTotal() = purchasesPeriodTotal + + /** Year-to-date settled card transaction total */ + @JsonProperty("purchases_ytd_total") + @ExcludeMissing + fun _purchasesYtdTotal() = purchasesYtdTotal + + /** Balance at the start of the billing period */ + @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + + /** Date when the billing period ended */ + @JsonProperty("statement_end_date") @ExcludeMissing fun _statementEndDate() = statementEndDate + + /** Date when the billing period began */ + @JsonProperty("statement_start_date") + @ExcludeMissing + fun _statementStartDate() = statementStartDate + + /** Globally unique identifier for a statement */ + @JsonProperty("token") @ExcludeMissing fun _token() = token + + /** Timestamp of when the statement was updated */ + @JsonProperty("updated") @ExcludeMissing fun _updated() = updated + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Statement = apply { + if (!validated) { + achPeriodTotal() + achYtdTotal() + adjustmentsPeriodTotal() + adjustmentsYtdTotal() + amountDue() + availableCredit() + created() + creditLimit() + daysInBillingCycle() + endingBalance() + financialAccountToken() + paymentDueDate() + purchasesPeriodTotal() + purchasesYtdTotal() + startingBalance() + statementEndDate() + statementStartDate() + token() + updated() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Statement && + this.achPeriodTotal == other.achPeriodTotal && + this.achYtdTotal == other.achYtdTotal && + this.adjustmentsPeriodTotal == other.adjustmentsPeriodTotal && + this.adjustmentsYtdTotal == other.adjustmentsYtdTotal && + this.amountDue == other.amountDue && + this.availableCredit == other.availableCredit && + this.created == other.created && + this.creditLimit == other.creditLimit && + this.daysInBillingCycle == other.daysInBillingCycle && + this.endingBalance == other.endingBalance && + this.financialAccountToken == other.financialAccountToken && + this.paymentDueDate == other.paymentDueDate && + this.purchasesPeriodTotal == other.purchasesPeriodTotal && + this.purchasesYtdTotal == other.purchasesYtdTotal && + this.startingBalance == other.startingBalance && + this.statementEndDate == other.statementEndDate && + this.statementStartDate == other.statementStartDate && + this.token == other.token && + this.updated == other.updated && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + achPeriodTotal, + achYtdTotal, + adjustmentsPeriodTotal, + adjustmentsYtdTotal, + amountDue, + availableCredit, + created, + creditLimit, + daysInBillingCycle, + endingBalance, + financialAccountToken, + paymentDueDate, + purchasesPeriodTotal, + purchasesYtdTotal, + startingBalance, + statementEndDate, + statementStartDate, + token, + updated, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Statement{achPeriodTotal=$achPeriodTotal, achYtdTotal=$achYtdTotal, adjustmentsPeriodTotal=$adjustmentsPeriodTotal, adjustmentsYtdTotal=$adjustmentsYtdTotal, amountDue=$amountDue, availableCredit=$availableCredit, created=$created, creditLimit=$creditLimit, daysInBillingCycle=$daysInBillingCycle, endingBalance=$endingBalance, financialAccountToken=$financialAccountToken, paymentDueDate=$paymentDueDate, purchasesPeriodTotal=$purchasesPeriodTotal, purchasesYtdTotal=$purchasesYtdTotal, startingBalance=$startingBalance, statementEndDate=$statementEndDate, statementStartDate=$statementStartDate, token=$token, updated=$updated, additionalProperties=$additionalProperties}" + + companion object { + + fun builder() = Builder() + } + + class Builder { + + private var achPeriodTotal: JsonField = JsonMissing.of() + private var achYtdTotal: JsonField = JsonMissing.of() + private var adjustmentsPeriodTotal: JsonField = JsonMissing.of() + private var adjustmentsYtdTotal: JsonField = JsonMissing.of() + private var amountDue: JsonField = JsonMissing.of() + private var availableCredit: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var creditLimit: JsonField = JsonMissing.of() + private var daysInBillingCycle: JsonField = JsonMissing.of() + private var endingBalance: JsonField = JsonMissing.of() + private var financialAccountToken: JsonField = JsonMissing.of() + private var paymentDueDate: JsonField = JsonMissing.of() + private var purchasesPeriodTotal: JsonField = JsonMissing.of() + private var purchasesYtdTotal: JsonField = JsonMissing.of() + private var startingBalance: JsonField = JsonMissing.of() + private var statementEndDate: JsonField = JsonMissing.of() + private var statementStartDate: JsonField = JsonMissing.of() + private var token: JsonField = JsonMissing.of() + private var updated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + internal fun from(statement: Statement) = apply { + this.achPeriodTotal = statement.achPeriodTotal + this.achYtdTotal = statement.achYtdTotal + this.adjustmentsPeriodTotal = statement.adjustmentsPeriodTotal + this.adjustmentsYtdTotal = statement.adjustmentsYtdTotal + this.amountDue = statement.amountDue + this.availableCredit = statement.availableCredit + this.created = statement.created + this.creditLimit = statement.creditLimit + this.daysInBillingCycle = statement.daysInBillingCycle + this.endingBalance = statement.endingBalance + this.financialAccountToken = statement.financialAccountToken + this.paymentDueDate = statement.paymentDueDate + this.purchasesPeriodTotal = statement.purchasesPeriodTotal + this.purchasesYtdTotal = statement.purchasesYtdTotal + this.startingBalance = statement.startingBalance + this.statementEndDate = statement.statementEndDate + this.statementStartDate = statement.statementStartDate + this.token = statement.token + this.updated = statement.updated + additionalProperties(statement.additionalProperties) + } + + /** Total payments during this billing period. */ + fun achPeriodTotal(achPeriodTotal: Long) = achPeriodTotal(JsonField.of(achPeriodTotal)) + + /** Total payments during this billing period. */ + @JsonProperty("ach_period_total") + @ExcludeMissing + fun achPeriodTotal(achPeriodTotal: JsonField) = apply { + this.achPeriodTotal = achPeriodTotal + } + + /** Year-to-date settled payment total */ + fun achYtdTotal(achYtdTotal: Long) = achYtdTotal(JsonField.of(achYtdTotal)) + + /** Year-to-date settled payment total */ + @JsonProperty("ach_ytd_total") + @ExcludeMissing + fun achYtdTotal(achYtdTotal: JsonField) = apply { this.achYtdTotal = achYtdTotal } + + /** Total adjustments during this billing period. */ + fun adjustmentsPeriodTotal(adjustmentsPeriodTotal: Long) = + adjustmentsPeriodTotal(JsonField.of(adjustmentsPeriodTotal)) + + /** Total adjustments during this billing period. */ + @JsonProperty("adjustments_period_total") + @ExcludeMissing + fun adjustmentsPeriodTotal(adjustmentsPeriodTotal: JsonField) = apply { + this.adjustmentsPeriodTotal = adjustmentsPeriodTotal + } + + /** Year-to-date settled adjustments total */ + fun adjustmentsYtdTotal(adjustmentsYtdTotal: Long) = + adjustmentsYtdTotal(JsonField.of(adjustmentsYtdTotal)) + + /** Year-to-date settled adjustments total */ + @JsonProperty("adjustments_ytd_total") + @ExcludeMissing + fun adjustmentsYtdTotal(adjustmentsYtdTotal: JsonField) = apply { + this.adjustmentsYtdTotal = adjustmentsYtdTotal + } + + /** + * Payment due at the end of the billing period. Negative amount indicates something is + * owed. If the amount owed is positive (e.g., there was a net credit), then payment should + * be returned to the cardholder via ACH. + */ + fun amountDue(amountDue: Long) = amountDue(JsonField.of(amountDue)) + + /** + * Payment due at the end of the billing period. Negative amount indicates something is + * owed. If the amount owed is positive (e.g., there was a net credit), then payment should + * be returned to the cardholder via ACH. + */ + @JsonProperty("amount_due") + @ExcludeMissing + fun amountDue(amountDue: JsonField) = apply { this.amountDue = amountDue } + + /** Amount of credit available to spend */ + fun availableCredit(availableCredit: Long) = availableCredit(JsonField.of(availableCredit)) + + /** Amount of credit available to spend */ + @JsonProperty("available_credit") + @ExcludeMissing + fun availableCredit(availableCredit: JsonField) = apply { + this.availableCredit = availableCredit + } + + /** Timestamp of when the statement was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** Timestamp of when the statement was created */ + @JsonProperty("created") + @ExcludeMissing + fun created(created: JsonField) = apply { this.created = created } + + /** + * For prepay accounts, this is the minimum prepay balance that must be maintained. For + * charge card accounts, this is the maximum credit balance extended by a lender. + */ + fun creditLimit(creditLimit: Long) = creditLimit(JsonField.of(creditLimit)) + + /** + * For prepay accounts, this is the minimum prepay balance that must be maintained. For + * charge card accounts, this is the maximum credit balance extended by a lender. + */ + @JsonProperty("credit_limit") + @ExcludeMissing + fun creditLimit(creditLimit: JsonField) = apply { this.creditLimit = creditLimit } + + /** Number of days in the billing cycle */ + fun daysInBillingCycle(daysInBillingCycle: Long) = + daysInBillingCycle(JsonField.of(daysInBillingCycle)) + + /** Number of days in the billing cycle */ + @JsonProperty("days_in_billing_cycle") + @ExcludeMissing + fun daysInBillingCycle(daysInBillingCycle: JsonField) = apply { + this.daysInBillingCycle = daysInBillingCycle + } + + /** + * Balance at the end of the billing period. For charge cards, this should be the same at + * the statement amount due. + */ + fun endingBalance(endingBalance: Long) = endingBalance(JsonField.of(endingBalance)) + + /** + * Balance at the end of the billing period. For charge cards, this should be the same at + * the statement amount due. + */ + @JsonProperty("ending_balance") + @ExcludeMissing + fun endingBalance(endingBalance: JsonField) = apply { + this.endingBalance = endingBalance + } + + /** Globally unique identifier for a financial account */ + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** Globally unique identifier for a financial account */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + /** Date when the payment is due */ + fun paymentDueDate(paymentDueDate: LocalDate) = paymentDueDate(JsonField.of(paymentDueDate)) + + /** Date when the payment is due */ + @JsonProperty("payment_due_date") + @ExcludeMissing + fun paymentDueDate(paymentDueDate: JsonField) = apply { + this.paymentDueDate = paymentDueDate + } + + /** + * Total settled card transactions during this billing period, determined by liability date. + */ + fun purchasesPeriodTotal(purchasesPeriodTotal: Long) = + purchasesPeriodTotal(JsonField.of(purchasesPeriodTotal)) + + /** + * Total settled card transactions during this billing period, determined by liability date. + */ + @JsonProperty("purchases_period_total") + @ExcludeMissing + fun purchasesPeriodTotal(purchasesPeriodTotal: JsonField) = apply { + this.purchasesPeriodTotal = purchasesPeriodTotal + } + + /** Year-to-date settled card transaction total */ + fun purchasesYtdTotal(purchasesYtdTotal: Long) = + purchasesYtdTotal(JsonField.of(purchasesYtdTotal)) + + /** Year-to-date settled card transaction total */ + @JsonProperty("purchases_ytd_total") + @ExcludeMissing + fun purchasesYtdTotal(purchasesYtdTotal: JsonField) = apply { + this.purchasesYtdTotal = purchasesYtdTotal + } + + /** Balance at the start of the billing period */ + fun startingBalance(startingBalance: Long) = startingBalance(JsonField.of(startingBalance)) + + /** Balance at the start of the billing period */ + @JsonProperty("starting_balance") + @ExcludeMissing + fun startingBalance(startingBalance: JsonField) = apply { + this.startingBalance = startingBalance + } + + /** Date when the billing period ended */ + fun statementEndDate(statementEndDate: LocalDate) = + statementEndDate(JsonField.of(statementEndDate)) + + /** Date when the billing period ended */ + @JsonProperty("statement_end_date") + @ExcludeMissing + fun statementEndDate(statementEndDate: JsonField) = apply { + this.statementEndDate = statementEndDate + } + + /** Date when the billing period began */ + fun statementStartDate(statementStartDate: LocalDate) = + statementStartDate(JsonField.of(statementStartDate)) + + /** Date when the billing period began */ + @JsonProperty("statement_start_date") + @ExcludeMissing + fun statementStartDate(statementStartDate: JsonField) = apply { + this.statementStartDate = statementStartDate + } + + /** Globally unique identifier for a statement */ + fun token(token: String) = token(JsonField.of(token)) + + /** Globally unique identifier for a statement */ + @JsonProperty("token") + @ExcludeMissing + fun token(token: JsonField) = apply { this.token = token } + + /** Timestamp of when the statement was updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** Timestamp of when the statement was 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(): Statement = + Statement( + achPeriodTotal, + achYtdTotal, + adjustmentsPeriodTotal, + adjustmentsYtdTotal, + amountDue, + availableCredit, + created, + creditLimit, + daysInBillingCycle, + endingBalance, + financialAccountToken, + paymentDueDate, + purchasesPeriodTotal, + purchasesYtdTotal, + startingBalance, + statementEndDate, + statementStartDate, + token, + updated, + additionalProperties.toUnmodifiable(), + ) + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionListParams.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionListParams.kt index c64b9f3a..40049c80 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionListParams.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/TransactionListParams.kt @@ -136,7 +136,7 @@ constructor( fun accountToken(accountToken: String) = apply { this.accountToken = accountToken } /** - * Date string in RFC 3339 format. Only entries created after the specified date will be + * 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 } @@ -145,7 +145,7 @@ constructor( fun cardToken(cardToken: String) = apply { this.cardToken = cardToken } /** - * Date string in RFC 3339 format. Only entries created before the specified date will be + * 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 } diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Transfer.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Transfer.kt index 54880026..a046934c 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Transfer.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/models/Transfer.kt @@ -525,7 +525,7 @@ private constructor( private val created: JsonField, private val result: JsonField, private val token: JsonField, - private val type: JsonField, + private val type: JsonField, private val additionalProperties: Map, ) { @@ -586,7 +586,7 @@ private constructor( * - `TRANSFER_INSUFFICIENT_FUNDS` - Declined internl transfer of funds due to insufficient * balance of the sender. */ - fun type(): Type? = type.getNullable("type") + fun type(): FinancialEventType? = type.getNullable("type") /** * Amount of the financial event that has been settled in the currency's smallest unit @@ -703,7 +703,7 @@ private constructor( private var created: JsonField = JsonMissing.of() private var result: JsonField = JsonMissing.of() private var token: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() internal fun from(financialEvent: FinancialEvent) = apply { @@ -794,7 +794,7 @@ private constructor( * - `TRANSFER_INSUFFICIENT_FUNDS` - Declined internl transfer of funds due to * insufficient balance of the sender. */ - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: FinancialEventType) = type(JsonField.of(type)) /** * Event types: @@ -833,7 +833,7 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -917,7 +917,7 @@ private constructor( fun asString(): String = _value().asStringOrThrow() } - class Type + class FinancialEventType @JsonCreator private constructor( private val value: JsonField, @@ -930,7 +930,7 @@ private constructor( return true } - return other is Type && this.value == other.value + return other is FinancialEventType && this.value == other.value } override fun hashCode() = value.hashCode() @@ -939,52 +939,59 @@ private constructor( companion object { - val ACH_INSUFFICIENT_FUNDS = Type(JsonField.of("ACH_INSUFFICIENT_FUNDS")) + val ACH_INSUFFICIENT_FUNDS = + FinancialEventType(JsonField.of("ACH_INSUFFICIENT_FUNDS")) - val ACH_ORIGINATION_PENDING = Type(JsonField.of("ACH_ORIGINATION_PENDING")) + val ACH_ORIGINATION_PENDING = + FinancialEventType(JsonField.of("ACH_ORIGINATION_PENDING")) - val ACH_ORIGINATION_RELEASED = Type(JsonField.of("ACH_ORIGINATION_RELEASED")) + val ACH_ORIGINATION_RELEASED = + FinancialEventType(JsonField.of("ACH_ORIGINATION_RELEASED")) - val ACH_RECEIPT_PENDING = Type(JsonField.of("ACH_RECEIPT_PENDING")) + val ACH_RECEIPT_PENDING = FinancialEventType(JsonField.of("ACH_RECEIPT_PENDING")) - val ACH_RECEIPT_RELEASED = Type(JsonField.of("ACH_RECEIPT_RELEASED")) + val ACH_RECEIPT_RELEASED = FinancialEventType(JsonField.of("ACH_RECEIPT_RELEASED")) - val ACH_RETURN = Type(JsonField.of("ACH_RETURN")) + val ACH_RETURN = FinancialEventType(JsonField.of("ACH_RETURN")) - val AUTHORIZATION = Type(JsonField.of("AUTHORIZATION")) + val AUTHORIZATION = FinancialEventType(JsonField.of("AUTHORIZATION")) - val AUTHORIZATION_ADVICE = Type(JsonField.of("AUTHORIZATION_ADVICE")) + val AUTHORIZATION_ADVICE = FinancialEventType(JsonField.of("AUTHORIZATION_ADVICE")) - val AUTHORIZATION_EXPIRY = Type(JsonField.of("AUTHORIZATION_EXPIRY")) + val AUTHORIZATION_EXPIRY = FinancialEventType(JsonField.of("AUTHORIZATION_EXPIRY")) - val AUTHORIZATION_REVERSAL = Type(JsonField.of("AUTHORIZATION_REVERSAL")) + val AUTHORIZATION_REVERSAL = + FinancialEventType(JsonField.of("AUTHORIZATION_REVERSAL")) - val BALANCE_INQUIRY = Type(JsonField.of("BALANCE_INQUIRY")) + val BALANCE_INQUIRY = FinancialEventType(JsonField.of("BALANCE_INQUIRY")) - val CLEARING = Type(JsonField.of("CLEARING")) + val CLEARING = FinancialEventType(JsonField.of("CLEARING")) - val CORRECTION_DEBIT = Type(JsonField.of("CORRECTION_DEBIT")) + val CORRECTION_DEBIT = FinancialEventType(JsonField.of("CORRECTION_DEBIT")) - val CORRECTION_CREDIT = Type(JsonField.of("CORRECTION_CREDIT")) + val CORRECTION_CREDIT = FinancialEventType(JsonField.of("CORRECTION_CREDIT")) - val CREDIT_AUTHORIZATION = Type(JsonField.of("CREDIT_AUTHORIZATION")) + val CREDIT_AUTHORIZATION = FinancialEventType(JsonField.of("CREDIT_AUTHORIZATION")) - val CREDIT_AUTHORIZATION_ADVICE = Type(JsonField.of("CREDIT_AUTHORIZATION_ADVICE")) + val CREDIT_AUTHORIZATION_ADVICE = + FinancialEventType(JsonField.of("CREDIT_AUTHORIZATION_ADVICE")) - val FINANCIAL_AUTHORIZATION = Type(JsonField.of("FINANCIAL_AUTHORIZATION")) + val FINANCIAL_AUTHORIZATION = + FinancialEventType(JsonField.of("FINANCIAL_AUTHORIZATION")) val FINANCIAL_CREDIT_AUTHORIZATION = - Type(JsonField.of("FINANCIAL_CREDIT_AUTHORIZATION")) + FinancialEventType(JsonField.of("FINANCIAL_CREDIT_AUTHORIZATION")) - val RETURN = Type(JsonField.of("RETURN")) + val RETURN = FinancialEventType(JsonField.of("RETURN")) - val RETURN_REVERSAL = Type(JsonField.of("RETURN_REVERSAL")) + val RETURN_REVERSAL = FinancialEventType(JsonField.of("RETURN_REVERSAL")) - val TRANSFER = Type(JsonField.of("TRANSFER")) + val TRANSFER = FinancialEventType(JsonField.of("TRANSFER")) - val TRANSFER_INSUFFICIENT_FUNDS = Type(JsonField.of("TRANSFER_INSUFFICIENT_FUNDS")) + val TRANSFER_INSUFFICIENT_FUNDS = + FinancialEventType(JsonField.of("TRANSFER_INSUFFICIENT_FUNDS")) - fun of(value: String) = Type(JsonField.of(value)) + fun of(value: String) = FinancialEventType(JsonField.of(value)) } enum class Known { @@ -1089,7 +1096,7 @@ private constructor( RETURN_REVERSAL -> Known.RETURN_REVERSAL TRANSFER -> Known.TRANSFER TRANSFER_INSUFFICIENT_FUNDS -> Known.TRANSFER_INSUFFICIENT_FUNDS - else -> throw LithicInvalidDataException("Unknown Type: $value") + else -> throw LithicInvalidDataException("Unknown FinancialEventType: $value") } fun asString(): String = _value().asStringOrThrow() diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/AccountServiceAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/AccountServiceAsync.kt index 9dd77adf..453f727c 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/AccountServiceAsync.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/AccountServiceAsync.kt @@ -10,9 +10,12 @@ import com.lithic.api.models.AccountListPageAsync import com.lithic.api.models.AccountListParams import com.lithic.api.models.AccountRetrieveParams import com.lithic.api.models.AccountUpdateParams +import com.lithic.api.services.async.accounts.CreditConfigurationServiceAsync interface AccountServiceAsync { + fun creditConfigurations(): CreditConfigurationServiceAsync + /** Get account configuration such as spend limits. */ suspend fun retrieve( params: AccountRetrieveParams, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/AccountServiceAsyncImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/AccountServiceAsyncImpl.kt index 4ab10864..f76c067e 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/AccountServiceAsyncImpl.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/AccountServiceAsyncImpl.kt @@ -13,6 +13,8 @@ import com.lithic.api.models.AccountListPageAsync import com.lithic.api.models.AccountListParams import com.lithic.api.models.AccountRetrieveParams import com.lithic.api.models.AccountUpdateParams +import com.lithic.api.services.async.accounts.CreditConfigurationServiceAsync +import com.lithic.api.services.async.accounts.CreditConfigurationServiceAsyncImpl import com.lithic.api.services.errorHandler import com.lithic.api.services.json import com.lithic.api.services.jsonHandler @@ -25,6 +27,12 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val creditConfigurations: CreditConfigurationServiceAsync by lazy { + CreditConfigurationServiceAsyncImpl(clientOptions) + } + + override fun creditConfigurations(): CreditConfigurationServiceAsync = creditConfigurations + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/CardProductServiceAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/CardProductServiceAsync.kt new file mode 100644 index 00000000..f15993aa --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/CardProductServiceAsync.kt @@ -0,0 +1,18 @@ +// 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.CardProductCreditDetailParams +import com.lithic.api.models.CardProductCreditDetailResponse + +interface CardProductServiceAsync { + + /** Get the Credit Detail for the card product */ + suspend fun creditDetail( + params: CardProductCreditDetailParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CardProductCreditDetailResponse +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/CardProductServiceAsyncImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/CardProductServiceAsyncImpl.kt new file mode 100644 index 00000000..4d543c83 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/CardProductServiceAsyncImpl.kt @@ -0,0 +1,51 @@ +// 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.CardProductCreditDetailParams +import com.lithic.api.models.CardProductCreditDetailResponse +import com.lithic.api.services.errorHandler +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class CardProductServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : CardProductServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val creditDetailHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Get the Credit Detail for the card product */ + override suspend fun creditDetail( + params: CardProductCreditDetailParams, + requestOptions: RequestOptions + ): CardProductCreditDetailResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("card_product", "credit_detail") + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> + response + .use { creditDetailHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/CardServiceAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/CardServiceAsync.kt index 301cef27..12ed90e2 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/CardServiceAsync.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/CardServiceAsync.kt @@ -17,9 +17,18 @@ import com.lithic.api.models.CardProvisionResponse import com.lithic.api.models.CardReissueParams import com.lithic.api.models.CardRetrieveParams import com.lithic.api.models.CardUpdateParams +import com.lithic.api.services.async.cards.AggregateBalanceServiceAsync +import com.lithic.api.services.async.cards.BalanceServiceAsync +import com.lithic.api.services.async.cards.FinancialTransactionServiceAsync interface CardServiceAsync { + fun aggregateBalances(): AggregateBalanceServiceAsync + + fun balances(): BalanceServiceAsync + + fun financialTransactions(): FinancialTransactionServiceAsync + /** * Create a new virtual or physical card. Parameters `pin`, `shipping_address`, and `product_id` * only apply to physical cards. diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/CardServiceAsyncImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/CardServiceAsyncImpl.kt index f73aa6ce..6570d9ad 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/CardServiceAsyncImpl.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/CardServiceAsyncImpl.kt @@ -20,6 +20,12 @@ import com.lithic.api.models.CardProvisionResponse import com.lithic.api.models.CardReissueParams import com.lithic.api.models.CardRetrieveParams import com.lithic.api.models.CardUpdateParams +import com.lithic.api.services.async.cards.AggregateBalanceServiceAsync +import com.lithic.api.services.async.cards.AggregateBalanceServiceAsyncImpl +import com.lithic.api.services.async.cards.BalanceServiceAsync +import com.lithic.api.services.async.cards.BalanceServiceAsyncImpl +import com.lithic.api.services.async.cards.FinancialTransactionServiceAsync +import com.lithic.api.services.async.cards.FinancialTransactionServiceAsyncImpl import com.lithic.api.services.errorHandler import com.lithic.api.services.json import com.lithic.api.services.jsonHandler @@ -38,6 +44,22 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val aggregateBalances: AggregateBalanceServiceAsync by lazy { + AggregateBalanceServiceAsyncImpl(clientOptions) + } + + private val balances: BalanceServiceAsync by lazy { BalanceServiceAsyncImpl(clientOptions) } + + private val financialTransactions: FinancialTransactionServiceAsync by lazy { + FinancialTransactionServiceAsyncImpl(clientOptions) + } + + override fun aggregateBalances(): AggregateBalanceServiceAsync = aggregateBalances + + override fun balances(): BalanceServiceAsync = balances + + override fun financialTransactions(): FinancialTransactionServiceAsync = financialTransactions + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/FinancialAccountServiceAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/FinancialAccountServiceAsync.kt index 21494bc4..23546fcf 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/FinancialAccountServiceAsync.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/FinancialAccountServiceAsync.kt @@ -9,6 +9,7 @@ import com.lithic.api.models.FinancialAccountListPageAsync import com.lithic.api.models.FinancialAccountListParams import com.lithic.api.services.async.financialAccounts.BalanceServiceAsync import com.lithic.api.services.async.financialAccounts.FinancialTransactionServiceAsync +import com.lithic.api.services.async.financialAccounts.StatementServiceAsync interface FinancialAccountServiceAsync { @@ -16,6 +17,8 @@ interface FinancialAccountServiceAsync { fun financialTransactions(): FinancialTransactionServiceAsync + fun statements(): StatementServiceAsync + /** Retrieve information on your financial accounts including routing and account number. */ suspend fun list( params: FinancialAccountListParams, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/FinancialAccountServiceAsyncImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/FinancialAccountServiceAsyncImpl.kt index 3eddbdd2..94f55bf4 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/FinancialAccountServiceAsyncImpl.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/FinancialAccountServiceAsyncImpl.kt @@ -14,6 +14,8 @@ import com.lithic.api.services.async.financialAccounts.BalanceServiceAsync import com.lithic.api.services.async.financialAccounts.BalanceServiceAsyncImpl import com.lithic.api.services.async.financialAccounts.FinancialTransactionServiceAsync import com.lithic.api.services.async.financialAccounts.FinancialTransactionServiceAsyncImpl +import com.lithic.api.services.async.financialAccounts.StatementServiceAsync +import com.lithic.api.services.async.financialAccounts.StatementServiceAsyncImpl import com.lithic.api.services.errorHandler import com.lithic.api.services.jsonHandler import com.lithic.api.services.withErrorHandler @@ -31,10 +33,16 @@ constructor( FinancialTransactionServiceAsyncImpl(clientOptions) } + private val statements: StatementServiceAsync by lazy { + StatementServiceAsyncImpl(clientOptions) + } + override fun balances(): BalanceServiceAsync = balances override fun financialTransactions(): FinancialTransactionServiceAsync = financialTransactions + override fun statements(): StatementServiceAsync = statements + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/PaymentServiceAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/PaymentServiceAsync.kt index c667d743..1161e263 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/PaymentServiceAsync.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/PaymentServiceAsync.kt @@ -11,6 +11,8 @@ import com.lithic.api.models.PaymentCreateResponse import com.lithic.api.models.PaymentListPageAsync import com.lithic.api.models.PaymentListParams import com.lithic.api.models.PaymentRetrieveParams +import com.lithic.api.models.PaymentRetryParams +import com.lithic.api.models.PaymentRetryResponse import com.lithic.api.models.PaymentSimulateReleaseParams import com.lithic.api.models.PaymentSimulateReleaseResponse import com.lithic.api.models.PaymentSimulateReturnParams @@ -36,6 +38,12 @@ interface PaymentServiceAsync { requestOptions: RequestOptions = RequestOptions.none() ): PaymentListPageAsync + /** Retry an origination which has been returned. */ + suspend fun retry( + params: PaymentRetryParams, + requestOptions: RequestOptions = RequestOptions.none() + ): PaymentRetryResponse + /** Simulates a release of a Payment. */ suspend fun simulateRelease( params: PaymentSimulateReleaseParams, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/PaymentServiceAsyncImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/PaymentServiceAsyncImpl.kt index 3a8ddf5f..33f1fb9b 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/PaymentServiceAsyncImpl.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/PaymentServiceAsyncImpl.kt @@ -14,6 +14,8 @@ import com.lithic.api.models.PaymentCreateResponse import com.lithic.api.models.PaymentListPageAsync import com.lithic.api.models.PaymentListParams import com.lithic.api.models.PaymentRetrieveParams +import com.lithic.api.models.PaymentRetryParams +import com.lithic.api.models.PaymentRetryResponse import com.lithic.api.models.PaymentSimulateReleaseParams import com.lithic.api.models.PaymentSimulateReleaseResponse import com.lithic.api.models.PaymentSimulateReturnParams @@ -114,6 +116,34 @@ constructor( } } + private val retryHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Retry an origination which has been returned. */ + override suspend fun retry( + params: PaymentRetryParams, + requestOptions: RequestOptions + ): PaymentRetryResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("payments", params.getPathParam(0), "retry") + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> + response + .use { retryHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + private val simulateReleaseHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/ReportServiceAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/ReportServiceAsync.kt new file mode 100644 index 00000000..b28550f3 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/ReportServiceAsync.kt @@ -0,0 +1,12 @@ +// 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.services.async.reports.SettlementServiceAsync + +interface ReportServiceAsync { + + fun settlement(): SettlementServiceAsync +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/ReportServiceAsyncImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/ReportServiceAsyncImpl.kt new file mode 100644 index 00000000..7d27843f --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/ReportServiceAsyncImpl.kt @@ -0,0 +1,24 @@ +// 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.http.HttpResponse.Handler +import com.lithic.api.errors.LithicError +import com.lithic.api.services.async.reports.SettlementServiceAsync +import com.lithic.api.services.async.reports.SettlementServiceAsyncImpl +import com.lithic.api.services.errorHandler + +class ReportServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : ReportServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val settlement: SettlementServiceAsync by lazy { + SettlementServiceAsyncImpl(clientOptions) + } + + override fun settlement(): SettlementServiceAsync = settlement +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/accounts/CreditConfigurationServiceAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/accounts/CreditConfigurationServiceAsync.kt new file mode 100644 index 00000000..c0cbc7ef --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/accounts/CreditConfigurationServiceAsync.kt @@ -0,0 +1,25 @@ +// 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.accounts + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.AccountCreditConfigurationRetrieveParams +import com.lithic.api.models.AccountCreditConfigurationUpdateParams +import com.lithic.api.models.BusinessAccount + +interface CreditConfigurationServiceAsync { + + /** Get an Account's credit configuration */ + suspend fun retrieve( + params: AccountCreditConfigurationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): BusinessAccount + + /** Update a Business Accounts credit configuration */ + suspend fun update( + params: AccountCreditConfigurationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): BusinessAccount +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/accounts/CreditConfigurationServiceAsyncImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/accounts/CreditConfigurationServiceAsyncImpl.kt new file mode 100644 index 00000000..3ed4d14b --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/accounts/CreditConfigurationServiceAsyncImpl.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async.accounts + +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.AccountCreditConfigurationRetrieveParams +import com.lithic.api.models.AccountCreditConfigurationUpdateParams +import com.lithic.api.models.BusinessAccount +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 CreditConfigurationServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : CreditConfigurationServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Get an Account's credit configuration */ + override suspend fun retrieve( + params: AccountCreditConfigurationRetrieveParams, + requestOptions: RequestOptions + ): BusinessAccount { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("accounts", params.getPathParam(0), "credit_configuration") + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(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) + + /** Update a Business Accounts credit configuration */ + override suspend fun update( + params: AccountCreditConfigurationUpdateParams, + requestOptions: RequestOptions + ): BusinessAccount { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("accounts", params.getPathParam(0), "credit_configuration") + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/AggregateBalanceServiceAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/AggregateBalanceServiceAsync.kt new file mode 100644 index 00000000..e6f59eda --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/AggregateBalanceServiceAsync.kt @@ -0,0 +1,18 @@ +// 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.cards + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.CardAggregateBalanceListPageAsync +import com.lithic.api.models.CardAggregateBalanceListParams + +interface AggregateBalanceServiceAsync { + + /** Get the aggregated card balance across all end-user accounts. */ + suspend fun list( + params: CardAggregateBalanceListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CardAggregateBalanceListPageAsync +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/AggregateBalanceServiceAsyncImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/AggregateBalanceServiceAsyncImpl.kt new file mode 100644 index 00000000..7ff43787 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/AggregateBalanceServiceAsyncImpl.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async.cards + +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.CardAggregateBalanceListPageAsync +import com.lithic.api.models.CardAggregateBalanceListParams +import com.lithic.api.services.errorHandler +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class AggregateBalanceServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : AggregateBalanceServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Get the aggregated card balance across all end-user accounts. */ + override suspend fun list( + params: CardAggregateBalanceListParams, + requestOptions: RequestOptions + ): CardAggregateBalanceListPageAsync { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("cards", "aggregate_balances") + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { CardAggregateBalanceListPageAsync.of(this, params, it) } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/BalanceServiceAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/BalanceServiceAsync.kt new file mode 100644 index 00000000..cb821b16 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/BalanceServiceAsync.kt @@ -0,0 +1,18 @@ +// 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.cards + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.CardBalanceListPageAsync +import com.lithic.api.models.CardBalanceListParams + +interface BalanceServiceAsync { + + /** Get the balances for a given card. */ + suspend fun list( + params: CardBalanceListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CardBalanceListPageAsync +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/BalanceServiceAsyncImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/BalanceServiceAsyncImpl.kt new file mode 100644 index 00000000..13fa79b6 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/BalanceServiceAsyncImpl.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async.cards + +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.CardBalanceListPageAsync +import com.lithic.api.models.CardBalanceListParams +import com.lithic.api.services.errorHandler +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class BalanceServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : BalanceServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Get the balances for a given card. */ + override suspend fun list( + params: CardBalanceListParams, + requestOptions: RequestOptions + ): CardBalanceListPageAsync { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("cards", params.getPathParam(0), "balances") + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { CardBalanceListPageAsync.of(this, params, it) } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/FinancialTransactionServiceAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/FinancialTransactionServiceAsync.kt new file mode 100644 index 00000000..21edf05a --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/FinancialTransactionServiceAsync.kt @@ -0,0 +1,26 @@ +// 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.cards + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.CardFinancialTransactionListPageAsync +import com.lithic.api.models.CardFinancialTransactionListParams +import com.lithic.api.models.CardFinancialTransactionRetrieveParams +import com.lithic.api.models.FinancialTransaction + +interface FinancialTransactionServiceAsync { + + /** Get the card financial transaction for the provided token. */ + suspend fun retrieve( + params: CardFinancialTransactionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): FinancialTransaction + + /** List the financial transactions for a given card. */ + suspend fun list( + params: CardFinancialTransactionListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CardFinancialTransactionListPageAsync +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/FinancialTransactionServiceAsyncImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/FinancialTransactionServiceAsyncImpl.kt new file mode 100644 index 00000000..ff0a4ed8 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/cards/FinancialTransactionServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async.cards + +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.CardFinancialTransactionListPageAsync +import com.lithic.api.models.CardFinancialTransactionListParams +import com.lithic.api.models.CardFinancialTransactionRetrieveParams +import com.lithic.api.models.FinancialTransaction +import com.lithic.api.services.errorHandler +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class FinancialTransactionServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : FinancialTransactionServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Get the card financial transaction for the provided token. */ + override suspend fun retrieve( + params: CardFinancialTransactionRetrieveParams, + requestOptions: RequestOptions + ): FinancialTransaction { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "cards", + params.getPathParam(0), + "financial_transactions", + params.getPathParam(1) + ) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(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 the financial transactions for a given card. */ + override suspend fun list( + params: CardFinancialTransactionListParams, + requestOptions: RequestOptions + ): CardFinancialTransactionListPageAsync { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("cards", params.getPathParam(0), "financial_transactions") + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { CardFinancialTransactionListPageAsync.of(this, params, it) } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/StatementServiceAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/StatementServiceAsync.kt new file mode 100644 index 00000000..fd0fe1e7 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/StatementServiceAsync.kt @@ -0,0 +1,29 @@ +// 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.financialAccounts + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.FinancialAccountStatementListPageAsync +import com.lithic.api.models.FinancialAccountStatementListParams +import com.lithic.api.models.FinancialAccountStatementRetrieveParams +import com.lithic.api.models.Statement +import com.lithic.api.services.async.financialAccounts.statements.LineItemServiceAsync + +interface StatementServiceAsync { + + fun lineItems(): LineItemServiceAsync + + /** Get a specific statement for a given financial account. */ + suspend fun retrieve( + params: FinancialAccountStatementRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Statement + + /** List the statements for a given financial account. */ + suspend fun list( + params: FinancialAccountStatementListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): FinancialAccountStatementListPageAsync +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/StatementServiceAsyncImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/StatementServiceAsyncImpl.kt new file mode 100644 index 00000000..301ef8a4 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/StatementServiceAsyncImpl.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async.financialAccounts + +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.FinancialAccountStatementListPageAsync +import com.lithic.api.models.FinancialAccountStatementListParams +import com.lithic.api.models.FinancialAccountStatementRetrieveParams +import com.lithic.api.models.Statement +import com.lithic.api.services.async.financialAccounts.statements.LineItemServiceAsync +import com.lithic.api.services.async.financialAccounts.statements.LineItemServiceAsyncImpl +import com.lithic.api.services.errorHandler +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class StatementServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : StatementServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val lineItems: LineItemServiceAsync by lazy { LineItemServiceAsyncImpl(clientOptions) } + + override fun lineItems(): LineItemServiceAsync = lineItems + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Get a specific statement for a given financial account. */ + override suspend fun retrieve( + params: FinancialAccountStatementRetrieveParams, + requestOptions: RequestOptions + ): Statement { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "financial_accounts", + params.getPathParam(0), + "statements", + params.getPathParam(1) + ) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(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 the statements for a given financial account. */ + override suspend fun list( + params: FinancialAccountStatementListParams, + requestOptions: RequestOptions + ): FinancialAccountStatementListPageAsync { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("financial_accounts", params.getPathParam(0), "statements") + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { FinancialAccountStatementListPageAsync.of(this, params, it) } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/statements/LineItemServiceAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/statements/LineItemServiceAsync.kt new file mode 100644 index 00000000..2a824800 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/statements/LineItemServiceAsync.kt @@ -0,0 +1,18 @@ +// 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.financialAccounts.statements + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.FinancialAccountStatementLineItemListPageAsync +import com.lithic.api.models.FinancialAccountStatementLineItemListParams + +interface LineItemServiceAsync { + + /** List the line items for a given statement within a given financial account. */ + suspend fun list( + params: FinancialAccountStatementLineItemListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): FinancialAccountStatementLineItemListPageAsync +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/statements/LineItemServiceAsyncImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/statements/LineItemServiceAsyncImpl.kt new file mode 100644 index 00000000..e7385031 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/financialAccounts/statements/LineItemServiceAsyncImpl.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async.financialAccounts.statements + +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.FinancialAccountStatementLineItemListPageAsync +import com.lithic.api.models.FinancialAccountStatementLineItemListParams +import com.lithic.api.services.errorHandler +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class LineItemServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : LineItemServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler( + clientOptions.jsonMapper + ) + .withErrorHandler(errorHandler) + + /** List the line items for a given statement within a given financial account. */ + override suspend fun list( + params: FinancialAccountStatementLineItemListParams, + requestOptions: RequestOptions + ): FinancialAccountStatementLineItemListPageAsync { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "financial_accounts", + params.getPathParam(0), + "statements", + params.getPathParam(1), + "line_items" + ) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> + response + .use { listHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { FinancialAccountStatementLineItemListPageAsync.of(this, params, it) } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/reports/SettlementServiceAsync.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/reports/SettlementServiceAsync.kt new file mode 100644 index 00000000..1b3e4e3e --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/reports/SettlementServiceAsync.kt @@ -0,0 +1,26 @@ +// 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.reports + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.ReportSettlementListDetailsPageAsync +import com.lithic.api.models.ReportSettlementListDetailsParams +import com.lithic.api.models.ReportSettlementSummaryParams +import com.lithic.api.models.SettlementSummaryResponse + +interface SettlementServiceAsync { + + /** List details. */ + suspend fun listDetails( + params: ReportSettlementListDetailsParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ReportSettlementListDetailsPageAsync + + /** Get the settlement report for a specified report date. */ + suspend fun summary( + params: ReportSettlementSummaryParams, + requestOptions: RequestOptions = RequestOptions.none() + ): SettlementSummaryResponse +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/reports/SettlementServiceAsyncImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/reports/SettlementServiceAsyncImpl.kt new file mode 100644 index 00000000..b88ee16c --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/async/reports/SettlementServiceAsyncImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async.reports + +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.ReportSettlementListDetailsPageAsync +import com.lithic.api.models.ReportSettlementListDetailsParams +import com.lithic.api.models.ReportSettlementSummaryParams +import com.lithic.api.models.SettlementSummaryResponse +import com.lithic.api.services.errorHandler +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class SettlementServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : SettlementServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listDetailsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** List details. */ + override suspend fun listDetails( + params: ReportSettlementListDetailsParams, + requestOptions: RequestOptions + ): ReportSettlementListDetailsPageAsync { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("reports", "settlement", "details", params.getPathParam(0)) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> + response + .use { listDetailsHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ReportSettlementListDetailsPageAsync.of(this, params, it) } + } + } + + private val summaryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Get the settlement report for a specified report date. */ + override suspend fun summary( + params: ReportSettlementSummaryParams, + requestOptions: RequestOptions + ): SettlementSummaryResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("reports", "settlement", "summary", params.getPathParam(0)) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).let { response -> + response + .use { summaryHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/AccountService.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/AccountService.kt index 31dfb603..e0b6951f 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/AccountService.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/AccountService.kt @@ -10,9 +10,12 @@ import com.lithic.api.models.AccountListPage import com.lithic.api.models.AccountListParams import com.lithic.api.models.AccountRetrieveParams import com.lithic.api.models.AccountUpdateParams +import com.lithic.api.services.blocking.accounts.CreditConfigurationService interface AccountService { + fun creditConfigurations(): CreditConfigurationService + /** Get account configuration such as spend limits. */ fun retrieve( params: AccountRetrieveParams, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/AccountServiceImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/AccountServiceImpl.kt index 5604f3c7..2733ec78 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/AccountServiceImpl.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/AccountServiceImpl.kt @@ -13,6 +13,8 @@ import com.lithic.api.models.AccountListPage import com.lithic.api.models.AccountListParams import com.lithic.api.models.AccountRetrieveParams import com.lithic.api.models.AccountUpdateParams +import com.lithic.api.services.blocking.accounts.CreditConfigurationService +import com.lithic.api.services.blocking.accounts.CreditConfigurationServiceImpl import com.lithic.api.services.errorHandler import com.lithic.api.services.json import com.lithic.api.services.jsonHandler @@ -25,6 +27,12 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val creditConfigurations: CreditConfigurationService by lazy { + CreditConfigurationServiceImpl(clientOptions) + } + + override fun creditConfigurations(): CreditConfigurationService = creditConfigurations + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/CardProductService.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/CardProductService.kt new file mode 100644 index 00000000..ae86aaff --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/CardProductService.kt @@ -0,0 +1,18 @@ +// 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.CardProductCreditDetailParams +import com.lithic.api.models.CardProductCreditDetailResponse + +interface CardProductService { + + /** Get the Credit Detail for the card product */ + fun creditDetail( + params: CardProductCreditDetailParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CardProductCreditDetailResponse +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/CardProductServiceImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/CardProductServiceImpl.kt new file mode 100644 index 00000000..9e050819 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/CardProductServiceImpl.kt @@ -0,0 +1,51 @@ +// 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.CardProductCreditDetailParams +import com.lithic.api.models.CardProductCreditDetailResponse +import com.lithic.api.services.errorHandler +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class CardProductServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : CardProductService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val creditDetailHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Get the Credit Detail for the card product */ + override fun creditDetail( + params: CardProductCreditDetailParams, + requestOptions: RequestOptions + ): CardProductCreditDetailResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("card_product", "credit_detail") + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { creditDetailHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/CardService.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/CardService.kt index ea2fba46..d01bfe01 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/CardService.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/CardService.kt @@ -17,9 +17,18 @@ import com.lithic.api.models.CardProvisionResponse import com.lithic.api.models.CardReissueParams import com.lithic.api.models.CardRetrieveParams import com.lithic.api.models.CardUpdateParams +import com.lithic.api.services.blocking.cards.AggregateBalanceService +import com.lithic.api.services.blocking.cards.BalanceService +import com.lithic.api.services.blocking.cards.FinancialTransactionService interface CardService { + fun aggregateBalances(): AggregateBalanceService + + fun balances(): BalanceService + + fun financialTransactions(): FinancialTransactionService + /** * Create a new virtual or physical card. Parameters `pin`, `shipping_address`, and `product_id` * only apply to physical cards. diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/CardServiceImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/CardServiceImpl.kt index 643f08dc..c9aeb7ef 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/CardServiceImpl.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/CardServiceImpl.kt @@ -20,6 +20,12 @@ import com.lithic.api.models.CardProvisionResponse import com.lithic.api.models.CardReissueParams import com.lithic.api.models.CardRetrieveParams import com.lithic.api.models.CardUpdateParams +import com.lithic.api.services.blocking.cards.AggregateBalanceService +import com.lithic.api.services.blocking.cards.AggregateBalanceServiceImpl +import com.lithic.api.services.blocking.cards.BalanceService +import com.lithic.api.services.blocking.cards.BalanceServiceImpl +import com.lithic.api.services.blocking.cards.FinancialTransactionService +import com.lithic.api.services.blocking.cards.FinancialTransactionServiceImpl import com.lithic.api.services.errorHandler import com.lithic.api.services.json import com.lithic.api.services.jsonHandler @@ -38,6 +44,22 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val aggregateBalances: AggregateBalanceService by lazy { + AggregateBalanceServiceImpl(clientOptions) + } + + private val balances: BalanceService by lazy { BalanceServiceImpl(clientOptions) } + + private val financialTransactions: FinancialTransactionService by lazy { + FinancialTransactionServiceImpl(clientOptions) + } + + override fun aggregateBalances(): AggregateBalanceService = aggregateBalances + + override fun balances(): BalanceService = balances + + override fun financialTransactions(): FinancialTransactionService = financialTransactions + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/FinancialAccountService.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/FinancialAccountService.kt index d5210859..c1ea3aa7 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/FinancialAccountService.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/FinancialAccountService.kt @@ -9,6 +9,7 @@ import com.lithic.api.models.FinancialAccountListPage import com.lithic.api.models.FinancialAccountListParams import com.lithic.api.services.blocking.financialAccounts.BalanceService import com.lithic.api.services.blocking.financialAccounts.FinancialTransactionService +import com.lithic.api.services.blocking.financialAccounts.StatementService interface FinancialAccountService { @@ -16,6 +17,8 @@ interface FinancialAccountService { fun financialTransactions(): FinancialTransactionService + fun statements(): StatementService + /** Retrieve information on your financial accounts including routing and account number. */ fun list( params: FinancialAccountListParams, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceImpl.kt index 3f9657ea..0028b564 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceImpl.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceImpl.kt @@ -14,6 +14,8 @@ import com.lithic.api.services.blocking.financialAccounts.BalanceService import com.lithic.api.services.blocking.financialAccounts.BalanceServiceImpl import com.lithic.api.services.blocking.financialAccounts.FinancialTransactionService import com.lithic.api.services.blocking.financialAccounts.FinancialTransactionServiceImpl +import com.lithic.api.services.blocking.financialAccounts.StatementService +import com.lithic.api.services.blocking.financialAccounts.StatementServiceImpl import com.lithic.api.services.errorHandler import com.lithic.api.services.jsonHandler import com.lithic.api.services.withErrorHandler @@ -31,10 +33,14 @@ constructor( FinancialTransactionServiceImpl(clientOptions) } + private val statements: StatementService by lazy { StatementServiceImpl(clientOptions) } + override fun balances(): BalanceService = balances override fun financialTransactions(): FinancialTransactionService = financialTransactions + override fun statements(): StatementService = statements + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/PaymentService.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/PaymentService.kt index 316dc694..8721b158 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/PaymentService.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/PaymentService.kt @@ -11,6 +11,8 @@ import com.lithic.api.models.PaymentCreateResponse import com.lithic.api.models.PaymentListPage import com.lithic.api.models.PaymentListParams import com.lithic.api.models.PaymentRetrieveParams +import com.lithic.api.models.PaymentRetryParams +import com.lithic.api.models.PaymentRetryResponse import com.lithic.api.models.PaymentSimulateReleaseParams import com.lithic.api.models.PaymentSimulateReleaseResponse import com.lithic.api.models.PaymentSimulateReturnParams @@ -36,6 +38,12 @@ interface PaymentService { requestOptions: RequestOptions = RequestOptions.none() ): PaymentListPage + /** Retry an origination which has been returned. */ + fun retry( + params: PaymentRetryParams, + requestOptions: RequestOptions = RequestOptions.none() + ): PaymentRetryResponse + /** Simulates a release of a Payment. */ fun simulateRelease( params: PaymentSimulateReleaseParams, diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/PaymentServiceImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/PaymentServiceImpl.kt index c6f8a11d..3e499684 100644 --- a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/PaymentServiceImpl.kt +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/PaymentServiceImpl.kt @@ -14,6 +14,8 @@ import com.lithic.api.models.PaymentCreateResponse import com.lithic.api.models.PaymentListPage import com.lithic.api.models.PaymentListParams import com.lithic.api.models.PaymentRetrieveParams +import com.lithic.api.models.PaymentRetryParams +import com.lithic.api.models.PaymentRetryResponse import com.lithic.api.models.PaymentSimulateReleaseParams import com.lithic.api.models.PaymentSimulateReleaseResponse import com.lithic.api.models.PaymentSimulateReturnParams @@ -108,6 +110,34 @@ constructor( } } + private val retryHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Retry an origination which has been returned. */ + override fun retry( + params: PaymentRetryParams, + requestOptions: RequestOptions + ): PaymentRetryResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("payments", params.getPathParam(0), "retry") + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .apply { params.getBody()?.also { body(json(clientOptions.jsonMapper, it)) } } + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retryHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + private val simulateReleaseHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/ReportService.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/ReportService.kt new file mode 100644 index 00000000..dada4826 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/ReportService.kt @@ -0,0 +1,12 @@ +// 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.services.blocking.reports.SettlementService + +interface ReportService { + + fun settlement(): SettlementService +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/ReportServiceImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/ReportServiceImpl.kt new file mode 100644 index 00000000..a837f2fe --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/ReportServiceImpl.kt @@ -0,0 +1,22 @@ +// 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.http.HttpResponse.Handler +import com.lithic.api.errors.LithicError +import com.lithic.api.services.blocking.reports.SettlementService +import com.lithic.api.services.blocking.reports.SettlementServiceImpl +import com.lithic.api.services.errorHandler + +class ReportServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : ReportService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val settlement: SettlementService by lazy { SettlementServiceImpl(clientOptions) } + + override fun settlement(): SettlementService = settlement +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/accounts/CreditConfigurationService.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/accounts/CreditConfigurationService.kt new file mode 100644 index 00000000..ef8aabd2 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/accounts/CreditConfigurationService.kt @@ -0,0 +1,25 @@ +// 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.accounts + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.AccountCreditConfigurationRetrieveParams +import com.lithic.api.models.AccountCreditConfigurationUpdateParams +import com.lithic.api.models.BusinessAccount + +interface CreditConfigurationService { + + /** Get an Account's credit configuration */ + fun retrieve( + params: AccountCreditConfigurationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): BusinessAccount + + /** Update a Business Accounts credit configuration */ + fun update( + params: AccountCreditConfigurationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): BusinessAccount +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/accounts/CreditConfigurationServiceImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/accounts/CreditConfigurationServiceImpl.kt new file mode 100644 index 00000000..a02ce4ae --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/accounts/CreditConfigurationServiceImpl.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.accounts + +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.AccountCreditConfigurationRetrieveParams +import com.lithic.api.models.AccountCreditConfigurationUpdateParams +import com.lithic.api.models.BusinessAccount +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 CreditConfigurationServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : CreditConfigurationService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Get an Account's credit configuration */ + override fun retrieve( + params: AccountCreditConfigurationRetrieveParams, + requestOptions: RequestOptions + ): BusinessAccount { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("accounts", params.getPathParam(0), "credit_configuration") + .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) + + /** Update a Business Accounts credit configuration */ + override fun update( + params: AccountCreditConfigurationUpdateParams, + requestOptions: RequestOptions + ): BusinessAccount { + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .addPathSegments("accounts", params.getPathParam(0), "credit_configuration") + .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() + } + } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/AggregateBalanceService.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/AggregateBalanceService.kt new file mode 100644 index 00000000..569b35d2 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/AggregateBalanceService.kt @@ -0,0 +1,18 @@ +// 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.cards + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.CardAggregateBalanceListPage +import com.lithic.api.models.CardAggregateBalanceListParams + +interface AggregateBalanceService { + + /** Get the aggregated card balance across all end-user accounts. */ + fun list( + params: CardAggregateBalanceListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CardAggregateBalanceListPage +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/AggregateBalanceServiceImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/AggregateBalanceServiceImpl.kt new file mode 100644 index 00000000..40901ee0 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/AggregateBalanceServiceImpl.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.cards + +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.CardAggregateBalanceListPage +import com.lithic.api.models.CardAggregateBalanceListParams +import com.lithic.api.services.errorHandler +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class AggregateBalanceServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : AggregateBalanceService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Get the aggregated card balance across all end-user accounts. */ + override fun list( + params: CardAggregateBalanceListParams, + requestOptions: RequestOptions + ): CardAggregateBalanceListPage { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("cards", "aggregate_balances") + .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 { CardAggregateBalanceListPage.of(this, params, it) } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/BalanceService.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/BalanceService.kt new file mode 100644 index 00000000..585ad5a6 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/BalanceService.kt @@ -0,0 +1,18 @@ +// 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.cards + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.CardBalanceListPage +import com.lithic.api.models.CardBalanceListParams + +interface BalanceService { + + /** Get the balances for a given card. */ + fun list( + params: CardBalanceListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CardBalanceListPage +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/BalanceServiceImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/BalanceServiceImpl.kt new file mode 100644 index 00000000..576c7ac8 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/BalanceServiceImpl.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.cards + +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.CardBalanceListPage +import com.lithic.api.models.CardBalanceListParams +import com.lithic.api.services.errorHandler +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class BalanceServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : BalanceService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Get the balances for a given card. */ + override fun list( + params: CardBalanceListParams, + requestOptions: RequestOptions + ): CardBalanceListPage { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("cards", params.getPathParam(0), "balances") + .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 { CardBalanceListPage.of(this, params, it) } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/FinancialTransactionService.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/FinancialTransactionService.kt new file mode 100644 index 00000000..9152002b --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/FinancialTransactionService.kt @@ -0,0 +1,26 @@ +// 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.cards + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.CardFinancialTransactionListPage +import com.lithic.api.models.CardFinancialTransactionListParams +import com.lithic.api.models.CardFinancialTransactionRetrieveParams +import com.lithic.api.models.FinancialTransaction + +interface FinancialTransactionService { + + /** Get the card financial transaction for the provided token. */ + fun retrieve( + params: CardFinancialTransactionRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): FinancialTransaction + + /** List the financial transactions for a given card. */ + fun list( + params: CardFinancialTransactionListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CardFinancialTransactionListPage +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/FinancialTransactionServiceImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/FinancialTransactionServiceImpl.kt new file mode 100644 index 00000000..97b2ac8e --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/cards/FinancialTransactionServiceImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.cards + +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.CardFinancialTransactionListPage +import com.lithic.api.models.CardFinancialTransactionListParams +import com.lithic.api.models.CardFinancialTransactionRetrieveParams +import com.lithic.api.models.FinancialTransaction +import com.lithic.api.services.errorHandler +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class FinancialTransactionServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : FinancialTransactionService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Get the card financial transaction for the provided token. */ + override fun retrieve( + params: CardFinancialTransactionRetrieveParams, + requestOptions: RequestOptions + ): FinancialTransaction { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "cards", + params.getPathParam(0), + "financial_transactions", + params.getPathParam(1) + ) + .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 the financial transactions for a given card. */ + override fun list( + params: CardFinancialTransactionListParams, + requestOptions: RequestOptions + ): CardFinancialTransactionListPage { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("cards", params.getPathParam(0), "financial_transactions") + .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 { CardFinancialTransactionListPage.of(this, params, it) } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/StatementService.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/StatementService.kt new file mode 100644 index 00000000..14214cc2 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/StatementService.kt @@ -0,0 +1,29 @@ +// 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.financialAccounts + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.FinancialAccountStatementListPage +import com.lithic.api.models.FinancialAccountStatementListParams +import com.lithic.api.models.FinancialAccountStatementRetrieveParams +import com.lithic.api.models.Statement +import com.lithic.api.services.blocking.financialAccounts.statements.LineItemService + +interface StatementService { + + fun lineItems(): LineItemService + + /** Get a specific statement for a given financial account. */ + fun retrieve( + params: FinancialAccountStatementRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): Statement + + /** List the statements for a given financial account. */ + fun list( + params: FinancialAccountStatementListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): FinancialAccountStatementListPage +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/StatementServiceImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/StatementServiceImpl.kt new file mode 100644 index 00000000..dfb05fd9 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/StatementServiceImpl.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.financialAccounts + +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.FinancialAccountStatementListPage +import com.lithic.api.models.FinancialAccountStatementListParams +import com.lithic.api.models.FinancialAccountStatementRetrieveParams +import com.lithic.api.models.Statement +import com.lithic.api.services.blocking.financialAccounts.statements.LineItemService +import com.lithic.api.services.blocking.financialAccounts.statements.LineItemServiceImpl +import com.lithic.api.services.errorHandler +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class StatementServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : StatementService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val lineItems: LineItemService by lazy { LineItemServiceImpl(clientOptions) } + + override fun lineItems(): LineItemService = lineItems + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** Get a specific statement for a given financial account. */ + override fun retrieve( + params: FinancialAccountStatementRetrieveParams, + requestOptions: RequestOptions + ): Statement { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "financial_accounts", + params.getPathParam(0), + "statements", + params.getPathParam(1) + ) + .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 the statements for a given financial account. */ + override fun list( + params: FinancialAccountStatementListParams, + requestOptions: RequestOptions + ): FinancialAccountStatementListPage { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("financial_accounts", params.getPathParam(0), "statements") + .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 { FinancialAccountStatementListPage.of(this, params, it) } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/statements/LineItemService.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/statements/LineItemService.kt new file mode 100644 index 00000000..8651499b --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/statements/LineItemService.kt @@ -0,0 +1,18 @@ +// 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.financialAccounts.statements + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.FinancialAccountStatementLineItemListPage +import com.lithic.api.models.FinancialAccountStatementLineItemListParams + +interface LineItemService { + + /** List the line items for a given statement within a given financial account. */ + fun list( + params: FinancialAccountStatementLineItemListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): FinancialAccountStatementLineItemListPage +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/statements/LineItemServiceImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/statements/LineItemServiceImpl.kt new file mode 100644 index 00000000..05e52ac0 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/financialAccounts/statements/LineItemServiceImpl.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.financialAccounts.statements + +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.FinancialAccountStatementLineItemListPage +import com.lithic.api.models.FinancialAccountStatementLineItemListParams +import com.lithic.api.services.errorHandler +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class LineItemServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : LineItemService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** List the line items for a given statement within a given financial account. */ + override fun list( + params: FinancialAccountStatementLineItemListParams, + requestOptions: RequestOptions + ): FinancialAccountStatementLineItemListPage { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "financial_accounts", + params.getPathParam(0), + "statements", + params.getPathParam(1), + "line_items" + ) + .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 { FinancialAccountStatementLineItemListPage.of(this, params, it) } + } + } +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/reports/SettlementService.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/reports/SettlementService.kt new file mode 100644 index 00000000..acb1a9dd --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/reports/SettlementService.kt @@ -0,0 +1,26 @@ +// 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.reports + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.ReportSettlementListDetailsPage +import com.lithic.api.models.ReportSettlementListDetailsParams +import com.lithic.api.models.ReportSettlementSummaryParams +import com.lithic.api.models.SettlementSummaryResponse + +interface SettlementService { + + /** List details. */ + fun listDetails( + params: ReportSettlementListDetailsParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ReportSettlementListDetailsPage + + /** Get the settlement report for a specified report date. */ + fun summary( + params: ReportSettlementSummaryParams, + requestOptions: RequestOptions = RequestOptions.none() + ): SettlementSummaryResponse +} diff --git a/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/reports/SettlementServiceImpl.kt b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/reports/SettlementServiceImpl.kt new file mode 100644 index 00000000..73cf9c75 --- /dev/null +++ b/lithic-kotlin-core/src/main/kotlin/com/lithic/api/services/blocking/reports/SettlementServiceImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.reports + +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.ReportSettlementListDetailsPage +import com.lithic.api.models.ReportSettlementListDetailsParams +import com.lithic.api.models.ReportSettlementSummaryParams +import com.lithic.api.models.SettlementSummaryResponse +import com.lithic.api.services.errorHandler +import com.lithic.api.services.jsonHandler +import com.lithic.api.services.withErrorHandler + +class SettlementServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : SettlementService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listDetailsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** List details. */ + override fun listDetails( + params: ReportSettlementListDetailsParams, + requestOptions: RequestOptions + ): ReportSettlementListDetailsPage { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("reports", "settlement", "details", params.getPathParam(0)) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { listDetailsHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + .let { ReportSettlementListDetailsPage.of(this, params, it) } + } + } + + private val summaryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Get the settlement report for a specified report date. */ + override fun summary( + params: ReportSettlementSummaryParams, + requestOptions: RequestOptions + ): SettlementSummaryResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("reports", "settlement", "summary", params.getPathParam(0)) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { summaryHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/AccountCreditConfigurationRetrieveParamsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/AccountCreditConfigurationRetrieveParamsTest.kt new file mode 100644 index 00000000..6436cfcc --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/AccountCreditConfigurationRetrieveParamsTest.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 AccountCreditConfigurationRetrieveParamsTest { + + @Test + fun createAccountCreditConfigurationRetrieveParams() { + AccountCreditConfigurationRetrieveParams.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + AccountCreditConfigurationRetrieveParams.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "accountToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/AccountCreditConfigurationUpdateParamsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/AccountCreditConfigurationUpdateParamsTest.kt new file mode 100644 index 00000000..04a2d1ea --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/AccountCreditConfigurationUpdateParamsTest.kt @@ -0,0 +1,63 @@ +// 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 AccountCreditConfigurationUpdateParamsTest { + + @Test + fun createAccountCreditConfigurationUpdateParams() { + AccountCreditConfigurationUpdateParams.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingPeriod(123L) + .creditLimit(123L) + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentPeriod(123L) + .build() + } + + @Test + fun getBody() { + val params = + AccountCreditConfigurationUpdateParams.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingPeriod(123L) + .creditLimit(123L) + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentPeriod(123L) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.billingPeriod()).isEqualTo(123L) + assertThat(body.creditLimit()).isEqualTo(123L) + assertThat(body.externalBankAccountToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.paymentPeriod()).isEqualTo(123L) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + AccountCreditConfigurationUpdateParams.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + } + + @Test + fun getPathParam() { + val params = + AccountCreditConfigurationUpdateParams.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "accountToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/AggregateBalanceListResponseTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/AggregateBalanceListResponseTest.kt new file mode 100644 index 00000000..f2245245 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/AggregateBalanceListResponseTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AggregateBalanceListResponseTest { + + @Test + fun createAggregateBalanceListResponse() { + val aggregateBalanceListResponse = + AggregateBalanceListResponse.builder() + .availableAmount(123L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("string") + .lastCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(123L) + .totalAmount(123L) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(aggregateBalanceListResponse).isNotNull + assertThat(aggregateBalanceListResponse.availableAmount()).isEqualTo(123L) + assertThat(aggregateBalanceListResponse.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(aggregateBalanceListResponse.currency()).isEqualTo("string") + assertThat(aggregateBalanceListResponse.lastCardToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(aggregateBalanceListResponse.lastTransactionEventToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(aggregateBalanceListResponse.lastTransactionToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(aggregateBalanceListResponse.pendingAmount()).isEqualTo(123L) + assertThat(aggregateBalanceListResponse.totalAmount()).isEqualTo(123L) + assertThat(aggregateBalanceListResponse.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/AuthenticationRetrieveResponseTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/AuthenticationRetrieveResponseTest.kt index 00f045e5..8e30568f 100644 --- a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/AuthenticationRetrieveResponseTest.kt +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/AuthenticationRetrieveResponseTest.kt @@ -14,14 +14,6 @@ class AuthenticationRetrieveResponseTest { AuthenticationRetrieveResponse.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .accountType(AuthenticationRetrieveResponse.AccountType.NOT_APPLICABLE) - .additionalData( - AuthenticationRetrieveResponse.AdditionalData.builder() - .networkDecision( - AuthenticationRetrieveResponse.AdditionalData.NetworkDecision.LOW_RISK - ) - .networkRiskScore(42.23) - .build() - ) .authenticationResult(AuthenticationRetrieveResponse.AuthenticationResult.SUCCESS) .cardExpiryCheck(AuthenticationRetrieveResponse.CardExpiryCheck.MATCH) .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -97,15 +89,15 @@ class AuthenticationRetrieveResponseTest { ) .build() ) - .transaction( - AuthenticationRetrieveResponse.Transaction.builder() - .amount(42.23) - .currency("xxx") - .currencyExponent(42.23) - .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .type( - AuthenticationRetrieveResponse.Transaction.Type.GOODS_SERVICE_PURCHASE + .messageCategory( + AuthenticationRetrieveResponse.MessageCategory.PAYMENT_AUTHENTICATION + ) + .additionalData( + AuthenticationRetrieveResponse.AdditionalData.builder() + .networkDecision( + AuthenticationRetrieveResponse.AdditionalData.NetworkDecision.LOW_RISK ) + .networkRiskScore(42.23) .build() ) .app( @@ -130,21 +122,23 @@ class AuthenticationRetrieveResponseTest { .threeRiRequestType( AuthenticationRetrieveResponse.ThreeRiRequestType.RECURRING_TRANSACTION ) + .transaction( + AuthenticationRetrieveResponse.Transaction.builder() + .amount(42.23) + .currency("xxx") + .currencyExponent(42.23) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type( + AuthenticationRetrieveResponse.Transaction.Type.GOODS_SERVICE_PURCHASE + ) + .build() + ) .build() assertThat(authenticationRetrieveResponse).isNotNull assertThat(authenticationRetrieveResponse.token()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(authenticationRetrieveResponse.accountType()) .isEqualTo(AuthenticationRetrieveResponse.AccountType.NOT_APPLICABLE) - assertThat(authenticationRetrieveResponse.additionalData()) - .isEqualTo( - AuthenticationRetrieveResponse.AdditionalData.builder() - .networkDecision( - AuthenticationRetrieveResponse.AdditionalData.NetworkDecision.LOW_RISK - ) - .networkRiskScore(42.23) - .build() - ) assertThat(authenticationRetrieveResponse.authenticationResult()) .isEqualTo(AuthenticationRetrieveResponse.AuthenticationResult.SUCCESS) assertThat(authenticationRetrieveResponse.cardExpiryCheck()) @@ -224,14 +218,15 @@ class AuthenticationRetrieveResponseTest { ) .build() ) - assertThat(authenticationRetrieveResponse.transaction()) + assertThat(authenticationRetrieveResponse.messageCategory()) + .isEqualTo(AuthenticationRetrieveResponse.MessageCategory.PAYMENT_AUTHENTICATION) + assertThat(authenticationRetrieveResponse.additionalData()) .isEqualTo( - AuthenticationRetrieveResponse.Transaction.builder() - .amount(42.23) - .currency("xxx") - .currencyExponent(42.23) - .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .type(AuthenticationRetrieveResponse.Transaction.Type.GOODS_SERVICE_PURCHASE) + AuthenticationRetrieveResponse.AdditionalData.builder() + .networkDecision( + AuthenticationRetrieveResponse.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(42.23) .build() ) assertThat(authenticationRetrieveResponse.app()) @@ -256,5 +251,15 @@ class AuthenticationRetrieveResponseTest { ) assertThat(authenticationRetrieveResponse.threeRiRequestType()) .isEqualTo(AuthenticationRetrieveResponse.ThreeRiRequestType.RECURRING_TRANSACTION) + assertThat(authenticationRetrieveResponse.transaction()) + .isEqualTo( + AuthenticationRetrieveResponse.Transaction.builder() + .amount(42.23) + .currency("xxx") + .currencyExponent(42.23) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(AuthenticationRetrieveResponse.Transaction.Type.GOODS_SERVICE_PURCHASE) + .build() + ) } } diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/BusinessAccountTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/BusinessAccountTest.kt new file mode 100644 index 00000000..10f27a6e --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/BusinessAccountTest.kt @@ -0,0 +1,36 @@ +// 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 BusinessAccountTest { + + @Test + fun createBusinessAccount() { + val businessAccount = + BusinessAccount.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .collectionsConfiguration( + BusinessAccount.AccountHolderCollectionsConfiguration.builder() + .billingPeriod(123L) + .paymentPeriod(123L) + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .creditLimit(123L) + .build() + assertThat(businessAccount).isNotNull + assertThat(businessAccount.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(businessAccount.collectionsConfiguration()) + .isEqualTo( + BusinessAccount.AccountHolderCollectionsConfiguration.builder() + .billingPeriod(123L) + .paymentPeriod(123L) + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + assertThat(businessAccount.creditLimit()).isEqualTo(123L) + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardAggregateBalanceListParamsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardAggregateBalanceListParamsTest.kt new file mode 100644 index 00000000..5dbae23c --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardAggregateBalanceListParamsTest.kt @@ -0,0 +1,38 @@ +// 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 CardAggregateBalanceListParamsTest { + + @Test + fun createCardAggregateBalanceListParams() { + CardAggregateBalanceListParams.builder() + .accountToken("string") + .businessAccountToken("string") + .build() + } + + @Test + fun getQueryParams() { + val params = + CardAggregateBalanceListParams.builder() + .accountToken("string") + .businessAccountToken("string") + .build() + val expected = mutableMapOf>() + expected.put("account_token", listOf("string")) + expected.put("business_account_token", listOf("string")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = CardAggregateBalanceListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardBalanceListParamsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardBalanceListParamsTest.kt new file mode 100644 index 00000000..9d198ce8 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardBalanceListParamsTest.kt @@ -0,0 +1,57 @@ +// 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 CardBalanceListParamsTest { + + @Test + fun createCardBalanceListParams() { + CardBalanceListParams.builder() + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .balanceDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getQueryParams() { + val params = + CardBalanceListParams.builder() + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .balanceDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + expected.put("balance_date", listOf("2019-12-27T18:11:19.117Z")) + expected.put("last_transaction_event_token", listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = + CardBalanceListParams.builder() + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getPathParam() { + val params = + CardBalanceListParams.builder() + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "cardToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardFinancialTransactionListParamsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardFinancialTransactionListParamsTest.kt new file mode 100644 index 00000000..ecb0658e --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardFinancialTransactionListParamsTest.kt @@ -0,0 +1,81 @@ +// 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 CardFinancialTransactionListParamsTest { + + @Test + fun createCardFinancialTransactionListParams() { + CardFinancialTransactionListParams.builder() + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .begin(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(CardFinancialTransactionListParams.Category.CARD) + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endingBefore("string") + .result(CardFinancialTransactionListParams.Result.APPROVED) + .startingAfter("string") + .status(CardFinancialTransactionListParams.Status.DECLINED) + .build() + } + + @Test + fun getQueryParams() { + val params = + CardFinancialTransactionListParams.builder() + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .begin(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(CardFinancialTransactionListParams.Category.CARD) + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endingBefore("string") + .result(CardFinancialTransactionListParams.Result.APPROVED) + .startingAfter("string") + .status(CardFinancialTransactionListParams.Status.DECLINED) + .build() + val expected = mutableMapOf>() + expected.put("begin", listOf("2019-12-27T18:11:19.117Z")) + expected.put( + "category", + listOf(CardFinancialTransactionListParams.Category.CARD.toString()) + ) + expected.put("end", listOf("2019-12-27T18:11:19.117Z")) + expected.put("ending_before", listOf("string")) + expected.put( + "result", + listOf(CardFinancialTransactionListParams.Result.APPROVED.toString()) + ) + expected.put("starting_after", listOf("string")) + expected.put( + "status", + listOf(CardFinancialTransactionListParams.Status.DECLINED.toString()) + ) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = + CardFinancialTransactionListParams.builder() + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getPathParam() { + val params = + CardFinancialTransactionListParams.builder() + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "cardToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardFinancialTransactionRetrieveParamsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardFinancialTransactionRetrieveParamsTest.kt new file mode 100644 index 00000000..20612f0d --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardFinancialTransactionRetrieveParamsTest.kt @@ -0,0 +1,34 @@ +// 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 CardFinancialTransactionRetrieveParamsTest { + + @Test + fun createCardFinancialTransactionRetrieveParams() { + CardFinancialTransactionRetrieveParams.builder() + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .financialTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + CardFinancialTransactionRetrieveParams.builder() + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .financialTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "cardToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // path param "financialTransactionToken" + assertThat(params.getPathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(2)).isEqualTo("") + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardProductCreditDetailParamsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardProductCreditDetailParamsTest.kt new file mode 100644 index 00000000..acba2193 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardProductCreditDetailParamsTest.kt @@ -0,0 +1,14 @@ +// 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 CardProductCreditDetailParamsTest { + + @Test + fun createCardProductCreditDetailParams() { + CardProductCreditDetailParams.builder().build() + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardProductCreditDetailResponseTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardProductCreditDetailResponseTest.kt new file mode 100644 index 00000000..cb16d2eb --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/CardProductCreditDetailResponseTest.kt @@ -0,0 +1,18 @@ +// 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 CardProductCreditDetailResponseTest { + + @Test + fun createCardProductCreditDetailResponse() { + val cardProductCreditDetailResponse = + CardProductCreditDetailResponse.builder().creditExtended(123L).creditLimit(123L).build() + assertThat(cardProductCreditDetailResponse).isNotNull + assertThat(cardProductCreditDetailResponse.creditExtended()).isEqualTo(123L) + assertThat(cardProductCreditDetailResponse.creditLimit()).isEqualTo(123L) + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/FinancialAccountStatementLineItemListParamsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/FinancialAccountStatementLineItemListParamsTest.kt new file mode 100644 index 00000000..1ebea3bb --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/FinancialAccountStatementLineItemListParamsTest.kt @@ -0,0 +1,65 @@ +// 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 FinancialAccountStatementLineItemListParamsTest { + + @Test + fun createFinancialAccountStatementLineItemListParams() { + FinancialAccountStatementLineItemListParams.builder() + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .statementToken("string") + .endingBefore("string") + .pageSize(123L) + .startingAfter("string") + .build() + } + + @Test + fun getQueryParams() { + val params = + FinancialAccountStatementLineItemListParams.builder() + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .statementToken("string") + .endingBefore("string") + .pageSize(123L) + .startingAfter("string") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("string")) + expected.put("page_size", listOf("123")) + expected.put("starting_after", listOf("string")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = + FinancialAccountStatementLineItemListParams.builder() + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .statementToken("string") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getPathParam() { + val params = + FinancialAccountStatementLineItemListParams.builder() + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .statementToken("string") + .build() + assertThat(params).isNotNull + // path param "financialAccountToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // path param "statementToken" + assertThat(params.getPathParam(1)).isEqualTo("string") + // out-of-bound path param + assertThat(params.getPathParam(2)).isEqualTo("") + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/FinancialAccountStatementListParamsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/FinancialAccountStatementListParamsTest.kt new file mode 100644 index 00000000..0e3151b2 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/FinancialAccountStatementListParamsTest.kt @@ -0,0 +1,66 @@ +// 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 FinancialAccountStatementListParamsTest { + + @Test + fun createFinancialAccountStatementListParams() { + FinancialAccountStatementListParams.builder() + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .begin(LocalDate.parse("2019-12-27")) + .end(LocalDate.parse("2019-12-27")) + .endingBefore("string") + .pageSize(123L) + .startingAfter("string") + .build() + } + + @Test + fun getQueryParams() { + val params = + FinancialAccountStatementListParams.builder() + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .begin(LocalDate.parse("2019-12-27")) + .end(LocalDate.parse("2019-12-27")) + .endingBefore("string") + .pageSize(123L) + .startingAfter("string") + .build() + val expected = mutableMapOf>() + expected.put("begin", listOf("2019-12-27")) + expected.put("end", listOf("2019-12-27")) + expected.put("ending_before", listOf("string")) + expected.put("page_size", listOf("123")) + expected.put("starting_after", listOf("string")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = + FinancialAccountStatementListParams.builder() + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getPathParam() { + val params = + FinancialAccountStatementListParams.builder() + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "financialAccountToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/FinancialAccountStatementRetrieveParamsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/FinancialAccountStatementRetrieveParamsTest.kt new file mode 100644 index 00000000..011d0d26 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/FinancialAccountStatementRetrieveParamsTest.kt @@ -0,0 +1,34 @@ +// 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 FinancialAccountStatementRetrieveParamsTest { + + @Test + fun createFinancialAccountStatementRetrieveParams() { + FinancialAccountStatementRetrieveParams.builder() + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .statementToken("string") + .build() + } + + @Test + fun getPathParam() { + val params = + FinancialAccountStatementRetrieveParams.builder() + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .statementToken("string") + .build() + assertThat(params).isNotNull + // path param "financialAccountToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // path param "statementToken" + assertThat(params.getPathParam(1)).isEqualTo("string") + // out-of-bound path param + assertThat(params.getPathParam(2)).isEqualTo("") + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/FinancialTransactionTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/FinancialTransactionTest.kt index a037cadf..39b279cb 100644 --- a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/FinancialTransactionTest.kt +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/FinancialTransactionTest.kt @@ -24,7 +24,10 @@ class FinancialTransactionTest { .amount(123L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(FinancialTransaction.FinancialEvent.Result.APPROVED) - .type(FinancialTransaction.FinancialEvent.Type.ACH_INSUFFICIENT_FUNDS) + .type( + FinancialTransaction.FinancialEvent.FinancialEventType + .ACH_INSUFFICIENT_FUNDS + ) .build() ) ) @@ -48,7 +51,10 @@ class FinancialTransactionTest { .amount(123L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(FinancialTransaction.FinancialEvent.Result.APPROVED) - .type(FinancialTransaction.FinancialEvent.Type.ACH_INSUFFICIENT_FUNDS) + .type( + FinancialTransaction.FinancialEvent.FinancialEventType + .ACH_INSUFFICIENT_FUNDS + ) .build() ) assertThat(financialTransaction.pendingAmount()).isEqualTo(123L) diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/LineItemListResponseTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/LineItemListResponseTest.kt new file mode 100644 index 00000000..ac32e4ae --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/LineItemListResponseTest.kt @@ -0,0 +1,46 @@ +// 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 LineItemListResponseTest { + + @Test + fun createLineItemListResponse() { + val lineItemListResponse = + LineItemListResponse.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(123L) + .category(LineItemListResponse.Category.CARD) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("string") + .eventType(LineItemListResponse.FinancialEventType.ACH_INSUFFICIENT_FUNDS) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .financialTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .settledDate(LocalDate.parse("2019-12-27")) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .descriptor("string") + .build() + assertThat(lineItemListResponse).isNotNull + assertThat(lineItemListResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(lineItemListResponse.amount()).isEqualTo(123L) + assertThat(lineItemListResponse.category()).isEqualTo(LineItemListResponse.Category.CARD) + assertThat(lineItemListResponse.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(lineItemListResponse.currency()).isEqualTo("string") + assertThat(lineItemListResponse.eventType()) + .isEqualTo(LineItemListResponse.FinancialEventType.ACH_INSUFFICIENT_FUNDS) + assertThat(lineItemListResponse.financialAccountToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(lineItemListResponse.financialTransactionToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(lineItemListResponse.settledDate()).isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(lineItemListResponse.cardToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(lineItemListResponse.descriptor()).isEqualTo("string") + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/PaymentCreateParamsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/PaymentCreateParamsTest.kt index 9f41d077..90de6ac2 100644 --- a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/PaymentCreateParamsTest.kt +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/PaymentCreateParamsTest.kt @@ -18,6 +18,8 @@ class PaymentCreateParamsTest { .methodAttributes( PaymentCreateParams.PaymentMethodAttributes.builder() .secCode(PaymentCreateParams.PaymentMethodAttributes.SecCode.PPD) + .retries(123L) + .returnReasonCode("string") .build() ) .type(PaymentCreateParams.Type.PAYMENT) @@ -38,6 +40,8 @@ class PaymentCreateParamsTest { .methodAttributes( PaymentCreateParams.PaymentMethodAttributes.builder() .secCode(PaymentCreateParams.PaymentMethodAttributes.SecCode.PPD) + .retries(123L) + .returnReasonCode("string") .build() ) .type(PaymentCreateParams.Type.PAYMENT) @@ -56,6 +60,8 @@ class PaymentCreateParamsTest { .isEqualTo( PaymentCreateParams.PaymentMethodAttributes.builder() .secCode(PaymentCreateParams.PaymentMethodAttributes.SecCode.PPD) + .retries(123L) + .returnReasonCode("string") .build() ) assertThat(body.type()).isEqualTo(PaymentCreateParams.Type.PAYMENT) diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/PaymentRetryParamsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/PaymentRetryParamsTest.kt new file mode 100644 index 00000000..6548f9a6 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/PaymentRetryParamsTest.kt @@ -0,0 +1,28 @@ +// 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 PaymentRetryParamsTest { + + @Test + fun createPaymentRetryParams() { + PaymentRetryParams.builder().paymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun getPathParam() { + val params = + PaymentRetryParams.builder() + .paymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "paymentToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/ReportSettlementListDetailsParamsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/ReportSettlementListDetailsParamsTest.kt new file mode 100644 index 00000000..8d8640fc --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/ReportSettlementListDetailsParamsTest.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 ReportSettlementListDetailsParamsTest { + + @Test + fun createReportSettlementListDetailsParams() { + ReportSettlementListDetailsParams.builder() + .reportDate(LocalDate.parse("2019-12-27")) + .endingBefore("string") + .pageSize(123L) + .startingAfter("string") + .build() + } + + @Test + fun getQueryParams() { + val params = + ReportSettlementListDetailsParams.builder() + .reportDate(LocalDate.parse("2019-12-27")) + .endingBefore("string") + .pageSize(123L) + .startingAfter("string") + .build() + val expected = mutableMapOf>() + expected.put("ending_before", listOf("string")) + expected.put("page_size", listOf("123")) + expected.put("starting_after", listOf("string")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = + ReportSettlementListDetailsParams.builder() + .reportDate(LocalDate.parse("2019-12-27")) + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getPathParam() { + val params = + ReportSettlementListDetailsParams.builder() + .reportDate(LocalDate.parse("2019-12-27")) + .build() + assertThat(params).isNotNull + // path param "reportDate" + assertThat(params.getPathParam(0)).isEqualTo("2019-12-27") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/ReportSettlementSummaryParamsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/ReportSettlementSummaryParamsTest.kt new file mode 100644 index 00000000..d4e22666 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/ReportSettlementSummaryParamsTest.kt @@ -0,0 +1,29 @@ +// 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 ReportSettlementSummaryParamsTest { + + @Test + fun createReportSettlementSummaryParams() { + ReportSettlementSummaryParams.builder().reportDate(LocalDate.parse("2019-12-27")).build() + } + + @Test + fun getPathParam() { + val params = + ReportSettlementSummaryParams.builder() + .reportDate(LocalDate.parse("2019-12-27")) + .build() + assertThat(params).isNotNull + // path param "reportDate" + assertThat(params.getPathParam(0)).isEqualTo("2019-12-27") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/SettlementDetailTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/SettlementDetailTest.kt new file mode 100644 index 00000000..f71a36a4 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/SettlementDetailTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.JsonValue +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class SettlementDetailTest { + + @Test + fun createSettlementDetail() { + val settlementDetail = + SettlementDetail.builder() + .token("e34a817f-119d-4976-9fb3-8b020b8bbec3") + .accountToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") + .cardProgramToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") + .cardToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") + .created(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .currency("840") + .disputesGrossAmount(123L) + .eventTokens(listOf(JsonValue.from(mapOf()))) + .institution("00001") + .interchangeGrossAmount(123L) + .network(SettlementDetail.Network.MASTERCARD) + .otherFeesDetails( + SettlementDetail.OtherFeesDetails.builder() + .title(JsonValue.from(mapOf())) + .type(JsonValue.from(mapOf())) + .build() + ) + .otherFeesGrossAmount(123L) + .reportDate("2023-06-01") + .settlementDate("2023-06-01") + .transactionToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") + .transactionsGrossAmount(123L) + .updated(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .build() + assertThat(settlementDetail).isNotNull + assertThat(settlementDetail.token()).isEqualTo("e34a817f-119d-4976-9fb3-8b020b8bbec3") + assertThat(settlementDetail.accountToken()) + .isEqualTo("e34a817f-119d-4976-9fb3-8b020b8bbec3") + assertThat(settlementDetail.cardProgramToken()) + .isEqualTo("e34a817f-119d-4976-9fb3-8b020b8bbec3") + assertThat(settlementDetail.cardToken()).isEqualTo("e34a817f-119d-4976-9fb3-8b020b8bbec3") + assertThat(settlementDetail.created()) + .isEqualTo(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + assertThat(settlementDetail.currency()).isEqualTo("840") + assertThat(settlementDetail.disputesGrossAmount()).isEqualTo(123L) + assertThat(settlementDetail.eventTokens()) + .containsExactly(JsonValue.from(mapOf())) + assertThat(settlementDetail.institution()).isEqualTo("00001") + assertThat(settlementDetail.interchangeGrossAmount()).isEqualTo(123L) + assertThat(settlementDetail.network()).isEqualTo(SettlementDetail.Network.MASTERCARD) + assertThat(settlementDetail.otherFeesDetails()) + .isEqualTo( + SettlementDetail.OtherFeesDetails.builder() + .title(JsonValue.from(mapOf())) + .type(JsonValue.from(mapOf())) + .build() + ) + assertThat(settlementDetail.otherFeesGrossAmount()).isEqualTo(123L) + assertThat(settlementDetail.reportDate()).isEqualTo("2023-06-01") + assertThat(settlementDetail.settlementDate()).isEqualTo("2023-06-01") + assertThat(settlementDetail.transactionToken()) + .isEqualTo("e34a817f-119d-4976-9fb3-8b020b8bbec3") + assertThat(settlementDetail.transactionsGrossAmount()).isEqualTo(123L) + assertThat(settlementDetail.updated()) + .isEqualTo(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/SettlementReportTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/SettlementReportTest.kt new file mode 100644 index 00000000..3c1b1294 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/SettlementReportTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class SettlementReportTest { + + @Test + fun createSettlementReport() { + val settlementReport = + SettlementReport.builder() + .created(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .currency("840") + .details( + listOf( + SettlementSummaryDetails.builder() + .disputesGrossAmount(123L) + .institution("00001") + .interchangeGrossAmount(123L) + .network(SettlementSummaryDetails.Network.MASTERCARD) + .otherFeesGrossAmount(123L) + .settledNetAmount(123L) + .transactionsGrossAmount(123L) + .build() + ) + ) + .disputesGrossAmount(123L) + .interchangeGrossAmount(123L) + .otherFeesGrossAmount(123L) + .reportDate("2023-06-01") + .settledNetAmount(123L) + .transactionsGrossAmount(123L) + .updated(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .build() + assertThat(settlementReport).isNotNull + assertThat(settlementReport.created()) + .isEqualTo(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + assertThat(settlementReport.currency()).isEqualTo("840") + assertThat(settlementReport.details()) + .containsExactly( + SettlementSummaryDetails.builder() + .disputesGrossAmount(123L) + .institution("00001") + .interchangeGrossAmount(123L) + .network(SettlementSummaryDetails.Network.MASTERCARD) + .otherFeesGrossAmount(123L) + .settledNetAmount(123L) + .transactionsGrossAmount(123L) + .build() + ) + assertThat(settlementReport.disputesGrossAmount()).isEqualTo(123L) + assertThat(settlementReport.interchangeGrossAmount()).isEqualTo(123L) + assertThat(settlementReport.otherFeesGrossAmount()).isEqualTo(123L) + assertThat(settlementReport.reportDate()).isEqualTo("2023-06-01") + assertThat(settlementReport.settledNetAmount()).isEqualTo(123L) + assertThat(settlementReport.transactionsGrossAmount()).isEqualTo(123L) + assertThat(settlementReport.updated()) + .isEqualTo(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/SettlementSummaryDetailsTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/SettlementSummaryDetailsTest.kt new file mode 100644 index 00000000..06613834 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/SettlementSummaryDetailsTest.kt @@ -0,0 +1,32 @@ +// 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 SettlementSummaryDetailsTest { + + @Test + fun createSettlementSummaryDetails() { + val settlementSummaryDetails = + SettlementSummaryDetails.builder() + .disputesGrossAmount(123L) + .institution("00001") + .interchangeGrossAmount(123L) + .network(SettlementSummaryDetails.Network.MASTERCARD) + .otherFeesGrossAmount(123L) + .settledNetAmount(123L) + .transactionsGrossAmount(123L) + .build() + assertThat(settlementSummaryDetails).isNotNull + assertThat(settlementSummaryDetails.disputesGrossAmount()).isEqualTo(123L) + assertThat(settlementSummaryDetails.institution()).isEqualTo("00001") + assertThat(settlementSummaryDetails.interchangeGrossAmount()).isEqualTo(123L) + assertThat(settlementSummaryDetails.network()) + .isEqualTo(SettlementSummaryDetails.Network.MASTERCARD) + assertThat(settlementSummaryDetails.otherFeesGrossAmount()).isEqualTo(123L) + assertThat(settlementSummaryDetails.settledNetAmount()).isEqualTo(123L) + assertThat(settlementSummaryDetails.transactionsGrossAmount()).isEqualTo(123L) + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/SettlementSummaryResponseTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/SettlementSummaryResponseTest.kt new file mode 100644 index 00000000..86b16796 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/SettlementSummaryResponseTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class SettlementSummaryResponseTest { + + @Test + fun createSettlementSummaryResponse() { + val settlementSummaryResponse = + SettlementSummaryResponse.builder() + .data( + listOf( + SettlementReport.builder() + .created(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .currency("840") + .details( + listOf( + SettlementSummaryDetails.builder() + .disputesGrossAmount(123L) + .institution("00001") + .interchangeGrossAmount(123L) + .network(SettlementSummaryDetails.Network.MASTERCARD) + .otherFeesGrossAmount(123L) + .settledNetAmount(123L) + .transactionsGrossAmount(123L) + .build() + ) + ) + .disputesGrossAmount(123L) + .interchangeGrossAmount(123L) + .otherFeesGrossAmount(123L) + .reportDate("2023-06-01") + .settledNetAmount(123L) + .transactionsGrossAmount(123L) + .updated(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .build() + ) + ) + .build() + assertThat(settlementSummaryResponse).isNotNull + assertThat(settlementSummaryResponse.data()) + .containsExactly( + SettlementReport.builder() + .created(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .currency("840") + .details( + listOf( + SettlementSummaryDetails.builder() + .disputesGrossAmount(123L) + .institution("00001") + .interchangeGrossAmount(123L) + .network(SettlementSummaryDetails.Network.MASTERCARD) + .otherFeesGrossAmount(123L) + .settledNetAmount(123L) + .transactionsGrossAmount(123L) + .build() + ) + ) + .disputesGrossAmount(123L) + .interchangeGrossAmount(123L) + .otherFeesGrossAmount(123L) + .reportDate("2023-06-01") + .settledNetAmount(123L) + .transactionsGrossAmount(123L) + .updated(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .build() + ) + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/StatementTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/StatementTest.kt new file mode 100644 index 00000000..2a035f75 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/StatementTest.kt @@ -0,0 +1,58 @@ +// 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 StatementTest { + + @Test + fun createStatement() { + val statement = + Statement.builder() + .token("string") + .achPeriodTotal(123L) + .achYtdTotal(123L) + .adjustmentsPeriodTotal(123L) + .adjustmentsYtdTotal(123L) + .amountDue(123L) + .availableCredit(123L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditLimit(123L) + .daysInBillingCycle(123L) + .endingBalance(123L) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentDueDate(LocalDate.parse("2019-12-27")) + .purchasesPeriodTotal(123L) + .purchasesYtdTotal(123L) + .startingBalance(123L) + .statementEndDate(LocalDate.parse("2019-12-27")) + .statementStartDate(LocalDate.parse("2019-12-27")) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + assertThat(statement).isNotNull + assertThat(statement.token()).isEqualTo("string") + assertThat(statement.achPeriodTotal()).isEqualTo(123L) + assertThat(statement.achYtdTotal()).isEqualTo(123L) + assertThat(statement.adjustmentsPeriodTotal()).isEqualTo(123L) + assertThat(statement.adjustmentsYtdTotal()).isEqualTo(123L) + assertThat(statement.amountDue()).isEqualTo(123L) + assertThat(statement.availableCredit()).isEqualTo(123L) + assertThat(statement.created()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(statement.creditLimit()).isEqualTo(123L) + assertThat(statement.daysInBillingCycle()).isEqualTo(123L) + assertThat(statement.endingBalance()).isEqualTo(123L) + assertThat(statement.financialAccountToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(statement.paymentDueDate()).isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(statement.purchasesPeriodTotal()).isEqualTo(123L) + assertThat(statement.purchasesYtdTotal()).isEqualTo(123L) + assertThat(statement.startingBalance()).isEqualTo(123L) + assertThat(statement.statementEndDate()).isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(statement.statementStartDate()).isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(statement.updated()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/TransferCreateResponseTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/TransferCreateResponseTest.kt index 7a245cb3..3239e331 100644 --- a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/TransferCreateResponseTest.kt +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/TransferCreateResponseTest.kt @@ -26,7 +26,10 @@ class TransferCreateResponseTest { .amount(123L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Transfer.FinancialEvent.Result.APPROVED) - .type(Transfer.FinancialEvent.Type.ACH_INSUFFICIENT_FUNDS) + .type( + Transfer.FinancialEvent.FinancialEventType + .ACH_INSUFFICIENT_FUNDS + ) .build() ) ) @@ -90,7 +93,10 @@ class TransferCreateResponseTest { .amount(123L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Transfer.FinancialEvent.Result.APPROVED) - .type(Transfer.FinancialEvent.Type.ACH_INSUFFICIENT_FUNDS) + .type( + Transfer.FinancialEvent.FinancialEventType + .ACH_INSUFFICIENT_FUNDS + ) .build() ) ) diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/TransferTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/TransferTest.kt index 4fefe8d9..916c84ba 100644 --- a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/TransferTest.kt +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/models/TransferTest.kt @@ -24,7 +24,7 @@ class TransferTest { .amount(123L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Transfer.FinancialEvent.Result.APPROVED) - .type(Transfer.FinancialEvent.Type.ACH_INSUFFICIENT_FUNDS) + .type(Transfer.FinancialEvent.FinancialEventType.ACH_INSUFFICIENT_FUNDS) .build() ) ) @@ -79,7 +79,7 @@ class TransferTest { .amount(123L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Transfer.FinancialEvent.Result.APPROVED) - .type(Transfer.FinancialEvent.Type.ACH_INSUFFICIENT_FUNDS) + .type(Transfer.FinancialEvent.FinancialEventType.ACH_INSUFFICIENT_FUNDS) .build() ) assertThat(transfer.fromBalance()) diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/CardProductServiceTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/CardProductServiceTest.kt new file mode 100644 index 00000000..30c959ea --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/CardProductServiceTest.kt @@ -0,0 +1,27 @@ +// 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 org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class CardProductServiceTest { + + @Test + fun callCreditDetail() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val cardProductService = client.cardProduct() + val cardProductCreditDetailResponse = + cardProductService.creditDetail(CardProductCreditDetailParams.builder().build()) + println(cardProductCreditDetailResponse) + cardProductCreditDetailResponse.validate() + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/PaymentServiceTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/PaymentServiceTest.kt index 507a9973..ba8104d3 100644 --- a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/PaymentServiceTest.kt +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/PaymentServiceTest.kt @@ -30,6 +30,8 @@ class PaymentServiceTest { .methodAttributes( PaymentCreateParams.PaymentMethodAttributes.builder() .secCode(PaymentCreateParams.PaymentMethodAttributes.SecCode.PPD) + .retries(123L) + .returnReasonCode("string") .build() ) .type(PaymentCreateParams.Type.PAYMENT) @@ -71,6 +73,23 @@ class PaymentServiceTest { response.data().forEach { it.validate() } } + @Test + fun callRetry() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val paymentService = client.payments() + val paymentRetryResponse = + paymentService.retry( + PaymentRetryParams.builder() + .paymentToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(paymentRetryResponse) + } + @Test fun callSimulateRelease() { val client = diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/ReportServiceTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/ReportServiceTest.kt new file mode 100644 index 00000000..4722ef90 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/ReportServiceTest.kt @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.lithic.api.TestServerExtension +import com.lithic.api.models.* +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) class ReportServiceTest diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/accounts/CreditConfigurationServiceTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/accounts/CreditConfigurationServiceTest.kt new file mode 100644 index 00000000..fb1867ea --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/accounts/CreditConfigurationServiceTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.accounts + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClient +import com.lithic.api.models.* +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class CreditConfigurationServiceTest { + + @Test + fun callRetrieve() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val creditConfigurationService = client.accounts().creditConfigurations() + val businessAccount = + creditConfigurationService.retrieve( + AccountCreditConfigurationRetrieveParams.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(businessAccount) + businessAccount.validate() + } + + @Test + fun callUpdate() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val creditConfigurationService = client.accounts().creditConfigurations() + val businessAccount = + creditConfigurationService.update( + AccountCreditConfigurationUpdateParams.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .billingPeriod(123L) + .creditLimit(123L) + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentPeriod(123L) + .build() + ) + println(businessAccount) + businessAccount.validate() + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/cards/AggregateBalanceServiceTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/cards/AggregateBalanceServiceTest.kt new file mode 100644 index 00000000..1cf937f2 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/cards/AggregateBalanceServiceTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.cards + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClient +import com.lithic.api.models.* +import com.lithic.api.models.CardAggregateBalanceListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class AggregateBalanceServiceTest { + + @Test + fun callList() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val aggregateBalanceService = client.cards().aggregateBalances() + val response = + aggregateBalanceService.list(CardAggregateBalanceListParams.builder().build()) + println(response) + response.data().forEach { it.validate() } + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/cards/BalanceServiceTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/cards/BalanceServiceTest.kt new file mode 100644 index 00000000..97704b05 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/cards/BalanceServiceTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.cards + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClient +import com.lithic.api.models.* +import com.lithic.api.models.CardBalanceListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class BalanceServiceTest { + + @Test + fun callList() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val balanceService = client.cards().balances() + val response = + balanceService.list( + CardBalanceListParams.builder() + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(response) + response.data().forEach { it.validate() } + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/cards/FinancialTransactionServiceTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/cards/FinancialTransactionServiceTest.kt new file mode 100644 index 00000000..81de6558 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/cards/FinancialTransactionServiceTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.cards + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClient +import com.lithic.api.models.* +import com.lithic.api.models.CardFinancialTransactionListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class FinancialTransactionServiceTest { + + @Test + fun callRetrieve() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val financialTransactionService = client.cards().financialTransactions() + val financialTransaction = + financialTransactionService.retrieve( + CardFinancialTransactionRetrieveParams.builder() + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .financialTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(financialTransaction) + financialTransaction.validate() + } + + @Test + fun callList() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val financialTransactionService = client.cards().financialTransactions() + val response = + financialTransactionService.list( + CardFinancialTransactionListParams.builder() + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(response) + response.data().forEach { it.validate() } + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/financialAccounts/StatementServiceTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/financialAccounts/StatementServiceTest.kt new file mode 100644 index 00000000..ab057b74 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/financialAccounts/StatementServiceTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.financialAccounts + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClient +import com.lithic.api.models.* +import com.lithic.api.models.FinancialAccountStatementListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class StatementServiceTest { + + @Test + fun callRetrieve() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val statementService = client.financialAccounts().statements() + val statement = + statementService.retrieve( + FinancialAccountStatementRetrieveParams.builder() + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .statementToken("string") + .build() + ) + println(statement) + statement.validate() + } + + @Test + fun callList() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val statementService = client.financialAccounts().statements() + val response = + statementService.list( + FinancialAccountStatementListParams.builder() + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(response) + response.data().forEach { it.validate() } + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/financialAccounts/statements/LineItemServiceTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/financialAccounts/statements/LineItemServiceTest.kt new file mode 100644 index 00000000..b6d66179 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/financialAccounts/statements/LineItemServiceTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.financialAccounts.statements + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClient +import com.lithic.api.models.* +import com.lithic.api.models.FinancialAccountStatementLineItemListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class LineItemServiceTest { + + @Test + fun callList() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val lineItemService = client.financialAccounts().statements().lineItems() + val response = + lineItemService.list( + FinancialAccountStatementLineItemListParams.builder() + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .statementToken("string") + .build() + ) + println(response) + response.data().forEach { it.validate() } + } +} diff --git a/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/reports/SettlementServiceTest.kt b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/reports/SettlementServiceTest.kt new file mode 100644 index 00000000..2e5193a6 --- /dev/null +++ b/lithic-kotlin-core/src/test/kotlin/com/lithic/api/services/blocking/reports/SettlementServiceTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.reports + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClient +import com.lithic.api.models.* +import com.lithic.api.models.ReportSettlementListDetailsParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class SettlementServiceTest { + + @Test + fun callListDetails() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val settlementService = client.reports().settlement() + val response = + settlementService.listDetails( + ReportSettlementListDetailsParams.builder() + .reportDate(LocalDate.parse("2019-12-27")) + .build() + ) + println(response) + response.data().forEach { it.validate() } + } + + @Test + fun callSummary() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val settlementService = client.reports().settlement() + val settlementSummaryResponse = + settlementService.summary( + ReportSettlementSummaryParams.builder() + .reportDate(LocalDate.parse("2019-12-27")) + .build() + ) + println(settlementSummaryResponse) + settlementSummaryResponse.validate() + } +}