com.lithic.api.models.CardCreateParams.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lithic-kotlin-core Show documentation
Show all versions of lithic-kotlin-core Show documentation
The Lithic Developer API is designed to provide a predictable programmatic
interface for accessing your Lithic account through an API and transaction
webhooks. Note that your API key is a secret and should be treated as such.
Don't share it with anyone, including us. We will never ask you for it.
// File generated from our OpenAPI spec by Stainless.
package com.lithic.api.models
import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.lithic.api.core.Enum
import com.lithic.api.core.ExcludeMissing
import com.lithic.api.core.JsonField
import com.lithic.api.core.JsonValue
import com.lithic.api.core.NoAutoDetect
import com.lithic.api.core.toUnmodifiable
import com.lithic.api.errors.LithicInvalidDataException
import com.lithic.api.models.*
import java.util.Objects
class CardCreateParams
constructor(
private val type: Type,
private val accountToken: String?,
private val cardProgramToken: String?,
private val carrier: Carrier?,
private val digitalCardArtToken: String?,
private val expMonth: String?,
private val expYear: String?,
private val memo: String?,
private val pin: String?,
private val productId: String?,
private val replacementFor: String?,
private val shippingAddress: ShippingAddress?,
private val shippingMethod: ShippingMethod?,
private val spendLimit: Long?,
private val spendLimitDuration: SpendLimitDuration?,
private val state: State?,
private val additionalQueryParams: Map>,
private val additionalHeaders: Map>,
private val additionalBodyProperties: Map,
) {
fun type(): Type = type
fun accountToken(): String? = accountToken
fun cardProgramToken(): String? = cardProgramToken
fun carrier(): Carrier? = carrier
fun digitalCardArtToken(): String? = digitalCardArtToken
fun expMonth(): String? = expMonth
fun expYear(): String? = expYear
fun memo(): String? = memo
fun pin(): String? = pin
fun productId(): String? = productId
fun replacementFor(): String? = replacementFor
fun shippingAddress(): ShippingAddress? = shippingAddress
fun shippingMethod(): ShippingMethod? = shippingMethod
fun spendLimit(): Long? = spendLimit
fun spendLimitDuration(): SpendLimitDuration? = spendLimitDuration
fun state(): State? = state
internal fun getBody(): CardCreateBody {
return CardCreateBody(
type,
accountToken,
cardProgramToken,
carrier,
digitalCardArtToken,
expMonth,
expYear,
memo,
pin,
productId,
replacementFor,
shippingAddress,
shippingMethod,
spendLimit,
spendLimitDuration,
state,
additionalBodyProperties,
)
}
internal fun getQueryParams(): Map> = additionalQueryParams
internal fun getHeaders(): Map> = additionalHeaders
@JsonDeserialize(builder = CardCreateBody.Builder::class)
@NoAutoDetect
class CardCreateBody
internal constructor(
private val type: Type?,
private val accountToken: String?,
private val cardProgramToken: String?,
private val carrier: Carrier?,
private val digitalCardArtToken: String?,
private val expMonth: String?,
private val expYear: String?,
private val memo: String?,
private val pin: String?,
private val productId: String?,
private val replacementFor: String?,
private val shippingAddress: ShippingAddress?,
private val shippingMethod: ShippingMethod?,
private val spendLimit: Long?,
private val spendLimitDuration: SpendLimitDuration?,
private val state: State?,
private val additionalProperties: Map,
) {
private var hashCode: Int = 0
/**
* Card types:
* - `VIRTUAL` - Card will authorize at any merchant and can be added to a digital wallet
* like Apple Pay or Google Pay (if the card program is digital wallet-enabled).
* - `PHYSICAL` - Manufactured and sent to the cardholder. We offer white label branding,
* credit, ATM, PIN debit, chip/EMV, NFC and magstripe functionality. Reach out at
* [lithic.com/contact](https://lithic.com/contact) for more information.
* - `SINGLE_USE` - Card is closed upon first successful authorization.
* - `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that
* successfully authorizes the card.
*/
@JsonProperty("type") fun type(): Type? = type
/**
* Globally unique identifier for the account that the card will be associated with.
* Required for programs enrolling users using the
* [/account_holders endpoint](https://docs.lithic.com/docs/account-holders-kyc). See
* [Managing Your Program](doc:managing-your-program) for more information.
*/
@JsonProperty("account_token") fun accountToken(): String? = accountToken
/**
* For card programs with more than one BIN range. This must be configured with Lithic
* before use. Identifies the card program/BIN range under which to create the card. If
* omitted, will utilize the program's default `card_program_token`. In Sandbox, use
* 00000000-0000-0000-1000-000000000000 and 00000000-0000-0000-2000-000000000000 to test
* creating cards on specific card programs.
*/
@JsonProperty("card_program_token") fun cardProgramToken(): String? = cardProgramToken
@JsonProperty("carrier") fun carrier(): Carrier? = carrier
/**
* Specifies the digital card art to be displayed in the user’s digital wallet after
* tokenization. This artwork must be approved by Mastercard and configured by Lithic to
* use. See
* [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art).
*/
@JsonProperty("digital_card_art_token")
fun digitalCardArtToken(): String? = digitalCardArtToken
/**
* Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an
* expiration date will be generated.
*/
@JsonProperty("exp_month") fun expMonth(): String? = expMonth
/**
* Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an
* expiration date will be generated.
*/
@JsonProperty("exp_year") fun expYear(): String? = expYear
/**
* Friendly name to identify the card. We recommend against using this field to store JSON
* data as it can cause unexpected behavior.
*/
@JsonProperty("memo") fun memo(): String? = memo
/**
* Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and `VIRTUAL`.
* See [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block).
*/
@JsonProperty("pin") fun pin(): String? = pin
/**
* Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic before
* use. Specifies the configuration (i.e., physical card art) that the card should be
* manufactured with.
*/
@JsonProperty("product_id") fun productId(): String? = productId
/**
* Only applicable to cards of type `PHYSICAL`. Globally unique identifier for the card that
* this physical card will replace.
*/
@JsonProperty("replacement_for") fun replacementFor(): String? = replacementFor
@JsonProperty("shipping_address") fun shippingAddress(): ShippingAddress? = shippingAddress
/**
* Shipping method for the card. Only applies to cards of type PHYSICAL. Use of options
* besides `STANDARD` require additional permissions.
* - `STANDARD` - USPS regular mail or similar international option, with no tracking
* - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with
* tracking
* - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking
* - `EXPRESS` - FedEx Express, 3-day shipping, with tracking
* - `2_DAY` - FedEx 2-day shipping, with tracking
* - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking
*/
@JsonProperty("shipping_method") fun shippingMethod(): ShippingMethod? = shippingMethod
/**
* Amount (in cents) to limit approved authorizations. Transaction requests above the spend
* limit will be declined. Note that a spend limit of 0 is effectively no limit, and should
* only be used to reset or remove a prior limit. Only a limit of 1 or above will result in
* declined transactions due to checks against the card limit.
*/
@JsonProperty("spend_limit") fun spendLimit(): Long? = spendLimit
/**
* Spend limit duration values:
* - `ANNUALLY` - Card will authorize transactions up to spend limit for the trailing year.
* - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime of the
* card.
* - `MONTHLY` - Card will authorize transactions up to spend limit for the trailing month.
* To support recurring monthly payments, which can occur on different day every month,
* the time window we consider for monthly velocity starts 6 days after the current
* calendar date one month prior.
* - `TRANSACTION` - Card will authorize multiple transactions if each individual
* transaction is under the spend limit.
*/
@JsonProperty("spend_limit_duration")
fun spendLimitDuration(): SpendLimitDuration? = spendLimitDuration
/**
* Card state values:
* - `OPEN` - Card will approve authorizations (if they match card and account parameters).
* - `PAUSED` - Card will decline authorizations, but can be resumed at a later time.
*/
@JsonProperty("state") fun state(): State? = state
@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 CardCreateBody &&
this.type == other.type &&
this.accountToken == other.accountToken &&
this.cardProgramToken == other.cardProgramToken &&
this.carrier == other.carrier &&
this.digitalCardArtToken == other.digitalCardArtToken &&
this.expMonth == other.expMonth &&
this.expYear == other.expYear &&
this.memo == other.memo &&
this.pin == other.pin &&
this.productId == other.productId &&
this.replacementFor == other.replacementFor &&
this.shippingAddress == other.shippingAddress &&
this.shippingMethod == other.shippingMethod &&
this.spendLimit == other.spendLimit &&
this.spendLimitDuration == other.spendLimitDuration &&
this.state == other.state &&
this.additionalProperties == other.additionalProperties
}
override fun hashCode(): Int {
if (hashCode == 0) {
hashCode =
Objects.hash(
type,
accountToken,
cardProgramToken,
carrier,
digitalCardArtToken,
expMonth,
expYear,
memo,
pin,
productId,
replacementFor,
shippingAddress,
shippingMethod,
spendLimit,
spendLimitDuration,
state,
additionalProperties,
)
}
return hashCode
}
override fun toString() =
"CardCreateBody{type=$type, accountToken=$accountToken, cardProgramToken=$cardProgramToken, carrier=$carrier, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, memo=$memo, pin=$pin, productId=$productId, replacementFor=$replacementFor, shippingAddress=$shippingAddress, shippingMethod=$shippingMethod, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, additionalProperties=$additionalProperties}"
companion object {
fun builder() = Builder()
}
class Builder {
private var type: Type? = null
private var accountToken: String? = null
private var cardProgramToken: String? = null
private var carrier: Carrier? = null
private var digitalCardArtToken: String? = null
private var expMonth: String? = null
private var expYear: String? = null
private var memo: String? = null
private var pin: String? = null
private var productId: String? = null
private var replacementFor: String? = null
private var shippingAddress: ShippingAddress? = null
private var shippingMethod: ShippingMethod? = null
private var spendLimit: Long? = null
private var spendLimitDuration: SpendLimitDuration? = null
private var state: State? = null
private var additionalProperties: MutableMap = mutableMapOf()
internal fun from(cardCreateBody: CardCreateBody) = apply {
this.type = cardCreateBody.type
this.accountToken = cardCreateBody.accountToken
this.cardProgramToken = cardCreateBody.cardProgramToken
this.carrier = cardCreateBody.carrier
this.digitalCardArtToken = cardCreateBody.digitalCardArtToken
this.expMonth = cardCreateBody.expMonth
this.expYear = cardCreateBody.expYear
this.memo = cardCreateBody.memo
this.pin = cardCreateBody.pin
this.productId = cardCreateBody.productId
this.replacementFor = cardCreateBody.replacementFor
this.shippingAddress = cardCreateBody.shippingAddress
this.shippingMethod = cardCreateBody.shippingMethod
this.spendLimit = cardCreateBody.spendLimit
this.spendLimitDuration = cardCreateBody.spendLimitDuration
this.state = cardCreateBody.state
additionalProperties(cardCreateBody.additionalProperties)
}
/**
* Card types:
* - `VIRTUAL` - Card will authorize at any merchant and can be added to a digital
* wallet like Apple Pay or Google Pay (if the card program is digital
* wallet-enabled).
* - `PHYSICAL` - Manufactured and sent to the cardholder. We offer white label
* branding, credit, ATM, PIN debit, chip/EMV, NFC and magstripe functionality. Reach
* out at [lithic.com/contact](https://lithic.com/contact) for more information.
* - `SINGLE_USE` - Card is closed upon first successful authorization.
* - `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that
* successfully authorizes the card.
*/
@JsonProperty("type") fun type(type: Type) = apply { this.type = type }
/**
* Globally unique identifier for the account that the card will be associated with.
* Required for programs enrolling users using the
* [/account_holders endpoint](https://docs.lithic.com/docs/account-holders-kyc). See
* [Managing Your Program](doc:managing-your-program) for more information.
*/
@JsonProperty("account_token")
fun accountToken(accountToken: String) = apply { this.accountToken = accountToken }
/**
* For card programs with more than one BIN range. This must be configured with Lithic
* before use. Identifies the card program/BIN range under which to create the card. If
* omitted, will utilize the program's default `card_program_token`. In Sandbox, use
* 00000000-0000-0000-1000-000000000000 and 00000000-0000-0000-2000-000000000000 to test
* creating cards on specific card programs.
*/
@JsonProperty("card_program_token")
fun cardProgramToken(cardProgramToken: String) = apply {
this.cardProgramToken = cardProgramToken
}
@JsonProperty("carrier")
fun carrier(carrier: Carrier) = apply { this.carrier = carrier }
/**
* Specifies the digital card art to be displayed in the user’s digital wallet after
* tokenization. This artwork must be approved by Mastercard and configured by Lithic to
* use. See
* [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art).
*/
@JsonProperty("digital_card_art_token")
fun digitalCardArtToken(digitalCardArtToken: String) = apply {
this.digitalCardArtToken = digitalCardArtToken
}
/**
* Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an
* expiration date will be generated.
*/
@JsonProperty("exp_month")
fun expMonth(expMonth: String) = apply { this.expMonth = expMonth }
/**
* Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an
* expiration date will be generated.
*/
@JsonProperty("exp_year")
fun expYear(expYear: String) = apply { this.expYear = expYear }
/**
* Friendly name to identify the card. We recommend against using this field to store
* JSON data as it can cause unexpected behavior.
*/
@JsonProperty("memo") fun memo(memo: String) = apply { this.memo = memo }
/**
* Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and
* `VIRTUAL`. See
* [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block).
*/
@JsonProperty("pin") fun pin(pin: String) = apply { this.pin = pin }
/**
* Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic
* before use. Specifies the configuration (i.e., physical card art) that the card
* should be manufactured with.
*/
@JsonProperty("product_id")
fun productId(productId: String) = apply { this.productId = productId }
/**
* Only applicable to cards of type `PHYSICAL`. Globally unique identifier for the card
* that this physical card will replace.
*/
@JsonProperty("replacement_for")
fun replacementFor(replacementFor: String) = apply {
this.replacementFor = replacementFor
}
@JsonProperty("shipping_address")
fun shippingAddress(shippingAddress: ShippingAddress) = apply {
this.shippingAddress = shippingAddress
}
/**
* Shipping method for the card. Only applies to cards of type PHYSICAL. Use of options
* besides `STANDARD` require additional permissions.
* - `STANDARD` - USPS regular mail or similar international option, with no tracking
* - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with
* tracking
* - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking
* - `EXPRESS` - FedEx Express, 3-day shipping, with tracking
* - `2_DAY` - FedEx 2-day shipping, with tracking
* - `EXPEDITED` - FedEx Standard Overnight or similar international option, with
* tracking
*/
@JsonProperty("shipping_method")
fun shippingMethod(shippingMethod: ShippingMethod) = apply {
this.shippingMethod = shippingMethod
}
/**
* Amount (in cents) to limit approved authorizations. Transaction requests above the
* spend limit will be declined. Note that a spend limit of 0 is effectively no limit,
* and should only be used to reset or remove a prior limit. Only a limit of 1 or above
* will result in declined transactions due to checks against the card limit.
*/
@JsonProperty("spend_limit")
fun spendLimit(spendLimit: Long) = apply { this.spendLimit = spendLimit }
/**
* Spend limit duration values:
* - `ANNUALLY` - Card will authorize transactions up to spend limit for the trailing
* year.
* - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime of
* the card.
* - `MONTHLY` - Card will authorize transactions up to spend limit for the trailing
* month. To support recurring monthly payments, which can occur on different day
* every month, the time window we consider for monthly velocity starts 6 days after
* the current calendar date one month prior.
* - `TRANSACTION` - Card will authorize multiple transactions if each individual
* transaction is under the spend limit.
*/
@JsonProperty("spend_limit_duration")
fun spendLimitDuration(spendLimitDuration: SpendLimitDuration) = apply {
this.spendLimitDuration = spendLimitDuration
}
/**
* Card state values:
* - `OPEN` - Card will approve authorizations (if they match card and account
* parameters).
* - `PAUSED` - Card will decline authorizations, but can be resumed at a later time.
*/
@JsonProperty("state") fun state(state: State) = apply { this.state = state }
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(): CardCreateBody =
CardCreateBody(
checkNotNull(type) { "`type` is required but was not set" },
accountToken,
cardProgramToken,
carrier,
digitalCardArtToken,
expMonth,
expYear,
memo,
pin,
productId,
replacementFor,
shippingAddress,
shippingMethod,
spendLimit,
spendLimitDuration,
state,
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 CardCreateParams &&
this.type == other.type &&
this.accountToken == other.accountToken &&
this.cardProgramToken == other.cardProgramToken &&
this.carrier == other.carrier &&
this.digitalCardArtToken == other.digitalCardArtToken &&
this.expMonth == other.expMonth &&
this.expYear == other.expYear &&
this.memo == other.memo &&
this.pin == other.pin &&
this.productId == other.productId &&
this.replacementFor == other.replacementFor &&
this.shippingAddress == other.shippingAddress &&
this.shippingMethod == other.shippingMethod &&
this.spendLimit == other.spendLimit &&
this.spendLimitDuration == other.spendLimitDuration &&
this.state == other.state &&
this.additionalQueryParams == other.additionalQueryParams &&
this.additionalHeaders == other.additionalHeaders &&
this.additionalBodyProperties == other.additionalBodyProperties
}
override fun hashCode(): Int {
return Objects.hash(
type,
accountToken,
cardProgramToken,
carrier,
digitalCardArtToken,
expMonth,
expYear,
memo,
pin,
productId,
replacementFor,
shippingAddress,
shippingMethod,
spendLimit,
spendLimitDuration,
state,
additionalQueryParams,
additionalHeaders,
additionalBodyProperties,
)
}
override fun toString() =
"CardCreateParams{type=$type, accountToken=$accountToken, cardProgramToken=$cardProgramToken, carrier=$carrier, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, memo=$memo, pin=$pin, productId=$productId, replacementFor=$replacementFor, shippingAddress=$shippingAddress, shippingMethod=$shippingMethod, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}"
fun toBuilder() = Builder().from(this)
companion object {
fun builder() = Builder()
}
@NoAutoDetect
class Builder {
private var type: Type? = null
private var accountToken: String? = null
private var cardProgramToken: String? = null
private var carrier: Carrier? = null
private var digitalCardArtToken: String? = null
private var expMonth: String? = null
private var expYear: String? = null
private var memo: String? = null
private var pin: String? = null
private var productId: String? = null
private var replacementFor: String? = null
private var shippingAddress: ShippingAddress? = null
private var shippingMethod: ShippingMethod? = null
private var spendLimit: Long? = null
private var spendLimitDuration: SpendLimitDuration? = null
private var state: State? = null
private var additionalQueryParams: MutableMap> = mutableMapOf()
private var additionalHeaders: MutableMap> = mutableMapOf()
private var additionalBodyProperties: MutableMap = mutableMapOf()
internal fun from(cardCreateParams: CardCreateParams) = apply {
this.type = cardCreateParams.type
this.accountToken = cardCreateParams.accountToken
this.cardProgramToken = cardCreateParams.cardProgramToken
this.carrier = cardCreateParams.carrier
this.digitalCardArtToken = cardCreateParams.digitalCardArtToken
this.expMonth = cardCreateParams.expMonth
this.expYear = cardCreateParams.expYear
this.memo = cardCreateParams.memo
this.pin = cardCreateParams.pin
this.productId = cardCreateParams.productId
this.replacementFor = cardCreateParams.replacementFor
this.shippingAddress = cardCreateParams.shippingAddress
this.shippingMethod = cardCreateParams.shippingMethod
this.spendLimit = cardCreateParams.spendLimit
this.spendLimitDuration = cardCreateParams.spendLimitDuration
this.state = cardCreateParams.state
additionalQueryParams(cardCreateParams.additionalQueryParams)
additionalHeaders(cardCreateParams.additionalHeaders)
additionalBodyProperties(cardCreateParams.additionalBodyProperties)
}
/**
* Card types:
* - `VIRTUAL` - Card will authorize at any merchant and can be added to a digital wallet
* like Apple Pay or Google Pay (if the card program is digital wallet-enabled).
* - `PHYSICAL` - Manufactured and sent to the cardholder. We offer white label branding,
* credit, ATM, PIN debit, chip/EMV, NFC and magstripe functionality. Reach out at
* [lithic.com/contact](https://lithic.com/contact) for more information.
* - `SINGLE_USE` - Card is closed upon first successful authorization.
* - `MERCHANT_LOCKED` - _[Deprecated]_ Card is locked to the first merchant that
* successfully authorizes the card.
*/
fun type(type: Type) = apply { this.type = type }
/**
* Globally unique identifier for the account that the card will be associated with.
* Required for programs enrolling users using the
* [/account_holders endpoint](https://docs.lithic.com/docs/account-holders-kyc). See
* [Managing Your Program](doc:managing-your-program) for more information.
*/
fun accountToken(accountToken: String) = apply { this.accountToken = accountToken }
/**
* For card programs with more than one BIN range. This must be configured with Lithic
* before use. Identifies the card program/BIN range under which to create the card. If
* omitted, will utilize the program's default `card_program_token`. In Sandbox, use
* 00000000-0000-0000-1000-000000000000 and 00000000-0000-0000-2000-000000000000 to test
* creating cards on specific card programs.
*/
fun cardProgramToken(cardProgramToken: String) = apply {
this.cardProgramToken = cardProgramToken
}
fun carrier(carrier: Carrier) = apply { this.carrier = carrier }
/**
* Specifies the digital card art to be displayed in the user’s digital wallet after
* tokenization. This artwork must be approved by Mastercard and configured by Lithic to
* use. See
* [Flexible Card Art Guide](https://docs.lithic.com/docs/about-digital-wallets#flexible-card-art).
*/
fun digitalCardArtToken(digitalCardArtToken: String) = apply {
this.digitalCardArtToken = digitalCardArtToken
}
/**
* Two digit (MM) expiry month. If neither `exp_month` nor `exp_year` is provided, an
* expiration date will be generated.
*/
fun expMonth(expMonth: String) = apply { this.expMonth = expMonth }
/**
* Four digit (yyyy) expiry year. If neither `exp_month` nor `exp_year` is provided, an
* expiration date will be generated.
*/
fun expYear(expYear: String) = apply { this.expYear = expYear }
/**
* Friendly name to identify the card. We recommend against using this field to store JSON
* data as it can cause unexpected behavior.
*/
fun memo(memo: String) = apply { this.memo = memo }
/**
* Encrypted PIN block (in base64). Only applies to cards of type `PHYSICAL` and `VIRTUAL`.
* See [Encrypted PIN Block](https://docs.lithic.com/docs/cards#encrypted-pin-block).
*/
fun pin(pin: String) = apply { this.pin = pin }
/**
* Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic before
* use. Specifies the configuration (i.e., physical card art) that the card should be
* manufactured with.
*/
fun productId(productId: String) = apply { this.productId = productId }
/**
* Only applicable to cards of type `PHYSICAL`. Globally unique identifier for the card that
* this physical card will replace.
*/
fun replacementFor(replacementFor: String) = apply { this.replacementFor = replacementFor }
fun shippingAddress(shippingAddress: ShippingAddress) = apply {
this.shippingAddress = shippingAddress
}
/**
* Shipping method for the card. Only applies to cards of type PHYSICAL. Use of options
* besides `STANDARD` require additional permissions.
* - `STANDARD` - USPS regular mail or similar international option, with no tracking
* - `STANDARD_WITH_TRACKING` - USPS regular mail or similar international option, with
* tracking
* - `PRIORITY` - USPS Priority, 1-3 day shipping, with tracking
* - `EXPRESS` - FedEx Express, 3-day shipping, with tracking
* - `2_DAY` - FedEx 2-day shipping, with tracking
* - `EXPEDITED` - FedEx Standard Overnight or similar international option, with tracking
*/
fun shippingMethod(shippingMethod: ShippingMethod) = apply {
this.shippingMethod = shippingMethod
}
/**
* Amount (in cents) to limit approved authorizations. Transaction requests above the spend
* limit will be declined. Note that a spend limit of 0 is effectively no limit, and should
* only be used to reset or remove a prior limit. Only a limit of 1 or above will result in
* declined transactions due to checks against the card limit.
*/
fun spendLimit(spendLimit: Long) = apply { this.spendLimit = spendLimit }
/**
* Spend limit duration values:
* - `ANNUALLY` - Card will authorize transactions up to spend limit for the trailing year.
* - `FOREVER` - Card will authorize only up to spend limit for the entire lifetime of the
* card.
* - `MONTHLY` - Card will authorize transactions up to spend limit for the trailing month.
* To support recurring monthly payments, which can occur on different day every month,
* the time window we consider for monthly velocity starts 6 days after the current
* calendar date one month prior.
* - `TRANSACTION` - Card will authorize multiple transactions if each individual
* transaction is under the spend limit.
*/
fun spendLimitDuration(spendLimitDuration: SpendLimitDuration) = apply {
this.spendLimitDuration = spendLimitDuration
}
/**
* Card state values:
* - `OPEN` - Card will approve authorizations (if they match card and account parameters).
* - `PAUSED` - Card will decline authorizations, but can be resumed at a later time.
*/
fun state(state: State) = apply { this.state = state }
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(): CardCreateParams =
CardCreateParams(
checkNotNull(type) { "`type` is required but was not set" },
accountToken,
cardProgramToken,
carrier,
digitalCardArtToken,
expMonth,
expYear,
memo,
pin,
productId,
replacementFor,
shippingAddress,
shippingMethod,
spendLimit,
spendLimitDuration,
state,
additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
additionalBodyProperties.toUnmodifiable(),
)
}
class Type
@JsonCreator
private constructor(
private val value: JsonField,
) : Enum {
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return other is Type && this.value == other.value
}
override fun hashCode() = value.hashCode()
override fun toString() = value.toString()
companion object {
val MERCHANT_LOCKED = Type(JsonField.of("MERCHANT_LOCKED"))
val PHYSICAL = Type(JsonField.of("PHYSICAL"))
val SINGLE_USE = Type(JsonField.of("SINGLE_USE"))
val VIRTUAL = Type(JsonField.of("VIRTUAL"))
fun of(value: String) = Type(JsonField.of(value))
}
enum class Known {
MERCHANT_LOCKED,
PHYSICAL,
SINGLE_USE,
VIRTUAL,
}
enum class Value {
MERCHANT_LOCKED,
PHYSICAL,
SINGLE_USE,
VIRTUAL,
_UNKNOWN,
}
fun value(): Value =
when (this) {
MERCHANT_LOCKED -> Value.MERCHANT_LOCKED
PHYSICAL -> Value.PHYSICAL
SINGLE_USE -> Value.SINGLE_USE
VIRTUAL -> Value.VIRTUAL
else -> Value._UNKNOWN
}
fun known(): Known =
when (this) {
MERCHANT_LOCKED -> Known.MERCHANT_LOCKED
PHYSICAL -> Known.PHYSICAL
SINGLE_USE -> Known.SINGLE_USE
VIRTUAL -> Known.VIRTUAL
else -> throw LithicInvalidDataException("Unknown Type: $value")
}
fun asString(): String = _value().asStringOrThrow()
}
class ShippingMethod
@JsonCreator
private constructor(
private val value: JsonField,
) : Enum {
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return other is ShippingMethod && this.value == other.value
}
override fun hashCode() = value.hashCode()
override fun toString() = value.toString()
companion object {
val _2_DAY = ShippingMethod(JsonField.of("2_DAY"))
val EXPEDITED = ShippingMethod(JsonField.of("EXPEDITED"))
val EXPRESS = ShippingMethod(JsonField.of("EXPRESS"))
val PRIORITY = ShippingMethod(JsonField.of("PRIORITY"))
val STANDARD = ShippingMethod(JsonField.of("STANDARD"))
val STANDARD_WITH_TRACKING = ShippingMethod(JsonField.of("STANDARD_WITH_TRACKING"))
fun of(value: String) = ShippingMethod(JsonField.of(value))
}
enum class Known {
_2_DAY,
EXPEDITED,
EXPRESS,
PRIORITY,
STANDARD,
STANDARD_WITH_TRACKING,
}
enum class Value {
_2_DAY,
EXPEDITED,
EXPRESS,
PRIORITY,
STANDARD,
STANDARD_WITH_TRACKING,
_UNKNOWN,
}
fun value(): Value =
when (this) {
_2_DAY -> Value._2_DAY
EXPEDITED -> Value.EXPEDITED
EXPRESS -> Value.EXPRESS
PRIORITY -> Value.PRIORITY
STANDARD -> Value.STANDARD
STANDARD_WITH_TRACKING -> Value.STANDARD_WITH_TRACKING
else -> Value._UNKNOWN
}
fun known(): Known =
when (this) {
_2_DAY -> Known._2_DAY
EXPEDITED -> Known.EXPEDITED
EXPRESS -> Known.EXPRESS
PRIORITY -> Known.PRIORITY
STANDARD -> Known.STANDARD
STANDARD_WITH_TRACKING -> Known.STANDARD_WITH_TRACKING
else -> throw LithicInvalidDataException("Unknown ShippingMethod: $value")
}
fun asString(): String = _value().asStringOrThrow()
}
class State
@JsonCreator
private constructor(
private val value: JsonField,
) : Enum {
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return other is State && this.value == other.value
}
override fun hashCode() = value.hashCode()
override fun toString() = value.toString()
companion object {
val OPEN = State(JsonField.of("OPEN"))
val PAUSED = State(JsonField.of("PAUSED"))
fun of(value: String) = State(JsonField.of(value))
}
enum class Known {
OPEN,
PAUSED,
}
enum class Value {
OPEN,
PAUSED,
_UNKNOWN,
}
fun value(): Value =
when (this) {
OPEN -> Value.OPEN
PAUSED -> Value.PAUSED
else -> Value._UNKNOWN
}
fun known(): Known =
when (this) {
OPEN -> Known.OPEN
PAUSED -> Known.PAUSED
else -> throw LithicInvalidDataException("Unknown State: $value")
}
fun asString(): String = _value().asStringOrThrow()
}
}