Skip to content

Commit

Permalink
feat(api): add account_token and card_program_token to Card (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Jan 31, 2024
1 parent dab86a7 commit 0d6a220
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
49 changes: 48 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 @@ -22,7 +22,9 @@ import java.util.Optional
@NoAutoDetect
class Card
private constructor(
private val accountToken: JsonField<String>,
private val authRuleTokens: JsonField<List<String>>,
private val cardProgramToken: JsonField<String>,
private val created: JsonField<OffsetDateTime>,
private val cvv: JsonField<String>,
private val digitalCardArtToken: JsonField<String>,
Expand All @@ -45,10 +47,16 @@ private constructor(

private var hashCode: Int = 0

/** Globally unique identifier for the account to which the card belongs. */
fun accountToken(): String = accountToken.getRequired("account_token")

/** List of identifiers for the Auth Rule(s) that are applied on the card. */
fun authRuleTokens(): Optional<List<String>> =
Optional.ofNullable(authRuleTokens.getNullable("auth_rule_tokens"))

/** Globally unique identifier for the card program on which the card exists. */
fun cardProgramToken(): String = cardProgramToken.getRequired("card_program_token")

/** An RFC 3339 timestamp for when the card was created. UTC time zone. */
fun created(): OffsetDateTime = created.getRequired("created")

Expand Down Expand Up @@ -148,9 +156,15 @@ private constructor(
*/
fun type(): Type = type.getRequired("type")

/** Globally unique identifier for the account to which the card belongs. */
@JsonProperty("account_token") @ExcludeMissing fun _accountToken() = accountToken

/** List of identifiers for the Auth Rule(s) that are applied on the card. */
@JsonProperty("auth_rule_tokens") @ExcludeMissing fun _authRuleTokens() = authRuleTokens

/** Globally unique identifier for the card program on which the card exists. */
@JsonProperty("card_program_token") @ExcludeMissing fun _cardProgramToken() = cardProgramToken

/** An RFC 3339 timestamp for when the card was created. UTC time zone. */
@JsonProperty("created") @ExcludeMissing fun _created() = created

Expand Down Expand Up @@ -258,7 +272,9 @@ private constructor(

fun validate(): Card = apply {
if (!validated) {
accountToken()
authRuleTokens()
cardProgramToken()
created()
cvv()
digitalCardArtToken()
Expand Down Expand Up @@ -286,7 +302,9 @@ private constructor(
}

return other is Card &&
this.accountToken == other.accountToken &&
this.authRuleTokens == other.authRuleTokens &&
this.cardProgramToken == other.cardProgramToken &&
this.created == other.created &&
this.cvv == other.cvv &&
this.digitalCardArtToken == other.digitalCardArtToken &&
Expand All @@ -309,7 +327,9 @@ private constructor(
if (hashCode == 0) {
hashCode =
Objects.hash(
accountToken,
authRuleTokens,
cardProgramToken,
created,
cvv,
digitalCardArtToken,
Expand All @@ -332,7 +352,7 @@ private constructor(
}

override fun toString() =
"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}"
"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}"

companion object {

Expand All @@ -341,7 +361,9 @@ private constructor(

class Builder {

private var accountToken: JsonField<String> = JsonMissing.of()
private var authRuleTokens: JsonField<List<String>> = JsonMissing.of()
private var cardProgramToken: JsonField<String> = JsonMissing.of()
private var created: JsonField<OffsetDateTime> = JsonMissing.of()
private var cvv: JsonField<String> = JsonMissing.of()
private var digitalCardArtToken: JsonField<String> = JsonMissing.of()
Expand All @@ -361,7 +383,9 @@ private constructor(

@JvmSynthetic
internal fun from(card: Card) = apply {
this.accountToken = card.accountToken
this.authRuleTokens = card.authRuleTokens
this.cardProgramToken = card.cardProgramToken
this.created = card.created
this.cvv = card.cvv
this.digitalCardArtToken = card.digitalCardArtToken
Expand All @@ -380,6 +404,16 @@ private constructor(
additionalProperties(card.additionalProperties)
}

/** Globally unique identifier for the account to which the card belongs. */
fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken))

/** Globally unique identifier for the account to which the card belongs. */
@JsonProperty("account_token")
@ExcludeMissing
fun accountToken(accountToken: JsonField<String>) = apply {
this.accountToken = accountToken
}

/** List of identifiers for the Auth Rule(s) that are applied on the card. */
fun authRuleTokens(authRuleTokens: List<String>) =
authRuleTokens(JsonField.of(authRuleTokens))
Expand All @@ -391,6 +425,17 @@ private constructor(
this.authRuleTokens = authRuleTokens
}

/** Globally unique identifier for the card program on which the card exists. */
fun cardProgramToken(cardProgramToken: String) =
cardProgramToken(JsonField.of(cardProgramToken))

/** Globally unique identifier for the card program on which the card exists. */
@JsonProperty("card_program_token")
@ExcludeMissing
fun cardProgramToken(cardProgramToken: JsonField<String>) = apply {
this.cardProgramToken = cardProgramToken
}

/** An RFC 3339 timestamp for when the card was created. UTC time zone. */
fun created(created: OffsetDateTime) = created(JsonField.of(created))

Expand Down Expand Up @@ -641,7 +686,9 @@ private constructor(

fun build(): Card =
Card(
accountToken,
authRuleTokens.map { it.toUnmodifiable() },
cardProgramToken,
created,
cvv,
digitalCardArtToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class CardTest {
val card =
Card.builder()
.token("7ef7d65c-9023-4da3-b113-3b8583fd7951")
.accountToken("f3f4918c-dee9-464d-a819-4aa42901d624")
.cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca")
.created(OffsetDateTime.parse("2021-06-28T22:53:15Z"))
.funding(
Card.FundingAccount.builder()
Expand Down Expand Up @@ -41,6 +43,8 @@ class CardTest {
.build()
assertThat(card).isNotNull
assertThat(card.token()).isEqualTo("7ef7d65c-9023-4da3-b113-3b8583fd7951")
assertThat(card.accountToken()).isEqualTo("f3f4918c-dee9-464d-a819-4aa42901d624")
assertThat(card.cardProgramToken()).isEqualTo("5e9483eb-8103-4e16-9794-2106111b2eca")
assertThat(card.created()).isEqualTo(OffsetDateTime.parse("2021-06-28T22:53:15Z"))
assertThat(card.funding())
.isEqualTo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class ErrorHandlingTest {
val expected =
Card.builder()
.token("7ef7d65c-9023-4da3-b113-3b8583fd7951")
.accountToken("f3f4918c-dee9-464d-a819-4aa42901d624")
.cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca")
.created(OffsetDateTime.parse("2021-06-28T22:53:15Z"))
.funding(
Card.FundingAccount.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class ServiceParamsTest {
val apiResponse =
Card.builder()
.token("7ef7d65c-9023-4da3-b113-3b8583fd7951")
.accountToken("f3f4918c-dee9-464d-a819-4aa42901d624")
.cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca")
.created(OffsetDateTime.parse("2021-06-28T22:53:15Z"))
.funding(
Card.FundingAccount.builder()
Expand Down

0 comments on commit 0d6a220

Please sign in to comment.