Skip to content

Commit f2968c7

Browse files
feat(api): add 'pin status' and 'pending_commands' to Card model (#292)
1 parent 6ca2c7d commit f2968c7

File tree

7 files changed

+241
-9
lines changed

7 files changed

+241
-9
lines changed

lithic-java-core/src/main/kotlin/com/lithic/api/models/Card.kt

Lines changed: 136 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ private constructor(
3737
private val lastFour: JsonField<String>,
3838
private val memo: JsonField<String>,
3939
private val pan: JsonField<String>,
40+
private val pendingCommands: JsonField<List<String>>,
41+
private val pinStatus: JsonField<PinStatus>,
4042
private val productId: JsonField<String>,
4143
private val spendLimit: JsonField<Long>,
4244
private val spendLimitDuration: JsonField<SpendLimitDuration>,
@@ -112,6 +114,19 @@ private constructor(
112114
*/
113115
fun pan(): Optional<String> = Optional.ofNullable(pan.getNullable("pan"))
114116

117+
/**
118+
* Indicates if there are offline PIN changes pending card interaction with an offline PIN
119+
* terminal. Possible commands are: CHANGE_PIN, UNBLOCK_PIN. Applicable only to cards issued in
120+
* markets supporting offline PINs.
121+
*/
122+
fun pendingCommands(): Optional<List<String>> =
123+
Optional.ofNullable(pendingCommands.getNullable("pending_commands"))
124+
125+
/**
126+
* Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect attempts).
127+
*/
128+
fun pinStatus(): PinStatus = pinStatus.getRequired("pin_status")
129+
115130
/**
116131
* Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic before use.
117132
* Specifies the configuration (i.e., physical card art) that the card should be manufactured
@@ -237,6 +252,18 @@ private constructor(
237252
*/
238253
@JsonProperty("pan") @ExcludeMissing fun _pan() = pan
239254

255+
/**
256+
* Indicates if there are offline PIN changes pending card interaction with an offline PIN
257+
* terminal. Possible commands are: CHANGE_PIN, UNBLOCK_PIN. Applicable only to cards issued in
258+
* markets supporting offline PINs.
259+
*/
260+
@JsonProperty("pending_commands") @ExcludeMissing fun _pendingCommands() = pendingCommands
261+
262+
/**
263+
* Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect attempts).
264+
*/
265+
@JsonProperty("pin_status") @ExcludeMissing fun _pinStatus() = pinStatus
266+
240267
/**
241268
* Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic before use.
242269
* Specifies the configuration (i.e., physical card art) that the card should be manufactured
@@ -320,6 +347,8 @@ private constructor(
320347
lastFour()
321348
memo()
322349
pan()
350+
pendingCommands()
351+
pinStatus()
323352
productId()
324353
spendLimit()
325354
spendLimitDuration()
@@ -352,6 +381,8 @@ private constructor(
352381
this.lastFour == other.lastFour &&
353382
this.memo == other.memo &&
354383
this.pan == other.pan &&
384+
this.pendingCommands == other.pendingCommands &&
385+
this.pinStatus == other.pinStatus &&
355386
this.productId == other.productId &&
356387
this.spendLimit == other.spendLimit &&
357388
this.spendLimitDuration == other.spendLimitDuration &&
@@ -379,6 +410,8 @@ private constructor(
379410
lastFour,
380411
memo,
381412
pan,
413+
pendingCommands,
414+
pinStatus,
382415
productId,
383416
spendLimit,
384417
spendLimitDuration,
@@ -392,7 +425,7 @@ private constructor(
392425
}
393426

394427
override fun toString() =
395-
"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}"
428+
"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}"
396429

397430
companion object {
398431

@@ -415,6 +448,8 @@ private constructor(
415448
private var lastFour: JsonField<String> = JsonMissing.of()
416449
private var memo: JsonField<String> = JsonMissing.of()
417450
private var pan: JsonField<String> = JsonMissing.of()
451+
private var pendingCommands: JsonField<List<String>> = JsonMissing.of()
452+
private var pinStatus: JsonField<PinStatus> = JsonMissing.of()
418453
private var productId: JsonField<String> = JsonMissing.of()
419454
private var spendLimit: JsonField<Long> = JsonMissing.of()
420455
private var spendLimitDuration: JsonField<SpendLimitDuration> = JsonMissing.of()
@@ -439,6 +474,8 @@ private constructor(
439474
this.lastFour = card.lastFour
440475
this.memo = card.memo
441476
this.pan = card.pan
477+
this.pendingCommands = card.pendingCommands
478+
this.pinStatus = card.pinStatus
442479
this.productId = card.productId
443480
this.spendLimit = card.spendLimit
444481
this.spendLimitDuration = card.spendLimitDuration
@@ -608,6 +645,39 @@ private constructor(
608645
@ExcludeMissing
609646
fun pan(pan: JsonField<String>) = apply { this.pan = pan }
610647

648+
/**
649+
* Indicates if there are offline PIN changes pending card interaction with an offline PIN
650+
* terminal. Possible commands are: CHANGE_PIN, UNBLOCK_PIN. Applicable only to cards issued
651+
* in markets supporting offline PINs.
652+
*/
653+
fun pendingCommands(pendingCommands: List<String>) =
654+
pendingCommands(JsonField.of(pendingCommands))
655+
656+
/**
657+
* Indicates if there are offline PIN changes pending card interaction with an offline PIN
658+
* terminal. Possible commands are: CHANGE_PIN, UNBLOCK_PIN. Applicable only to cards issued
659+
* in markets supporting offline PINs.
660+
*/
661+
@JsonProperty("pending_commands")
662+
@ExcludeMissing
663+
fun pendingCommands(pendingCommands: JsonField<List<String>>) = apply {
664+
this.pendingCommands = pendingCommands
665+
}
666+
667+
/**
668+
* Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect
669+
* attempts).
670+
*/
671+
fun pinStatus(pinStatus: PinStatus) = pinStatus(JsonField.of(pinStatus))
672+
673+
/**
674+
* Indicates if a card is blocked due a PIN status issue (e.g. excessive incorrect
675+
* attempts).
676+
*/
677+
@JsonProperty("pin_status")
678+
@ExcludeMissing
679+
fun pinStatus(pinStatus: JsonField<PinStatus>) = apply { this.pinStatus = pinStatus }
680+
611681
/**
612682
* Only applicable to cards of type `PHYSICAL`. This must be configured with Lithic before
613683
* use. Specifies the configuration (i.e., physical card art) that the card should be
@@ -779,6 +849,8 @@ private constructor(
779849
lastFour,
780850
memo,
781851
pan,
852+
pendingCommands.map { it.toUnmodifiable() },
853+
pinStatus,
782854
productId,
783855
spendLimit,
784856
spendLimitDuration,
@@ -1214,6 +1286,69 @@ private constructor(
12141286
}
12151287
}
12161288

1289+
class PinStatus
1290+
@JsonCreator
1291+
private constructor(
1292+
private val value: JsonField<String>,
1293+
) : Enum {
1294+
1295+
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value
1296+
1297+
override fun equals(other: Any?): Boolean {
1298+
if (this === other) {
1299+
return true
1300+
}
1301+
1302+
return other is PinStatus && this.value == other.value
1303+
}
1304+
1305+
override fun hashCode() = value.hashCode()
1306+
1307+
override fun toString() = value.toString()
1308+
1309+
companion object {
1310+
1311+
@JvmField val OK = PinStatus(JsonField.of("OK"))
1312+
1313+
@JvmField val BLOCKED = PinStatus(JsonField.of("BLOCKED"))
1314+
1315+
@JvmField val NOT_SET = PinStatus(JsonField.of("NOT_SET"))
1316+
1317+
@JvmStatic fun of(value: String) = PinStatus(JsonField.of(value))
1318+
}
1319+
1320+
enum class Known {
1321+
OK,
1322+
BLOCKED,
1323+
NOT_SET,
1324+
}
1325+
1326+
enum class Value {
1327+
OK,
1328+
BLOCKED,
1329+
NOT_SET,
1330+
_UNKNOWN,
1331+
}
1332+
1333+
fun value(): Value =
1334+
when (this) {
1335+
OK -> Value.OK
1336+
BLOCKED -> Value.BLOCKED
1337+
NOT_SET -> Value.NOT_SET
1338+
else -> Value._UNKNOWN
1339+
}
1340+
1341+
fun known(): Known =
1342+
when (this) {
1343+
OK -> Known.OK
1344+
BLOCKED -> Known.BLOCKED
1345+
NOT_SET -> Known.NOT_SET
1346+
else -> throw LithicInvalidDataException("Unknown PinStatus: $value")
1347+
}
1348+
1349+
fun asString(): String = _value().asStringOrThrow()
1350+
}
1351+
12171352
class State
12181353
@JsonCreator
12191354
private constructor(

0 commit comments

Comments
 (0)