Skip to content

Commit

Permalink
chore(api): adds charge_off functionality to FinancialAccounts (#351)
Browse files Browse the repository at this point in the history
- adds `CHARGED_OFF` to `financial_account_states` property
- adds `charged_off_reason` property
- adds `charge_off` method
  • Loading branch information
stainless-app[bot] authored and Stainless Bot committed Nov 1, 2024
1 parent ee5d02e commit 1bf0ec1
Show file tree
Hide file tree
Showing 12 changed files with 676 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 155
configured_endpoints: 156
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ private constructor(
private val externalBankAccountToken: JsonField<String>,
private val creditProductToken: JsonField<String>,
private val tier: JsonField<String>,
private val isSpendBlocked: JsonField<Boolean>,
private val financialAccountState: JsonField<FinancialAccountState>,
private val chargedOffReason: JsonField<ChargedOffReason>,
private val additionalProperties: Map<String, JsonValue>,
) {

Expand All @@ -270,10 +272,16 @@ private constructor(
/** Tier assigned to the financial account */
fun tier(): String? = tier.getNullable("tier")

fun isSpendBlocked(): Boolean = isSpendBlocked.getRequired("is_spend_blocked")

/** State of the financial account */
fun financialAccountState(): FinancialAccountState? =
financialAccountState.getNullable("financial_account_state")

/** Reason for the financial account being marked as Charged Off */
fun chargedOffReason(): ChargedOffReason? =
chargedOffReason.getNullable("charged_off_reason")

@JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit() = creditLimit

@JsonProperty("external_bank_account_token")
Expand All @@ -288,11 +296,18 @@ private constructor(
/** Tier assigned to the financial account */
@JsonProperty("tier") @ExcludeMissing fun _tier() = tier

@JsonProperty("is_spend_blocked") @ExcludeMissing fun _isSpendBlocked() = isSpendBlocked

/** State of the financial account */
@JsonProperty("financial_account_state")
@ExcludeMissing
fun _financialAccountState() = financialAccountState

/** Reason for the financial account being marked as Charged Off */
@JsonProperty("charged_off_reason")
@ExcludeMissing
fun _chargedOffReason() = chargedOffReason

@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
Expand All @@ -303,7 +318,9 @@ private constructor(
externalBankAccountToken()
creditProductToken()
tier()
isSpendBlocked()
financialAccountState()
chargedOffReason()
validated = true
}
}
Expand All @@ -321,7 +338,9 @@ private constructor(
private var externalBankAccountToken: JsonField<String> = JsonMissing.of()
private var creditProductToken: JsonField<String> = JsonMissing.of()
private var tier: JsonField<String> = JsonMissing.of()
private var isSpendBlocked: JsonField<Boolean> = JsonMissing.of()
private var financialAccountState: JsonField<FinancialAccountState> = JsonMissing.of()
private var chargedOffReason: JsonField<ChargedOffReason> = JsonMissing.of()
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()

internal fun from(financialAccountCreditConfig: FinancialAccountCreditConfig) = apply {
Expand All @@ -330,7 +349,9 @@ private constructor(
financialAccountCreditConfig.externalBankAccountToken
this.creditProductToken = financialAccountCreditConfig.creditProductToken
this.tier = financialAccountCreditConfig.tier
this.isSpendBlocked = financialAccountCreditConfig.isSpendBlocked
this.financialAccountState = financialAccountCreditConfig.financialAccountState
this.chargedOffReason = financialAccountCreditConfig.chargedOffReason
additionalProperties(financialAccountCreditConfig.additionalProperties)
}

Expand Down Expand Up @@ -368,6 +389,15 @@ private constructor(
@ExcludeMissing
fun tier(tier: JsonField<String>) = apply { this.tier = tier }

fun isSpendBlocked(isSpendBlocked: Boolean) =
isSpendBlocked(JsonField.of(isSpendBlocked))

@JsonProperty("is_spend_blocked")
@ExcludeMissing
fun isSpendBlocked(isSpendBlocked: JsonField<Boolean>) = apply {
this.isSpendBlocked = isSpendBlocked
}

/** State of the financial account */
fun financialAccountState(financialAccountState: FinancialAccountState) =
financialAccountState(JsonField.of(financialAccountState))
Expand All @@ -380,6 +410,17 @@ private constructor(
this.financialAccountState = financialAccountState
}

/** Reason for the financial account being marked as Charged Off */
fun chargedOffReason(chargedOffReason: ChargedOffReason) =
chargedOffReason(JsonField.of(chargedOffReason))

/** Reason for the financial account being marked as Charged Off */
@JsonProperty("charged_off_reason")
@ExcludeMissing
fun chargedOffReason(chargedOffReason: JsonField<ChargedOffReason>) = apply {
this.chargedOffReason = chargedOffReason
}

fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
this.additionalProperties.clear()
this.additionalProperties.putAll(additionalProperties)
Expand All @@ -400,11 +441,70 @@ private constructor(
externalBankAccountToken,
creditProductToken,
tier,
isSpendBlocked,
financialAccountState,
chargedOffReason,
additionalProperties.toUnmodifiable(),
)
}

class ChargedOffReason
@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 /* spotless:off */ other is ChargedOffReason && this.value == other.value /* spotless:on */
}

override fun hashCode() = value.hashCode()

override fun toString() = value.toString()

companion object {

val DELINQUENT = ChargedOffReason(JsonField.of("DELINQUENT"))

val FRAUD = ChargedOffReason(JsonField.of("FRAUD"))

fun of(value: String) = ChargedOffReason(JsonField.of(value))
}

enum class Known {
DELINQUENT,
FRAUD,
}

enum class Value {
DELINQUENT,
FRAUD,
_UNKNOWN,
}

fun value(): Value =
when (this) {
DELINQUENT -> Value.DELINQUENT
FRAUD -> Value.FRAUD
else -> Value._UNKNOWN
}

fun known(): Known =
when (this) {
DELINQUENT -> Known.DELINQUENT
FRAUD -> Known.FRAUD
else -> throw LithicInvalidDataException("Unknown ChargedOffReason: $value")
}

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

class FinancialAccountState
@JsonCreator
private constructor(
Expand Down Expand Up @@ -433,19 +533,23 @@ private constructor(

val DELINQUENT = FinancialAccountState(JsonField.of("DELINQUENT"))

val CHARGED_OFF = FinancialAccountState(JsonField.of("CHARGED_OFF"))

fun of(value: String) = FinancialAccountState(JsonField.of(value))
}

enum class Known {
PENDING,
CURRENT,
DELINQUENT,
CHARGED_OFF,
}

enum class Value {
PENDING,
CURRENT,
DELINQUENT,
CHARGED_OFF,
_UNKNOWN,
}

Expand All @@ -454,6 +558,7 @@ private constructor(
PENDING -> Value.PENDING
CURRENT -> Value.CURRENT
DELINQUENT -> Value.DELINQUENT
CHARGED_OFF -> Value.CHARGED_OFF
else -> Value._UNKNOWN
}

Expand All @@ -462,6 +567,7 @@ private constructor(
PENDING -> Known.PENDING
CURRENT -> Known.CURRENT
DELINQUENT -> Known.DELINQUENT
CHARGED_OFF -> Known.CHARGED_OFF
else ->
throw LithicInvalidDataException("Unknown FinancialAccountState: $value")
}
Expand All @@ -474,20 +580,20 @@ private constructor(
return true
}

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 */
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 */
}

private var hashCode: Int = 0

override fun hashCode(): Int {
if (hashCode == 0) {
hashCode = /* spotless:off */ Objects.hash(creditLimit, externalBankAccountToken, creditProductToken, tier, financialAccountState, additionalProperties) /* spotless:on */
hashCode = /* spotless:off */ Objects.hash(creditLimit, externalBankAccountToken, creditProductToken, tier, isSpendBlocked, financialAccountState, chargedOffReason, additionalProperties) /* spotless:on */
}
return hashCode
}

override fun toString() =
"FinancialAccountCreditConfig{creditLimit=$creditLimit, externalBankAccountToken=$externalBankAccountToken, creditProductToken=$creditProductToken, tier=$tier, financialAccountState=$financialAccountState, additionalProperties=$additionalProperties}"
"FinancialAccountCreditConfig{creditLimit=$creditLimit, externalBankAccountToken=$externalBankAccountToken, creditProductToken=$creditProductToken, tier=$tier, isSpendBlocked=$isSpendBlocked, financialAccountState=$financialAccountState, chargedOffReason=$chargedOffReason, additionalProperties=$additionalProperties}"
}

class Type
Expand Down
Loading

0 comments on commit 1bf0ec1

Please sign in to comment.