Skip to content

Commit 985fd9d

Browse files
stainless-botstainless-app[bot]
authored andcommitted
feat(api): add account_token and card_program_token to Card (#150)
1 parent dab86a7 commit 985fd9d

4 files changed

Lines changed: 56 additions & 1 deletion

File tree

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

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import java.util.Optional
2222
@NoAutoDetect
2323
class Card
2424
private constructor(
25+
private val accountToken: JsonField<String>,
2526
private val authRuleTokens: JsonField<List<String>>,
27+
private val cardProgramToken: JsonField<String>,
2628
private val created: JsonField<OffsetDateTime>,
2729
private val cvv: JsonField<String>,
2830
private val digitalCardArtToken: JsonField<String>,
@@ -45,10 +47,16 @@ private constructor(
4547

4648
private var hashCode: Int = 0
4749

50+
/** Globally unique identifier for the account to which the card belongs. */
51+
fun accountToken(): String = accountToken.getRequired("account_token")
52+
4853
/** List of identifiers for the Auth Rule(s) that are applied on the card. */
4954
fun authRuleTokens(): Optional<List<String>> =
5055
Optional.ofNullable(authRuleTokens.getNullable("auth_rule_tokens"))
5156

57+
/** Globally unique identifier for the card program on which the card exists. */
58+
fun cardProgramToken(): String = cardProgramToken.getRequired("card_program_token")
59+
5260
/** An RFC 3339 timestamp for when the card was created. UTC time zone. */
5361
fun created(): OffsetDateTime = created.getRequired("created")
5462

@@ -148,9 +156,15 @@ private constructor(
148156
*/
149157
fun type(): Type = type.getRequired("type")
150158

159+
/** Globally unique identifier for the account to which the card belongs. */
160+
@JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken
161+
151162
/** List of identifiers for the Auth Rule(s) that are applied on the card. */
152163
@JsonProperty("auth_rule_tokens") @ExcludeMissing fun _authRuleTokens() = authRuleTokens
153164

165+
/** Globally unique identifier for the card program on which the card exists. */
166+
@JsonProperty("card_program_token") @ExcludeMissing fun _cardProgramToken() = cardProgramToken
167+
154168
/** An RFC 3339 timestamp for when the card was created. UTC time zone. */
155169
@JsonProperty("created") @ExcludeMissing fun _created() = created
156170

@@ -258,7 +272,9 @@ private constructor(
258272

259273
fun validate(): Card = apply {
260274
if (!validated) {
275+
accountToken()
261276
authRuleTokens()
277+
cardProgramToken()
262278
created()
263279
cvv()
264280
digitalCardArtToken()
@@ -286,7 +302,9 @@ private constructor(
286302
}
287303

288304
return other is Card &&
305+
this.accountToken == other.accountToken &&
289306
this.authRuleTokens == other.authRuleTokens &&
307+
this.cardProgramToken == other.cardProgramToken &&
290308
this.created == other.created &&
291309
this.cvv == other.cvv &&
292310
this.digitalCardArtToken == other.digitalCardArtToken &&
@@ -309,7 +327,9 @@ private constructor(
309327
if (hashCode == 0) {
310328
hashCode =
311329
Objects.hash(
330+
accountToken,
312331
authRuleTokens,
332+
cardProgramToken,
313333
created,
314334
cvv,
315335
digitalCardArtToken,
@@ -332,7 +352,7 @@ private constructor(
332352
}
333353

334354
override fun toString() =
335-
"Card{authRuleTokens=$authRuleTokens, created=$created, cvv=$cvv, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, funding=$funding, hostname=$hostname, lastFour=$lastFour, memo=$memo, pan=$pan, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, token=$token, type=$type, additionalProperties=$additionalProperties}"
355+
"Card{accountToken=$accountToken, authRuleTokens=$authRuleTokens, cardProgramToken=$cardProgramToken, created=$created, cvv=$cvv, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, funding=$funding, hostname=$hostname, lastFour=$lastFour, memo=$memo, pan=$pan, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, token=$token, type=$type, additionalProperties=$additionalProperties}"
336356

337357
companion object {
338358

@@ -341,7 +361,9 @@ private constructor(
341361

342362
class Builder {
343363

364+
private var accountToken: JsonField<String> = JsonMissing.of()
344365
private var authRuleTokens: JsonField<List<String>> = JsonMissing.of()
366+
private var cardProgramToken: JsonField<String> = JsonMissing.of()
345367
private var created: JsonField<OffsetDateTime> = JsonMissing.of()
346368
private var cvv: JsonField<String> = JsonMissing.of()
347369
private var digitalCardArtToken: JsonField<String> = JsonMissing.of()
@@ -361,7 +383,9 @@ private constructor(
361383

362384
@JvmSynthetic
363385
internal fun from(card: Card) = apply {
386+
this.accountToken = card.accountToken
364387
this.authRuleTokens = card.authRuleTokens
388+
this.cardProgramToken = card.cardProgramToken
365389
this.created = card.created
366390
this.cvv = card.cvv
367391
this.digitalCardArtToken = card.digitalCardArtToken
@@ -380,6 +404,16 @@ private constructor(
380404
additionalProperties(card.additionalProperties)
381405
}
382406

407+
/** Globally unique identifier for the account to which the card belongs. */
408+
fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken))
409+
410+
/** Globally unique identifier for the account to which the card belongs. */
411+
@JsonProperty("account_token")
412+
@ExcludeMissing
413+
fun accountToken(accountToken: JsonField<String>) = apply {
414+
this.accountToken = accountToken
415+
}
416+
383417
/** List of identifiers for the Auth Rule(s) that are applied on the card. */
384418
fun authRuleTokens(authRuleTokens: List<String>) =
385419
authRuleTokens(JsonField.of(authRuleTokens))
@@ -391,6 +425,17 @@ private constructor(
391425
this.authRuleTokens = authRuleTokens
392426
}
393427

428+
/** Globally unique identifier for the card program on which the card exists. */
429+
fun cardProgramToken(cardProgramToken: String) =
430+
cardProgramToken(JsonField.of(cardProgramToken))
431+
432+
/** Globally unique identifier for the card program on which the card exists. */
433+
@JsonProperty("card_program_token")
434+
@ExcludeMissing
435+
fun cardProgramToken(cardProgramToken: JsonField<String>) = apply {
436+
this.cardProgramToken = cardProgramToken
437+
}
438+
394439
/** An RFC 3339 timestamp for when the card was created. UTC time zone. */
395440
fun created(created: OffsetDateTime) = created(JsonField.of(created))
396441

@@ -641,7 +686,9 @@ private constructor(
641686

642687
fun build(): Card =
643688
Card(
689+
accountToken,
644690
authRuleTokens.map { it.toUnmodifiable() },
691+
cardProgramToken,
645692
created,
646693
cvv,
647694
digitalCardArtToken,

lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class CardTest {
1313
val card =
1414
Card.builder()
1515
.token("7ef7d65c-9023-4da3-b113-3b8583fd7951")
16+
.accountToken("f3f4918c-dee9-464d-a819-4aa42901d624")
17+
.cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca")
1618
.created(OffsetDateTime.parse("2021-06-28T22:53:15Z"))
1719
.funding(
1820
Card.FundingAccount.builder()
@@ -41,6 +43,8 @@ class CardTest {
4143
.build()
4244
assertThat(card).isNotNull
4345
assertThat(card.token()).isEqualTo("7ef7d65c-9023-4da3-b113-3b8583fd7951")
46+
assertThat(card.accountToken()).isEqualTo("f3f4918c-dee9-464d-a819-4aa42901d624")
47+
assertThat(card.cardProgramToken()).isEqualTo("5e9483eb-8103-4e16-9794-2106111b2eca")
4448
assertThat(card.created()).isEqualTo(OffsetDateTime.parse("2021-06-28T22:53:15Z"))
4549
assertThat(card.funding())
4650
.isEqualTo(

lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ class ErrorHandlingTest {
9595
val expected =
9696
Card.builder()
9797
.token("7ef7d65c-9023-4da3-b113-3b8583fd7951")
98+
.accountToken("f3f4918c-dee9-464d-a819-4aa42901d624")
99+
.cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca")
98100
.created(OffsetDateTime.parse("2021-06-28T22:53:15Z"))
99101
.funding(
100102
Card.FundingAccount.builder()

lithic-java-core/src/test/kotlin/com/lithic/api/services/ServiceParamsTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ class ServiceParamsTest {
9595
val apiResponse =
9696
Card.builder()
9797
.token("7ef7d65c-9023-4da3-b113-3b8583fd7951")
98+
.accountToken("f3f4918c-dee9-464d-a819-4aa42901d624")
99+
.cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca")
98100
.created(OffsetDateTime.parse("2021-06-28T22:53:15Z"))
99101
.funding(
100102
Card.FundingAccount.builder()

0 commit comments

Comments
 (0)