Skip to content

Commit

Permalink
feat(api): add 'pin status' and 'pending_commands' to Card model (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Aug 28, 2024
1 parent 6ca2c7d commit f2968c7
Show file tree
Hide file tree
Showing 7 changed files with 241 additions and 9 deletions.
137 changes: 136 additions & 1 deletion lithic-java-core/src/main/kotlin/com/lithic/api/models/Card.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ private constructor(
private val lastFour: JsonField<String>,
private val memo: JsonField<String>,
private val pan: JsonField<String>,
private val pendingCommands: JsonField<List<String>>,
private val pinStatus: JsonField<PinStatus>,
private val productId: JsonField<String>,
private val spendLimit: JsonField<Long>,
private val spendLimitDuration: JsonField<SpendLimitDuration>,
Expand Down Expand Up @@ -112,6 +114,19 @@ private constructor(
*/
fun pan(): Optional<String> = Optional.ofNullable(pan.getNullable("pan"))

/**
* Indicates if there are offline PIN changes pending card interaction with an offline PIN
* terminal. Possible commands are: CHANGE_PIN, UNBLOCK_PIN. Applicable only to cards issued in
* markets supporting offline PINs.
*/
fun pendingCommands(): Optional<List<String>> =
Optional.ofNullable(pendingCommands.getNullable("pending_commands"))

/**
* Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect attempts).
*/
fun pinStatus(): PinStatus = pinStatus.getRequired("pin_status")

/**
* 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
Expand Down Expand Up @@ -237,6 +252,18 @@ private constructor(
*/
@JsonProperty("pan") @ExcludeMissing fun _pan() = pan

/**
* Indicates if there are offline PIN changes pending card interaction with an offline PIN
* terminal. Possible commands are: CHANGE_PIN, UNBLOCK_PIN. Applicable only to cards issued in
* markets supporting offline PINs.
*/
@JsonProperty("pending_commands") @ExcludeMissing fun _pendingCommands() = pendingCommands

/**
* Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect attempts).
*/
@JsonProperty("pin_status") @ExcludeMissing fun _pinStatus() = pinStatus

/**
* 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
Expand Down Expand Up @@ -320,6 +347,8 @@ private constructor(
lastFour()
memo()
pan()
pendingCommands()
pinStatus()
productId()
spendLimit()
spendLimitDuration()
Expand Down Expand Up @@ -352,6 +381,8 @@ private constructor(
this.lastFour == other.lastFour &&
this.memo == other.memo &&
this.pan == other.pan &&
this.pendingCommands == other.pendingCommands &&
this.pinStatus == other.pinStatus &&
this.productId == other.productId &&
this.spendLimit == other.spendLimit &&
this.spendLimitDuration == other.spendLimitDuration &&
Expand Down Expand Up @@ -379,6 +410,8 @@ private constructor(
lastFour,
memo,
pan,
pendingCommands,
pinStatus,
productId,
spendLimit,
spendLimitDuration,
Expand All @@ -392,7 +425,7 @@ private constructor(
}

override fun toString() =
"Card{accountToken=$accountToken, authRuleTokens=$authRuleTokens, cardProgramToken=$cardProgramToken, cardholderCurrency=$cardholderCurrency, created=$created, cvv=$cvv, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, funding=$funding, hostname=$hostname, lastFour=$lastFour, memo=$memo, pan=$pan, productId=$productId, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, token=$token, type=$type, additionalProperties=$additionalProperties}"
"Card{accountToken=$accountToken, authRuleTokens=$authRuleTokens, cardProgramToken=$cardProgramToken, cardholderCurrency=$cardholderCurrency, created=$created, cvv=$cvv, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, funding=$funding, hostname=$hostname, lastFour=$lastFour, memo=$memo, pan=$pan, pendingCommands=$pendingCommands, pinStatus=$pinStatus, productId=$productId, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, token=$token, type=$type, additionalProperties=$additionalProperties}"

companion object {

Expand All @@ -415,6 +448,8 @@ private constructor(
private var lastFour: JsonField<String> = JsonMissing.of()
private var memo: JsonField<String> = JsonMissing.of()
private var pan: JsonField<String> = JsonMissing.of()
private var pendingCommands: JsonField<List<String>> = JsonMissing.of()
private var pinStatus: JsonField<PinStatus> = JsonMissing.of()
private var productId: JsonField<String> = JsonMissing.of()
private var spendLimit: JsonField<Long> = JsonMissing.of()
private var spendLimitDuration: JsonField<SpendLimitDuration> = JsonMissing.of()
Expand All @@ -439,6 +474,8 @@ private constructor(
this.lastFour = card.lastFour
this.memo = card.memo
this.pan = card.pan
this.pendingCommands = card.pendingCommands
this.pinStatus = card.pinStatus
this.productId = card.productId
this.spendLimit = card.spendLimit
this.spendLimitDuration = card.spendLimitDuration
Expand Down Expand Up @@ -608,6 +645,39 @@ private constructor(
@ExcludeMissing
fun pan(pan: JsonField<String>) = apply { this.pan = pan }

/**
* Indicates if there are offline PIN changes pending card interaction with an offline PIN
* terminal. Possible commands are: CHANGE_PIN, UNBLOCK_PIN. Applicable only to cards issued
* in markets supporting offline PINs.
*/
fun pendingCommands(pendingCommands: List<String>) =
pendingCommands(JsonField.of(pendingCommands))

/**
* Indicates if there are offline PIN changes pending card interaction with an offline PIN
* terminal. Possible commands are: CHANGE_PIN, UNBLOCK_PIN. Applicable only to cards issued
* in markets supporting offline PINs.
*/
@JsonProperty("pending_commands")
@ExcludeMissing
fun pendingCommands(pendingCommands: JsonField<List<String>>) = apply {
this.pendingCommands = pendingCommands
}

/**
* Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect
* attempts).
*/
fun pinStatus(pinStatus: PinStatus) = pinStatus(JsonField.of(pinStatus))

/**
* Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect
* attempts).
*/
@JsonProperty("pin_status")
@ExcludeMissing
fun pinStatus(pinStatus: JsonField<PinStatus>) = apply { this.pinStatus = pinStatus }

/**
* 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
Expand Down Expand Up @@ -779,6 +849,8 @@ private constructor(
lastFour,
memo,
pan,
pendingCommands.map { it.toUnmodifiable() },
pinStatus,
productId,
spendLimit,
spendLimitDuration,
Expand Down Expand Up @@ -1214,6 +1286,69 @@ private constructor(
}
}

class PinStatus
@JsonCreator
private constructor(
private val value: JsonField<String>,
) : Enum {

@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value

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

return other is PinStatus && this.value == other.value
}

override fun hashCode() = value.hashCode()

override fun toString() = value.toString()

companion object {

@JvmField val OK = PinStatus(JsonField.of("OK"))

@JvmField val BLOCKED = PinStatus(JsonField.of("BLOCKED"))

@JvmField val NOT_SET = PinStatus(JsonField.of("NOT_SET"))

@JvmStatic fun of(value: String) = PinStatus(JsonField.of(value))
}

enum class Known {
OK,
BLOCKED,
NOT_SET,
}

enum class Value {
OK,
BLOCKED,
NOT_SET,
_UNKNOWN,
}

fun value(): Value =
when (this) {
OK -> Value.OK
BLOCKED -> Value.BLOCKED
NOT_SET -> Value.NOT_SET
else -> Value._UNKNOWN
}

fun known(): Known =
when (this) {
OK -> Known.OK
BLOCKED -> Known.BLOCKED
NOT_SET -> Known.NOT_SET
else -> throw LithicInvalidDataException("Unknown PinStatus: $value")
}

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

class State
@JsonCreator
private constructor(
Expand Down
Loading

0 comments on commit f2968c7

Please sign in to comment.