Skip to content

Commit 8f9e6fa

Browse files
chore(api): adds charge_off functionality to FinancialAccounts (#362)
- adds `CHARGED_OFF` to `financial_account_states` property - adds `charged_off_reason` property - adds `charge_off` method
1 parent f9434bd commit 8f9e6fa

12 files changed

Lines changed: 685 additions & 17 deletions

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
configured_endpoints: 155
1+
configured_endpoints: 156

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

Lines changed: 109 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ private constructor(
258258
private val externalBankAccountToken: JsonField<String>,
259259
private val creditProductToken: JsonField<String>,
260260
private val tier: JsonField<String>,
261+
private val isSpendBlocked: JsonField<Boolean>,
261262
private val financialAccountState: JsonField<FinancialAccountState>,
263+
private val chargedOffReason: JsonField<ChargedOffReason>,
262264
private val additionalProperties: Map<String, JsonValue>,
263265
) {
264266

@@ -277,10 +279,16 @@ private constructor(
277279
/** Tier assigned to the financial account */
278280
fun tier(): Optional<String> = Optional.ofNullable(tier.getNullable("tier"))
279281

282+
fun isSpendBlocked(): Boolean = isSpendBlocked.getRequired("is_spend_blocked")
283+
280284
/** State of the financial account */
281285
fun financialAccountState(): Optional<FinancialAccountState> =
282286
Optional.ofNullable(financialAccountState.getNullable("financial_account_state"))
283287

288+
/** Reason for the financial account being marked as Charged Off */
289+
fun chargedOffReason(): Optional<ChargedOffReason> =
290+
Optional.ofNullable(chargedOffReason.getNullable("charged_off_reason"))
291+
284292
@JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit() = creditLimit
285293

286294
@JsonProperty("external_bank_account_token")
@@ -295,11 +303,18 @@ private constructor(
295303
/** Tier assigned to the financial account */
296304
@JsonProperty("tier") @ExcludeMissing fun _tier() = tier
297305

306+
@JsonProperty("is_spend_blocked") @ExcludeMissing fun _isSpendBlocked() = isSpendBlocked
307+
298308
/** State of the financial account */
299309
@JsonProperty("financial_account_state")
300310
@ExcludeMissing
301311
fun _financialAccountState() = financialAccountState
302312

313+
/** Reason for the financial account being marked as Charged Off */
314+
@JsonProperty("charged_off_reason")
315+
@ExcludeMissing
316+
fun _chargedOffReason() = chargedOffReason
317+
303318
@JsonAnyGetter
304319
@ExcludeMissing
305320
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
@@ -310,7 +325,9 @@ private constructor(
310325
externalBankAccountToken()
311326
creditProductToken()
312327
tier()
328+
isSpendBlocked()
313329
financialAccountState()
330+
chargedOffReason()
314331
validated = true
315332
}
316333
}
@@ -328,7 +345,9 @@ private constructor(
328345
private var externalBankAccountToken: JsonField<String> = JsonMissing.of()
329346
private var creditProductToken: JsonField<String> = JsonMissing.of()
330347
private var tier: JsonField<String> = JsonMissing.of()
348+
private var isSpendBlocked: JsonField<Boolean> = JsonMissing.of()
331349
private var financialAccountState: JsonField<FinancialAccountState> = JsonMissing.of()
350+
private var chargedOffReason: JsonField<ChargedOffReason> = JsonMissing.of()
332351
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
333352

334353
@JvmSynthetic
@@ -338,7 +357,9 @@ private constructor(
338357
financialAccountCreditConfig.externalBankAccountToken
339358
this.creditProductToken = financialAccountCreditConfig.creditProductToken
340359
this.tier = financialAccountCreditConfig.tier
360+
this.isSpendBlocked = financialAccountCreditConfig.isSpendBlocked
341361
this.financialAccountState = financialAccountCreditConfig.financialAccountState
362+
this.chargedOffReason = financialAccountCreditConfig.chargedOffReason
342363
additionalProperties(financialAccountCreditConfig.additionalProperties)
343364
}
344365

@@ -376,6 +397,15 @@ private constructor(
376397
@ExcludeMissing
377398
fun tier(tier: JsonField<String>) = apply { this.tier = tier }
378399

400+
fun isSpendBlocked(isSpendBlocked: Boolean) =
401+
isSpendBlocked(JsonField.of(isSpendBlocked))
402+
403+
@JsonProperty("is_spend_blocked")
404+
@ExcludeMissing
405+
fun isSpendBlocked(isSpendBlocked: JsonField<Boolean>) = apply {
406+
this.isSpendBlocked = isSpendBlocked
407+
}
408+
379409
/** State of the financial account */
380410
fun financialAccountState(financialAccountState: FinancialAccountState) =
381411
financialAccountState(JsonField.of(financialAccountState))
@@ -388,6 +418,17 @@ private constructor(
388418
this.financialAccountState = financialAccountState
389419
}
390420

421+
/** Reason for the financial account being marked as Charged Off */
422+
fun chargedOffReason(chargedOffReason: ChargedOffReason) =
423+
chargedOffReason(JsonField.of(chargedOffReason))
424+
425+
/** Reason for the financial account being marked as Charged Off */
426+
@JsonProperty("charged_off_reason")
427+
@ExcludeMissing
428+
fun chargedOffReason(chargedOffReason: JsonField<ChargedOffReason>) = apply {
429+
this.chargedOffReason = chargedOffReason
430+
}
431+
391432
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
392433
this.additionalProperties.clear()
393434
this.additionalProperties.putAll(additionalProperties)
@@ -408,11 +449,70 @@ private constructor(
408449
externalBankAccountToken,
409450
creditProductToken,
410451
tier,
452+
isSpendBlocked,
411453
financialAccountState,
454+
chargedOffReason,
412455
additionalProperties.toUnmodifiable(),
413456
)
414457
}
415458

459+
class ChargedOffReason
460+
@JsonCreator
461+
private constructor(
462+
private val value: JsonField<String>,
463+
) : Enum {
464+
465+
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value
466+
467+
override fun equals(other: Any?): Boolean {
468+
if (this === other) {
469+
return true
470+
}
471+
472+
return /* spotless:off */ other is ChargedOffReason && this.value == other.value /* spotless:on */
473+
}
474+
475+
override fun hashCode() = value.hashCode()
476+
477+
override fun toString() = value.toString()
478+
479+
companion object {
480+
481+
@JvmField val DELINQUENT = ChargedOffReason(JsonField.of("DELINQUENT"))
482+
483+
@JvmField val FRAUD = ChargedOffReason(JsonField.of("FRAUD"))
484+
485+
@JvmStatic fun of(value: String) = ChargedOffReason(JsonField.of(value))
486+
}
487+
488+
enum class Known {
489+
DELINQUENT,
490+
FRAUD,
491+
}
492+
493+
enum class Value {
494+
DELINQUENT,
495+
FRAUD,
496+
_UNKNOWN,
497+
}
498+
499+
fun value(): Value =
500+
when (this) {
501+
DELINQUENT -> Value.DELINQUENT
502+
FRAUD -> Value.FRAUD
503+
else -> Value._UNKNOWN
504+
}
505+
506+
fun known(): Known =
507+
when (this) {
508+
DELINQUENT -> Known.DELINQUENT
509+
FRAUD -> Known.FRAUD
510+
else -> throw LithicInvalidDataException("Unknown ChargedOffReason: $value")
511+
}
512+
513+
fun asString(): String = _value().asStringOrThrow()
514+
}
515+
416516
class FinancialAccountState
417517
@JsonCreator
418518
private constructor(
@@ -441,19 +541,23 @@ private constructor(
441541

442542
@JvmField val DELINQUENT = FinancialAccountState(JsonField.of("DELINQUENT"))
443543

544+
@JvmField val CHARGED_OFF = FinancialAccountState(JsonField.of("CHARGED_OFF"))
545+
444546
@JvmStatic fun of(value: String) = FinancialAccountState(JsonField.of(value))
445547
}
446548

447549
enum class Known {
448550
PENDING,
449551
CURRENT,
450552
DELINQUENT,
553+
CHARGED_OFF,
451554
}
452555

453556
enum class Value {
454557
PENDING,
455558
CURRENT,
456559
DELINQUENT,
560+
CHARGED_OFF,
457561
_UNKNOWN,
458562
}
459563

@@ -462,6 +566,7 @@ private constructor(
462566
PENDING -> Value.PENDING
463567
CURRENT -> Value.CURRENT
464568
DELINQUENT -> Value.DELINQUENT
569+
CHARGED_OFF -> Value.CHARGED_OFF
465570
else -> Value._UNKNOWN
466571
}
467572

@@ -470,6 +575,7 @@ private constructor(
470575
PENDING -> Known.PENDING
471576
CURRENT -> Known.CURRENT
472577
DELINQUENT -> Known.DELINQUENT
578+
CHARGED_OFF -> Known.CHARGED_OFF
473579
else ->
474580
throw LithicInvalidDataException("Unknown FinancialAccountState: $value")
475581
}
@@ -482,20 +588,20 @@ private constructor(
482588
return true
483589
}
484590

485-
return /* spotless:off */ other is FinancialAccountCreditConfig && this.creditLimit == other.creditLimit && this.externalBankAccountToken == other.externalBankAccountToken && this.creditProductToken == other.creditProductToken && this.tier == other.tier && this.financialAccountState == other.financialAccountState && this.additionalProperties == other.additionalProperties /* spotless:on */
591+
return /* spotless:off */ other is FinancialAccountCreditConfig && this.creditLimit == other.creditLimit && this.externalBankAccountToken == other.externalBankAccountToken && this.creditProductToken == other.creditProductToken && this.tier == other.tier && this.isSpendBlocked == other.isSpendBlocked && this.financialAccountState == other.financialAccountState && this.chargedOffReason == other.chargedOffReason && this.additionalProperties == other.additionalProperties /* spotless:on */
486592
}
487593

488594
private var hashCode: Int = 0
489595

490596
override fun hashCode(): Int {
491597
if (hashCode == 0) {
492-
hashCode = /* spotless:off */ Objects.hash(creditLimit, externalBankAccountToken, creditProductToken, tier, financialAccountState, additionalProperties) /* spotless:on */
598+
hashCode = /* spotless:off */ Objects.hash(creditLimit, externalBankAccountToken, creditProductToken, tier, isSpendBlocked, financialAccountState, chargedOffReason, additionalProperties) /* spotless:on */
493599
}
494600
return hashCode
495601
}
496602

497603
override fun toString() =
498-
"FinancialAccountCreditConfig{creditLimit=$creditLimit, externalBankAccountToken=$externalBankAccountToken, creditProductToken=$creditProductToken, tier=$tier, financialAccountState=$financialAccountState, additionalProperties=$additionalProperties}"
604+
"FinancialAccountCreditConfig{creditLimit=$creditLimit, externalBankAccountToken=$externalBankAccountToken, creditProductToken=$creditProductToken, tier=$tier, isSpendBlocked=$isSpendBlocked, financialAccountState=$financialAccountState, chargedOffReason=$chargedOffReason, additionalProperties=$additionalProperties}"
499605
}
500606

501607
class Type

0 commit comments

Comments
 (0)