diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 85c79bb04..bfd4e4464 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.408.0" + ".": "0.409.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 91752aeff..df82cbc8f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 232 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-3309070d0c282e00842afa3021c80774f8e1f3a4517959927adfd9ffaa81c94c.yml -openapi_spec_hash: 57927271c019ee8ddd428afa8a57baaf +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-994727afca8b769c05b3531b0e560cfc71b7d2c45a49b54e09bbf73d0dbcaa1f.yml +openapi_spec_hash: bb1c55d7e08fb038a7383976bba226d1 config_hash: 27e44ed36b9c5617b580ead7231a594a diff --git a/CHANGELOG.md b/CHANGELOG.md index e4fa52c41..a96b0112a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.409.0 (2026-01-30) + +Full Changelog: [v0.408.0...v0.409.0](https://github.com/Increase/increase-java/compare/v0.408.0...v0.409.0) + +### Features + +* **api:** api update ([633a11f](https://github.com/Increase/increase-java/commit/633a11f61f35bcbea16924486453cea8edb831ec)) + ## 0.408.0 (2026-01-30) Full Changelog: [v0.407.0...v0.408.0](https://github.com/Increase/increase-java/compare/v0.407.0...v0.408.0) diff --git a/README.md b/README.md index c8e357112..b3f99daca 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.increase.api/increase-java)](https://central.sonatype.com/artifact/com.increase.api/increase-java/0.408.0) -[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.408.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.408.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.increase.api/increase-java)](https://central.sonatype.com/artifact/com.increase.api/increase-java/0.409.0) +[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.409.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.409.0) @@ -13,7 +13,7 @@ The Increase Java SDK is similar to the Increase Kotlin SDK but with minor diffe -The REST API documentation can be found on [increase.com](https://increase.com/documentation). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.increase.api/increase-java/0.408.0). +The REST API documentation can be found on [increase.com](https://increase.com/documentation). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.increase.api/increase-java/0.409.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [increase.com](https://increase.com/d ### Gradle ```kotlin -implementation("com.increase.api:increase-java:0.408.0") +implementation("com.increase.api:increase-java:0.409.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.increase.api:increase-java:0.408.0") com.increase.api increase-java - 0.408.0 + 0.409.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 9d3812209..a3bc6c537 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.increase.api" - version = "0.408.0" // x-release-please-version + version = "0.409.0" // x-release-please-version } subprojects { diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/Account.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/Account.kt index f217c1e07..9b2de97fe 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/Account.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/Account.kt @@ -34,11 +34,13 @@ private constructor( private val createdAt: JsonField, private val currency: JsonField, private val entityId: JsonField, + private val funding: JsonField, private val idempotencyKey: JsonField, private val informationalEntityId: JsonField, private val interestAccrued: JsonField, private val interestAccruedAt: JsonField, private val interestRate: JsonField, + private val loan: JsonField, private val name: JsonField, private val programId: JsonField, private val status: JsonField, @@ -61,6 +63,7 @@ private constructor( createdAt: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("entity_id") @ExcludeMissing entityId: JsonField = JsonMissing.of(), + @JsonProperty("funding") @ExcludeMissing funding: JsonField = JsonMissing.of(), @JsonProperty("idempotency_key") @ExcludeMissing idempotencyKey: JsonField = JsonMissing.of(), @@ -76,6 +79,7 @@ private constructor( @JsonProperty("interest_rate") @ExcludeMissing interestRate: JsonField = JsonMissing.of(), + @JsonProperty("loan") @ExcludeMissing loan: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("program_id") @ExcludeMissing programId: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), @@ -88,11 +92,13 @@ private constructor( createdAt, currency, entityId, + funding, idempotencyKey, informationalEntityId, interestAccrued, interestAccruedAt, interestRate, + loan, name, programId, status, @@ -159,6 +165,14 @@ private constructor( */ fun entityId(): String = entityId.getRequired("entity_id") + /** + * Whether the Account is funded by a loan or by deposits. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun funding(): Optional = funding.getOptional("funding") + /** * The idempotency key you chose for this object. This value is unique across Increase and is * used to ensure that a request is only processed once. Learn more about @@ -207,6 +221,14 @@ private constructor( */ fun interestRate(): String = interestRate.getRequired("interest_rate") + /** + * The Account's loan-related information, if the Account is a loan account. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loan(): Optional = loan.getOptional("loan") + /** * The name you choose for the Account. * @@ -294,6 +316,13 @@ private constructor( */ @JsonProperty("entity_id") @ExcludeMissing fun _entityId(): JsonField = entityId + /** + * Returns the raw JSON value of [funding]. + * + * Unlike [funding], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("funding") @ExcludeMissing fun _funding(): JsonField = funding + /** * Returns the raw JSON value of [idempotencyKey]. * @@ -341,6 +370,13 @@ private constructor( @ExcludeMissing fun _interestRate(): JsonField = interestRate + /** + * Returns the raw JSON value of [loan]. + * + * Unlike [loan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loan") @ExcludeMissing fun _loan(): JsonField = loan + /** * Returns the raw JSON value of [name]. * @@ -395,11 +431,13 @@ private constructor( * .createdAt() * .currency() * .entityId() + * .funding() * .idempotencyKey() * .informationalEntityId() * .interestAccrued() * .interestAccruedAt() * .interestRate() + * .loan() * .name() * .programId() * .status() @@ -419,11 +457,13 @@ private constructor( private var createdAt: JsonField? = null private var currency: JsonField? = null private var entityId: JsonField? = null + private var funding: JsonField? = null private var idempotencyKey: JsonField? = null private var informationalEntityId: JsonField? = null private var interestAccrued: JsonField? = null private var interestAccruedAt: JsonField? = null private var interestRate: JsonField? = null + private var loan: JsonField? = null private var name: JsonField? = null private var programId: JsonField? = null private var status: JsonField? = null @@ -439,11 +479,13 @@ private constructor( createdAt = account.createdAt currency = account.currency entityId = account.entityId + funding = account.funding idempotencyKey = account.idempotencyKey informationalEntityId = account.informationalEntityId interestAccrued = account.interestAccrued interestAccruedAt = account.interestAccruedAt interestRate = account.interestRate + loan = account.loan name = account.name programId = account.programId status = account.status @@ -554,6 +596,20 @@ private constructor( */ fun entityId(entityId: JsonField) = apply { this.entityId = entityId } + /** Whether the Account is funded by a loan or by deposits. */ + fun funding(funding: Funding?) = funding(JsonField.ofNullable(funding)) + + /** Alias for calling [Builder.funding] with `funding.orElse(null)`. */ + fun funding(funding: Optional) = funding(funding.getOrNull()) + + /** + * Sets [Builder.funding] to an arbitrary JSON value. + * + * You should usually call [Builder.funding] with a well-typed [Funding] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun funding(funding: JsonField) = apply { this.funding = funding } + /** * The idempotency key you chose for this object. This value is unique across Increase and * is used to ensure that a request is only processed once. Learn more about @@ -659,6 +715,20 @@ private constructor( this.interestRate = interestRate } + /** The Account's loan-related information, if the Account is a loan account. */ + fun loan(loan: Loan?) = loan(JsonField.ofNullable(loan)) + + /** Alias for calling [Builder.loan] with `loan.orElse(null)`. */ + fun loan(loan: Optional) = loan(loan.getOrNull()) + + /** + * Sets [Builder.loan] to an arbitrary JSON value. + * + * You should usually call [Builder.loan] with a well-typed [Loan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun loan(loan: JsonField) = apply { this.loan = loan } + /** The name you choose for the Account. */ fun name(name: String) = name(JsonField.of(name)) @@ -742,11 +812,13 @@ private constructor( * .createdAt() * .currency() * .entityId() + * .funding() * .idempotencyKey() * .informationalEntityId() * .interestAccrued() * .interestAccruedAt() * .interestRate() + * .loan() * .name() * .programId() * .status() @@ -764,11 +836,13 @@ private constructor( checkRequired("createdAt", createdAt), checkRequired("currency", currency), checkRequired("entityId", entityId), + checkRequired("funding", funding), checkRequired("idempotencyKey", idempotencyKey), checkRequired("informationalEntityId", informationalEntityId), checkRequired("interestAccrued", interestAccrued), checkRequired("interestAccruedAt", interestAccruedAt), checkRequired("interestRate", interestRate), + checkRequired("loan", loan), checkRequired("name", name), checkRequired("programId", programId), checkRequired("status", status), @@ -791,11 +865,13 @@ private constructor( createdAt() currency().validate() entityId() + funding().ifPresent { it.validate() } idempotencyKey() informationalEntityId() interestAccrued() interestAccruedAt() interestRate() + loan().ifPresent { it.validate() } name() programId() status().validate() @@ -825,11 +901,13 @@ private constructor( (if (createdAt.asKnown().isPresent) 1 else 0) + (currency.asKnown().getOrNull()?.validity() ?: 0) + (if (entityId.asKnown().isPresent) 1 else 0) + + (funding.asKnown().getOrNull()?.validity() ?: 0) + (if (idempotencyKey.asKnown().isPresent) 1 else 0) + (if (informationalEntityId.asKnown().isPresent) 1 else 0) + (if (interestAccrued.asKnown().isPresent) 1 else 0) + (if (interestAccruedAt.asKnown().isPresent) 1 else 0) + (if (interestRate.asKnown().isPresent) 1 else 0) + + (loan.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (programId.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + @@ -1103,6 +1181,678 @@ private constructor( override fun toString() = value.toString() } + /** Whether the Account is funded by a loan or by deposits. */ + class Funding @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + /** + * An account funded by a loan. Before opening a loan account, contact + * support@increase.com to set up a loan program. + */ + @JvmField val LOAN = of("loan") + + /** An account funded by deposits. */ + @JvmField val DEPOSITS = of("deposits") + + @JvmStatic fun of(value: String) = Funding(JsonField.of(value)) + } + + /** An enum containing [Funding]'s known values. */ + enum class Known { + /** + * An account funded by a loan. Before opening a loan account, contact + * support@increase.com to set up a loan program. + */ + LOAN, + /** An account funded by deposits. */ + DEPOSITS, + } + + /** + * An enum containing [Funding]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Funding] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** + * An account funded by a loan. Before opening a loan account, contact + * support@increase.com to set up a loan program. + */ + LOAN, + /** An account funded by deposits. */ + DEPOSITS, + /** An enum member indicating that [Funding] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LOAN -> Value.LOAN + DEPOSITS -> Value.DEPOSITS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LOAN -> Known.LOAN + DEPOSITS -> Known.DEPOSITS + else -> throw IncreaseInvalidDataException("Unknown Funding: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Funding = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Funding && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The Account's loan-related information, if the Account is a loan account. */ + class Loan + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val creditLimit: JsonField, + private val gracePeriodDays: JsonField, + private val maturityDate: JsonField, + private val statementDayOfMonth: JsonField, + private val statementPaymentType: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credit_limit") + @ExcludeMissing + creditLimit: JsonField = JsonMissing.of(), + @JsonProperty("grace_period_days") + @ExcludeMissing + gracePeriodDays: JsonField = JsonMissing.of(), + @JsonProperty("maturity_date") + @ExcludeMissing + maturityDate: JsonField = JsonMissing.of(), + @JsonProperty("statement_day_of_month") + @ExcludeMissing + statementDayOfMonth: JsonField = JsonMissing.of(), + @JsonProperty("statement_payment_type") + @ExcludeMissing + statementPaymentType: JsonField = JsonMissing.of(), + ) : this( + creditLimit, + gracePeriodDays, + maturityDate, + statementDayOfMonth, + statementPaymentType, + mutableMapOf(), + ) + + /** + * The maximum amount of money that can be borrowed on the Account. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditLimit(): Long = creditLimit.getRequired("credit_limit") + + /** + * The number of days after the statement date that the Account can be past due before being + * considered delinquent. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun gracePeriodDays(): Long = gracePeriodDays.getRequired("grace_period_days") + + /** + * The date on which the loan matures. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maturityDate(): Optional = maturityDate.getOptional("maturity_date") + + /** + * The day of the month on which the loan statement is generated. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun statementDayOfMonth(): Long = statementDayOfMonth.getRequired("statement_day_of_month") + + /** + * The type of payment for the loan. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun statementPaymentType(): StatementPaymentType = + statementPaymentType.getRequired("statement_payment_type") + + /** + * Returns the raw JSON value of [creditLimit]. + * + * Unlike [creditLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_limit") + @ExcludeMissing + fun _creditLimit(): JsonField = creditLimit + + /** + * Returns the raw JSON value of [gracePeriodDays]. + * + * Unlike [gracePeriodDays], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grace_period_days") + @ExcludeMissing + fun _gracePeriodDays(): JsonField = gracePeriodDays + + /** + * Returns the raw JSON value of [maturityDate]. + * + * Unlike [maturityDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("maturity_date") + @ExcludeMissing + fun _maturityDate(): JsonField = maturityDate + + /** + * Returns the raw JSON value of [statementDayOfMonth]. + * + * Unlike [statementDayOfMonth], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("statement_day_of_month") + @ExcludeMissing + fun _statementDayOfMonth(): JsonField = statementDayOfMonth + + /** + * Returns the raw JSON value of [statementPaymentType]. + * + * Unlike [statementPaymentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("statement_payment_type") + @ExcludeMissing + fun _statementPaymentType(): JsonField = statementPaymentType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Loan]. + * + * The following fields are required: + * ```java + * .creditLimit() + * .gracePeriodDays() + * .maturityDate() + * .statementDayOfMonth() + * .statementPaymentType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Loan]. */ + class Builder internal constructor() { + + private var creditLimit: JsonField? = null + private var gracePeriodDays: JsonField? = null + private var maturityDate: JsonField? = null + private var statementDayOfMonth: JsonField? = null + private var statementPaymentType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(loan: Loan) = apply { + creditLimit = loan.creditLimit + gracePeriodDays = loan.gracePeriodDays + maturityDate = loan.maturityDate + statementDayOfMonth = loan.statementDayOfMonth + statementPaymentType = loan.statementPaymentType + additionalProperties = loan.additionalProperties.toMutableMap() + } + + /** The maximum amount of money that can be borrowed on the Account. */ + fun creditLimit(creditLimit: Long) = creditLimit(JsonField.of(creditLimit)) + + /** + * Sets [Builder.creditLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.creditLimit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditLimit(creditLimit: JsonField) = apply { this.creditLimit = creditLimit } + + /** + * The number of days after the statement date that the Account can be past due before + * being considered delinquent. + */ + fun gracePeriodDays(gracePeriodDays: Long) = + gracePeriodDays(JsonField.of(gracePeriodDays)) + + /** + * Sets [Builder.gracePeriodDays] to an arbitrary JSON value. + * + * You should usually call [Builder.gracePeriodDays] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gracePeriodDays(gracePeriodDays: JsonField) = apply { + this.gracePeriodDays = gracePeriodDays + } + + /** The date on which the loan matures. */ + fun maturityDate(maturityDate: LocalDate?) = + maturityDate(JsonField.ofNullable(maturityDate)) + + /** Alias for calling [Builder.maturityDate] with `maturityDate.orElse(null)`. */ + fun maturityDate(maturityDate: Optional) = + maturityDate(maturityDate.getOrNull()) + + /** + * Sets [Builder.maturityDate] to an arbitrary JSON value. + * + * You should usually call [Builder.maturityDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maturityDate(maturityDate: JsonField) = apply { + this.maturityDate = maturityDate + } + + /** The day of the month on which the loan statement is generated. */ + fun statementDayOfMonth(statementDayOfMonth: Long) = + statementDayOfMonth(JsonField.of(statementDayOfMonth)) + + /** + * Sets [Builder.statementDayOfMonth] to an arbitrary JSON value. + * + * You should usually call [Builder.statementDayOfMonth] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statementDayOfMonth(statementDayOfMonth: JsonField) = apply { + this.statementDayOfMonth = statementDayOfMonth + } + + /** The type of payment for the loan. */ + fun statementPaymentType(statementPaymentType: StatementPaymentType) = + statementPaymentType(JsonField.of(statementPaymentType)) + + /** + * Sets [Builder.statementPaymentType] to an arbitrary JSON value. + * + * You should usually call [Builder.statementPaymentType] with a well-typed + * [StatementPaymentType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun statementPaymentType(statementPaymentType: JsonField) = + apply { + this.statementPaymentType = statementPaymentType + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Loan]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .creditLimit() + * .gracePeriodDays() + * .maturityDate() + * .statementDayOfMonth() + * .statementPaymentType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Loan = + Loan( + checkRequired("creditLimit", creditLimit), + checkRequired("gracePeriodDays", gracePeriodDays), + checkRequired("maturityDate", maturityDate), + checkRequired("statementDayOfMonth", statementDayOfMonth), + checkRequired("statementPaymentType", statementPaymentType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Loan = apply { + if (validated) { + return@apply + } + + creditLimit() + gracePeriodDays() + maturityDate() + statementDayOfMonth() + statementPaymentType().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (creditLimit.asKnown().isPresent) 1 else 0) + + (if (gracePeriodDays.asKnown().isPresent) 1 else 0) + + (if (maturityDate.asKnown().isPresent) 1 else 0) + + (if (statementDayOfMonth.asKnown().isPresent) 1 else 0) + + (statementPaymentType.asKnown().getOrNull()?.validity() ?: 0) + + /** The type of payment for the loan. */ + class StatementPaymentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + /** + * The borrower must pay the full balance of the loan at the end of the statement + * period. + */ + @JvmField val BALANCE = of("balance") + + /** + * The borrower must pay the accrued interest at the end of the statement period. + */ + @JvmField val INTEREST_UNTIL_MATURITY = of("interest_until_maturity") + + @JvmStatic fun of(value: String) = StatementPaymentType(JsonField.of(value)) + } + + /** An enum containing [StatementPaymentType]'s known values. */ + enum class Known { + /** + * The borrower must pay the full balance of the loan at the end of the statement + * period. + */ + BALANCE, + /** + * The borrower must pay the accrued interest at the end of the statement period. + */ + INTEREST_UNTIL_MATURITY, + } + + /** + * An enum containing [StatementPaymentType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [StatementPaymentType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** + * The borrower must pay the full balance of the loan at the end of the statement + * period. + */ + BALANCE, + /** + * The borrower must pay the accrued interest at the end of the statement period. + */ + INTEREST_UNTIL_MATURITY, + /** + * An enum member indicating that [StatementPaymentType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BALANCE -> Value.BALANCE + INTEREST_UNTIL_MATURITY -> Value.INTEREST_UNTIL_MATURITY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BALANCE -> Known.BALANCE + INTEREST_UNTIL_MATURITY -> Known.INTEREST_UNTIL_MATURITY + else -> + throw IncreaseInvalidDataException("Unknown StatementPaymentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): StatementPaymentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StatementPaymentType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Loan && + creditLimit == other.creditLimit && + gracePeriodDays == other.gracePeriodDays && + maturityDate == other.maturityDate && + statementDayOfMonth == other.statementDayOfMonth && + statementPaymentType == other.statementPaymentType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + creditLimit, + gracePeriodDays, + maturityDate, + statementDayOfMonth, + statementPaymentType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Loan{creditLimit=$creditLimit, gracePeriodDays=$gracePeriodDays, maturityDate=$maturityDate, statementDayOfMonth=$statementDayOfMonth, statementPaymentType=$statementPaymentType, additionalProperties=$additionalProperties}" + } + /** The status of the Account. */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -1372,11 +2122,13 @@ private constructor( createdAt == other.createdAt && currency == other.currency && entityId == other.entityId && + funding == other.funding && idempotencyKey == other.idempotencyKey && informationalEntityId == other.informationalEntityId && interestAccrued == other.interestAccrued && interestAccruedAt == other.interestAccruedAt && interestRate == other.interestRate && + loan == other.loan && name == other.name && programId == other.programId && status == other.status && @@ -1393,11 +2145,13 @@ private constructor( createdAt, currency, entityId, + funding, idempotencyKey, informationalEntityId, interestAccrued, interestAccruedAt, interestRate, + loan, name, programId, status, @@ -1409,5 +2163,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Account{id=$id, accountRevenueRate=$accountRevenueRate, bank=$bank, closedAt=$closedAt, createdAt=$createdAt, currency=$currency, entityId=$entityId, idempotencyKey=$idempotencyKey, informationalEntityId=$informationalEntityId, interestAccrued=$interestAccrued, interestAccruedAt=$interestAccruedAt, interestRate=$interestRate, name=$name, programId=$programId, status=$status, type=$type, additionalProperties=$additionalProperties}" + "Account{id=$id, accountRevenueRate=$accountRevenueRate, bank=$bank, closedAt=$closedAt, createdAt=$createdAt, currency=$currency, entityId=$entityId, funding=$funding, idempotencyKey=$idempotencyKey, informationalEntityId=$informationalEntityId, interestAccrued=$interestAccrued, interestAccruedAt=$interestAccruedAt, interestRate=$interestRate, loan=$loan, name=$name, programId=$programId, status=$status, type=$type, additionalProperties=$additionalProperties}" } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/AccountCreateParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/AccountCreateParams.kt index 34891d29d..a2d111a24 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/AccountCreateParams.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/AccountCreateParams.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.increase.api.core.Enum import com.increase.api.core.ExcludeMissing import com.increase.api.core.JsonField import com.increase.api.core.JsonMissing @@ -15,9 +16,11 @@ import com.increase.api.core.checkRequired import com.increase.api.core.http.Headers import com.increase.api.core.http.QueryParams import com.increase.api.errors.IncreaseInvalidDataException +import java.time.LocalDate import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Create an Account */ class AccountCreateParams @@ -43,6 +46,14 @@ private constructor( */ fun entityId(): Optional = body.entityId() + /** + * Whether the Account is funded by a loan or by deposits. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun funding(): Optional = body.funding() + /** * The identifier of an Entity that, while not owning the Account, is associated with its * activity. This is generally the beneficiary of the funds. @@ -52,6 +63,14 @@ private constructor( */ fun informationalEntityId(): Optional = body.informationalEntityId() + /** + * The loan details for the account. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loan(): Optional = body.loan() + /** * The identifier for the Program that this Account falls under. Required if you operate more * than one Program. @@ -75,6 +94,13 @@ private constructor( */ fun _entityId(): JsonField = body._entityId() + /** + * Returns the raw JSON value of [funding]. + * + * Unlike [funding], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _funding(): JsonField = body._funding() + /** * Returns the raw JSON value of [informationalEntityId]. * @@ -83,6 +109,13 @@ private constructor( */ fun _informationalEntityId(): JsonField = body._informationalEntityId() + /** + * Returns the raw JSON value of [loan]. + * + * Unlike [loan], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _loan(): JsonField = body._loan() + /** * Returns the raw JSON value of [programId]. * @@ -134,8 +167,10 @@ private constructor( * Otherwise, it's more convenient to use the top-level setters instead: * - [name] * - [entityId] + * - [funding] * - [informationalEntityId] - * - [programId] + * - [loan] + * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -161,6 +196,17 @@ private constructor( */ fun entityId(entityId: JsonField) = apply { body.entityId(entityId) } + /** Whether the Account is funded by a loan or by deposits. */ + fun funding(funding: Funding) = apply { body.funding(funding) } + + /** + * Sets [Builder.funding] to an arbitrary JSON value. + * + * You should usually call [Builder.funding] with a well-typed [Funding] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun funding(funding: JsonField) = apply { body.funding(funding) } + /** * The identifier of an Entity that, while not owning the Account, is associated with its * activity. This is generally the beneficiary of the funds. @@ -180,6 +226,17 @@ private constructor( body.informationalEntityId(informationalEntityId) } + /** The loan details for the account. */ + fun loan(loan: Loan) = apply { body.loan(loan) } + + /** + * Sets [Builder.loan] to an arbitrary JSON value. + * + * You should usually call [Builder.loan] with a well-typed [Loan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun loan(loan: JsonField) = apply { body.loan(loan) } + /** * The identifier for the Program that this Account falls under. Required if you operate * more than one Program. @@ -343,7 +400,9 @@ private constructor( private constructor( private val name: JsonField, private val entityId: JsonField, + private val funding: JsonField, private val informationalEntityId: JsonField, + private val loan: JsonField, private val programId: JsonField, private val additionalProperties: MutableMap, ) { @@ -354,13 +413,15 @@ private constructor( @JsonProperty("entity_id") @ExcludeMissing entityId: JsonField = JsonMissing.of(), + @JsonProperty("funding") @ExcludeMissing funding: JsonField = JsonMissing.of(), @JsonProperty("informational_entity_id") @ExcludeMissing informationalEntityId: JsonField = JsonMissing.of(), + @JsonProperty("loan") @ExcludeMissing loan: JsonField = JsonMissing.of(), @JsonProperty("program_id") @ExcludeMissing programId: JsonField = JsonMissing.of(), - ) : this(name, entityId, informationalEntityId, programId, mutableMapOf()) + ) : this(name, entityId, funding, informationalEntityId, loan, programId, mutableMapOf()) /** * The name you choose for the Account. @@ -378,6 +439,14 @@ private constructor( */ fun entityId(): Optional = entityId.getOptional("entity_id") + /** + * Whether the Account is funded by a loan or by deposits. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun funding(): Optional = funding.getOptional("funding") + /** * The identifier of an Entity that, while not owning the Account, is associated with its * activity. This is generally the beneficiary of the funds. @@ -388,6 +457,14 @@ private constructor( fun informationalEntityId(): Optional = informationalEntityId.getOptional("informational_entity_id") + /** + * The loan details for the account. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun loan(): Optional = loan.getOptional("loan") + /** * The identifier for the Program that this Account falls under. Required if you operate * more than one Program. @@ -411,6 +488,13 @@ private constructor( */ @JsonProperty("entity_id") @ExcludeMissing fun _entityId(): JsonField = entityId + /** + * Returns the raw JSON value of [funding]. + * + * Unlike [funding], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("funding") @ExcludeMissing fun _funding(): JsonField = funding + /** * Returns the raw JSON value of [informationalEntityId]. * @@ -421,6 +505,13 @@ private constructor( @ExcludeMissing fun _informationalEntityId(): JsonField = informationalEntityId + /** + * Returns the raw JSON value of [loan]. + * + * Unlike [loan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loan") @ExcludeMissing fun _loan(): JsonField = loan + /** * Returns the raw JSON value of [programId]. * @@ -458,7 +549,9 @@ private constructor( private var name: JsonField? = null private var entityId: JsonField = JsonMissing.of() + private var funding: JsonField = JsonMissing.of() private var informationalEntityId: JsonField = JsonMissing.of() + private var loan: JsonField = JsonMissing.of() private var programId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -466,7 +559,9 @@ private constructor( internal fun from(body: Body) = apply { name = body.name entityId = body.entityId + funding = body.funding informationalEntityId = body.informationalEntityId + loan = body.loan programId = body.programId additionalProperties = body.additionalProperties.toMutableMap() } @@ -495,6 +590,18 @@ private constructor( */ fun entityId(entityId: JsonField) = apply { this.entityId = entityId } + /** Whether the Account is funded by a loan or by deposits. */ + fun funding(funding: Funding) = funding(JsonField.of(funding)) + + /** + * Sets [Builder.funding] to an arbitrary JSON value. + * + * You should usually call [Builder.funding] with a well-typed [Funding] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun funding(funding: JsonField) = apply { this.funding = funding } + /** * The identifier of an Entity that, while not owning the Account, is associated with * its activity. This is generally the beneficiary of the funds. @@ -513,6 +620,18 @@ private constructor( this.informationalEntityId = informationalEntityId } + /** The loan details for the account. */ + fun loan(loan: Loan) = loan(JsonField.of(loan)) + + /** + * Sets [Builder.loan] to an arbitrary JSON value. + * + * You should usually call [Builder.loan] with a well-typed [Loan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loan(loan: JsonField) = apply { this.loan = loan } + /** * The identifier for the Program that this Account falls under. Required if you operate * more than one Program. @@ -563,7 +682,9 @@ private constructor( Body( checkRequired("name", name), entityId, + funding, informationalEntityId, + loan, programId, additionalProperties.toMutableMap(), ) @@ -578,7 +699,9 @@ private constructor( name() entityId() + funding().ifPresent { it.validate() } informationalEntityId() + loan().ifPresent { it.validate() } programId() validated = true } @@ -601,7 +724,9 @@ private constructor( internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + (if (entityId.asKnown().isPresent) 1 else 0) + + (funding.asKnown().getOrNull()?.validity() ?: 0) + (if (informationalEntityId.asKnown().isPresent) 1 else 0) + + (loan.asKnown().getOrNull()?.validity() ?: 0) + (if (programId.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -612,19 +737,694 @@ private constructor( return other is Body && name == other.name && entityId == other.entityId && + funding == other.funding && informationalEntityId == other.informationalEntityId && + loan == other.loan && programId == other.programId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(name, entityId, informationalEntityId, programId, additionalProperties) + Objects.hash( + name, + entityId, + funding, + informationalEntityId, + loan, + programId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{name=$name, entityId=$entityId, funding=$funding, informationalEntityId=$informationalEntityId, loan=$loan, programId=$programId, additionalProperties=$additionalProperties}" + } + + /** Whether the Account is funded by a loan or by deposits. */ + class Funding @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + /** + * An account funded by a loan. Before opening a loan account, contact + * support@increase.com to set up a loan program. + */ + @JvmField val LOAN = of("loan") + + /** An account funded by deposits. */ + @JvmField val DEPOSITS = of("deposits") + + @JvmStatic fun of(value: String) = Funding(JsonField.of(value)) + } + + /** An enum containing [Funding]'s known values. */ + enum class Known { + /** + * An account funded by a loan. Before opening a loan account, contact + * support@increase.com to set up a loan program. + */ + LOAN, + /** An account funded by deposits. */ + DEPOSITS, + } + + /** + * An enum containing [Funding]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Funding] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** + * An account funded by a loan. Before opening a loan account, contact + * support@increase.com to set up a loan program. + */ + LOAN, + /** An account funded by deposits. */ + DEPOSITS, + /** An enum member indicating that [Funding] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LOAN -> Value.LOAN + DEPOSITS -> Value.DEPOSITS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LOAN -> Known.LOAN + DEPOSITS -> Known.DEPOSITS + else -> throw IncreaseInvalidDataException("Unknown Funding: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Funding = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Funding && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The loan details for the account. */ + class Loan + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val creditLimit: JsonField, + private val gracePeriodDays: JsonField, + private val statementDayOfMonth: JsonField, + private val statementPaymentType: JsonField, + private val maturityDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credit_limit") + @ExcludeMissing + creditLimit: JsonField = JsonMissing.of(), + @JsonProperty("grace_period_days") + @ExcludeMissing + gracePeriodDays: JsonField = JsonMissing.of(), + @JsonProperty("statement_day_of_month") + @ExcludeMissing + statementDayOfMonth: JsonField = JsonMissing.of(), + @JsonProperty("statement_payment_type") + @ExcludeMissing + statementPaymentType: JsonField = JsonMissing.of(), + @JsonProperty("maturity_date") + @ExcludeMissing + maturityDate: JsonField = JsonMissing.of(), + ) : this( + creditLimit, + gracePeriodDays, + statementDayOfMonth, + statementPaymentType, + maturityDate, + mutableMapOf(), + ) + + /** + * The maximum amount of money that can be drawn from the Account. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditLimit(): Long = creditLimit.getRequired("credit_limit") + + /** + * The number of days after the statement date that the Account can be past due before being + * considered delinquent. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun gracePeriodDays(): Long = gracePeriodDays.getRequired("grace_period_days") + + /** + * The day of the month on which the loan statement is generated. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun statementDayOfMonth(): Long = statementDayOfMonth.getRequired("statement_day_of_month") + + /** + * The type of statement payment for the account. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun statementPaymentType(): StatementPaymentType = + statementPaymentType.getRequired("statement_payment_type") + + /** + * The date on which the loan matures. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun maturityDate(): Optional = maturityDate.getOptional("maturity_date") + + /** + * Returns the raw JSON value of [creditLimit]. + * + * Unlike [creditLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_limit") + @ExcludeMissing + fun _creditLimit(): JsonField = creditLimit + + /** + * Returns the raw JSON value of [gracePeriodDays]. + * + * Unlike [gracePeriodDays], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grace_period_days") + @ExcludeMissing + fun _gracePeriodDays(): JsonField = gracePeriodDays + + /** + * Returns the raw JSON value of [statementDayOfMonth]. + * + * Unlike [statementDayOfMonth], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("statement_day_of_month") + @ExcludeMissing + fun _statementDayOfMonth(): JsonField = statementDayOfMonth + + /** + * Returns the raw JSON value of [statementPaymentType]. + * + * Unlike [statementPaymentType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("statement_payment_type") + @ExcludeMissing + fun _statementPaymentType(): JsonField = statementPaymentType + + /** + * Returns the raw JSON value of [maturityDate]. + * + * Unlike [maturityDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("maturity_date") + @ExcludeMissing + fun _maturityDate(): JsonField = maturityDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Loan]. + * + * The following fields are required: + * ```java + * .creditLimit() + * .gracePeriodDays() + * .statementDayOfMonth() + * .statementPaymentType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Loan]. */ + class Builder internal constructor() { + + private var creditLimit: JsonField? = null + private var gracePeriodDays: JsonField? = null + private var statementDayOfMonth: JsonField? = null + private var statementPaymentType: JsonField? = null + private var maturityDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(loan: Loan) = apply { + creditLimit = loan.creditLimit + gracePeriodDays = loan.gracePeriodDays + statementDayOfMonth = loan.statementDayOfMonth + statementPaymentType = loan.statementPaymentType + maturityDate = loan.maturityDate + additionalProperties = loan.additionalProperties.toMutableMap() + } + + /** The maximum amount of money that can be drawn from the Account. */ + fun creditLimit(creditLimit: Long) = creditLimit(JsonField.of(creditLimit)) + + /** + * Sets [Builder.creditLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.creditLimit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditLimit(creditLimit: JsonField) = apply { this.creditLimit = creditLimit } + + /** + * The number of days after the statement date that the Account can be past due before + * being considered delinquent. + */ + fun gracePeriodDays(gracePeriodDays: Long) = + gracePeriodDays(JsonField.of(gracePeriodDays)) + + /** + * Sets [Builder.gracePeriodDays] to an arbitrary JSON value. + * + * You should usually call [Builder.gracePeriodDays] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gracePeriodDays(gracePeriodDays: JsonField) = apply { + this.gracePeriodDays = gracePeriodDays + } + + /** The day of the month on which the loan statement is generated. */ + fun statementDayOfMonth(statementDayOfMonth: Long) = + statementDayOfMonth(JsonField.of(statementDayOfMonth)) + + /** + * Sets [Builder.statementDayOfMonth] to an arbitrary JSON value. + * + * You should usually call [Builder.statementDayOfMonth] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statementDayOfMonth(statementDayOfMonth: JsonField) = apply { + this.statementDayOfMonth = statementDayOfMonth + } + + /** The type of statement payment for the account. */ + fun statementPaymentType(statementPaymentType: StatementPaymentType) = + statementPaymentType(JsonField.of(statementPaymentType)) + + /** + * Sets [Builder.statementPaymentType] to an arbitrary JSON value. + * + * You should usually call [Builder.statementPaymentType] with a well-typed + * [StatementPaymentType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun statementPaymentType(statementPaymentType: JsonField) = + apply { + this.statementPaymentType = statementPaymentType + } + + /** The date on which the loan matures. */ + fun maturityDate(maturityDate: LocalDate) = maturityDate(JsonField.of(maturityDate)) + + /** + * Sets [Builder.maturityDate] to an arbitrary JSON value. + * + * You should usually call [Builder.maturityDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maturityDate(maturityDate: JsonField) = apply { + this.maturityDate = maturityDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Loan]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .creditLimit() + * .gracePeriodDays() + * .statementDayOfMonth() + * .statementPaymentType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Loan = + Loan( + checkRequired("creditLimit", creditLimit), + checkRequired("gracePeriodDays", gracePeriodDays), + checkRequired("statementDayOfMonth", statementDayOfMonth), + checkRequired("statementPaymentType", statementPaymentType), + maturityDate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Loan = apply { + if (validated) { + return@apply + } + + creditLimit() + gracePeriodDays() + statementDayOfMonth() + statementPaymentType().validate() + maturityDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (creditLimit.asKnown().isPresent) 1 else 0) + + (if (gracePeriodDays.asKnown().isPresent) 1 else 0) + + (if (statementDayOfMonth.asKnown().isPresent) 1 else 0) + + (statementPaymentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (maturityDate.asKnown().isPresent) 1 else 0) + + /** The type of statement payment for the account. */ + class StatementPaymentType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + /** + * The borrower must pay the full balance of the loan at the end of the statement + * period. + */ + @JvmField val BALANCE = of("balance") + + /** + * The borrower must pay the accrued interest at the end of the statement period. + */ + @JvmField val INTEREST_UNTIL_MATURITY = of("interest_until_maturity") + + @JvmStatic fun of(value: String) = StatementPaymentType(JsonField.of(value)) + } + + /** An enum containing [StatementPaymentType]'s known values. */ + enum class Known { + /** + * The borrower must pay the full balance of the loan at the end of the statement + * period. + */ + BALANCE, + /** + * The borrower must pay the accrued interest at the end of the statement period. + */ + INTEREST_UNTIL_MATURITY, + } + + /** + * An enum containing [StatementPaymentType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [StatementPaymentType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** + * The borrower must pay the full balance of the loan at the end of the statement + * period. + */ + BALANCE, + /** + * The borrower must pay the accrued interest at the end of the statement period. + */ + INTEREST_UNTIL_MATURITY, + /** + * An enum member indicating that [StatementPaymentType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BALANCE -> Value.BALANCE + INTEREST_UNTIL_MATURITY -> Value.INTEREST_UNTIL_MATURITY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BALANCE -> Known.BALANCE + INTEREST_UNTIL_MATURITY -> Known.INTEREST_UNTIL_MATURITY + else -> + throw IncreaseInvalidDataException("Unknown StatementPaymentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): StatementPaymentType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StatementPaymentType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Loan && + creditLimit == other.creditLimit && + gracePeriodDays == other.gracePeriodDays && + statementDayOfMonth == other.statementDayOfMonth && + statementPaymentType == other.statementPaymentType && + maturityDate == other.maturityDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + creditLimit, + gracePeriodDays, + statementDayOfMonth, + statementPaymentType, + maturityDate, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{name=$name, entityId=$entityId, informationalEntityId=$informationalEntityId, programId=$programId, additionalProperties=$additionalProperties}" + "Loan{creditLimit=$creditLimit, gracePeriodDays=$gracePeriodDays, statementDayOfMonth=$statementDayOfMonth, statementPaymentType=$statementPaymentType, maturityDate=$maturityDate, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/AccountUpdateParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/AccountUpdateParams.kt index 08071586c..aaedb4915 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/AccountUpdateParams.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/AccountUpdateParams.kt @@ -11,6 +11,7 @@ import com.increase.api.core.JsonField import com.increase.api.core.JsonMissing import com.increase.api.core.JsonValue import com.increase.api.core.Params +import com.increase.api.core.checkRequired import com.increase.api.core.http.Headers import com.increase.api.core.http.QueryParams import com.increase.api.errors.IncreaseInvalidDataException @@ -31,6 +32,14 @@ private constructor( /** The identifier of the Account to update. */ fun accountId(): Optional = Optional.ofNullable(accountId) + /** + * The loan details for the account. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loan(): Optional = body.loan() + /** * The new name of the Account. * @@ -39,6 +48,13 @@ private constructor( */ fun name(): Optional = body.name() + /** + * Returns the raw JSON value of [loan]. + * + * Unlike [loan], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _loan(): JsonField = body._loan() + /** * Returns the raw JSON value of [name]. * @@ -91,10 +107,22 @@ private constructor( * * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: + * - [loan] * - [name] */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** The loan details for the account. */ + fun loan(loan: Loan) = apply { body.loan(loan) } + + /** + * Sets [Builder.loan] to an arbitrary JSON value. + * + * You should usually call [Builder.loan] with a well-typed [Loan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun loan(loan: JsonField) = apply { body.loan(loan) } + /** The new name of the Account. */ fun name(name: String) = apply { body.name(name) } @@ -252,14 +280,24 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val loan: JsonField, private val name: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() - ) : this(name, mutableMapOf()) + @JsonProperty("loan") @ExcludeMissing loan: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(loan, name, mutableMapOf()) + + /** + * The loan details for the account. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun loan(): Optional = loan.getOptional("loan") /** * The new name of the Account. @@ -269,6 +307,13 @@ private constructor( */ fun name(): Optional = name.getOptional("name") + /** + * Returns the raw JSON value of [loan]. + * + * Unlike [loan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loan") @ExcludeMissing fun _loan(): JsonField = loan + /** * Returns the raw JSON value of [name]. * @@ -297,15 +342,29 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var loan: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { + loan = body.loan name = body.name additionalProperties = body.additionalProperties.toMutableMap() } + /** The loan details for the account. */ + fun loan(loan: Loan) = loan(JsonField.of(loan)) + + /** + * Sets [Builder.loan] to an arbitrary JSON value. + * + * You should usually call [Builder.loan] with a well-typed [Loan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loan(loan: JsonField) = apply { this.loan = loan } + /** The new name of the Account. */ fun name(name: String) = name(JsonField.of(name)) @@ -342,7 +401,7 @@ private constructor( * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Body = Body(name, additionalProperties.toMutableMap()) + fun build(): Body = Body(loan, name, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -352,6 +411,7 @@ private constructor( return@apply } + loan().ifPresent { it.validate() } name() validated = true } @@ -370,7 +430,9 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun validity(): Int = + (loan.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -378,15 +440,178 @@ private constructor( } return other is Body && + loan == other.loan && name == other.name && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(loan, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{loan=$loan, name=$name, additionalProperties=$additionalProperties}" + } + + /** The loan details for the account. */ + class Loan + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val creditLimit: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credit_limit") + @ExcludeMissing + creditLimit: JsonField = JsonMissing.of() + ) : this(creditLimit, mutableMapOf()) + + /** + * The maximum amount of money that can be drawn from the Account. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditLimit(): Long = creditLimit.getRequired("credit_limit") + + /** + * Returns the raw JSON value of [creditLimit]. + * + * Unlike [creditLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_limit") + @ExcludeMissing + fun _creditLimit(): JsonField = creditLimit + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Loan]. + * + * The following fields are required: + * ```java + * .creditLimit() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Loan]. */ + class Builder internal constructor() { + + private var creditLimit: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(loan: Loan) = apply { + creditLimit = loan.creditLimit + additionalProperties = loan.additionalProperties.toMutableMap() + } + + /** The maximum amount of money that can be drawn from the Account. */ + fun creditLimit(creditLimit: Long) = creditLimit(JsonField.of(creditLimit)) + + /** + * Sets [Builder.creditLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.creditLimit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditLimit(creditLimit: JsonField) = apply { this.creditLimit = creditLimit } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Loan]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .creditLimit() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Loan = + Loan(checkRequired("creditLimit", creditLimit), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Loan = apply { + if (validated) { + return@apply + } + + creditLimit() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (creditLimit.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Loan && + creditLimit == other.creditLimit && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(creditLimit, additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Loan{creditLimit=$creditLimit, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/BalanceLookup.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/BalanceLookup.kt index b818c0609..91c5f8aa6 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/BalanceLookup.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/accounts/BalanceLookup.kt @@ -13,8 +13,10 @@ import com.increase.api.core.JsonMissing import com.increase.api.core.JsonValue import com.increase.api.core.checkRequired import com.increase.api.errors.IncreaseInvalidDataException +import java.time.OffsetDateTime import java.util.Collections import java.util.Objects +import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Represents a request to lookup the balance of an Account at a given point in time. */ @@ -24,6 +26,7 @@ private constructor( private val accountId: JsonField, private val availableBalance: JsonField, private val currentBalance: JsonField, + private val loan: JsonField, private val type: JsonField, private val additionalProperties: MutableMap, ) { @@ -37,8 +40,9 @@ private constructor( @JsonProperty("current_balance") @ExcludeMissing currentBalance: JsonField = JsonMissing.of(), + @JsonProperty("loan") @ExcludeMissing loan: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(accountId, availableBalance, currentBalance, type, mutableMapOf()) + ) : this(accountId, availableBalance, currentBalance, loan, type, mutableMapOf()) /** * The identifier for the account for which the balance was queried. @@ -66,6 +70,14 @@ private constructor( */ fun currentBalance(): Long = currentBalance.getRequired("current_balance") + /** + * The loan balances for the Account. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loan(): Optional = loan.getOptional("loan") + /** * A constant representing the object's type. For this resource it will always be * `balance_lookup`. @@ -101,6 +113,13 @@ private constructor( @ExcludeMissing fun _currentBalance(): JsonField = currentBalance + /** + * Returns the raw JSON value of [loan]. + * + * Unlike [loan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loan") @ExcludeMissing fun _loan(): JsonField = loan + /** * Returns the raw JSON value of [type]. * @@ -130,6 +149,7 @@ private constructor( * .accountId() * .availableBalance() * .currentBalance() + * .loan() * .type() * ``` */ @@ -142,6 +162,7 @@ private constructor( private var accountId: JsonField? = null private var availableBalance: JsonField? = null private var currentBalance: JsonField? = null + private var loan: JsonField? = null private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -150,6 +171,7 @@ private constructor( accountId = balanceLookup.accountId availableBalance = balanceLookup.availableBalance currentBalance = balanceLookup.currentBalance + loan = balanceLookup.loan type = balanceLookup.type additionalProperties = balanceLookup.additionalProperties.toMutableMap() } @@ -201,6 +223,20 @@ private constructor( this.currentBalance = currentBalance } + /** The loan balances for the Account. */ + fun loan(loan: Loan?) = loan(JsonField.ofNullable(loan)) + + /** Alias for calling [Builder.loan] with `loan.orElse(null)`. */ + fun loan(loan: Optional) = loan(loan.getOrNull()) + + /** + * Sets [Builder.loan] to an arbitrary JSON value. + * + * You should usually call [Builder.loan] with a well-typed [Loan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun loan(loan: JsonField) = apply { this.loan = loan } + /** * A constant representing the object's type. For this resource it will always be * `balance_lookup`. @@ -244,6 +280,7 @@ private constructor( * .accountId() * .availableBalance() * .currentBalance() + * .loan() * .type() * ``` * @@ -254,6 +291,7 @@ private constructor( checkRequired("accountId", accountId), checkRequired("availableBalance", availableBalance), checkRequired("currentBalance", currentBalance), + checkRequired("loan", loan), checkRequired("type", type), additionalProperties.toMutableMap(), ) @@ -269,6 +307,7 @@ private constructor( accountId() availableBalance() currentBalance() + loan().ifPresent { it.validate() } type().validate() validated = true } @@ -291,8 +330,265 @@ private constructor( (if (accountId.asKnown().isPresent) 1 else 0) + (if (availableBalance.asKnown().isPresent) 1 else 0) + (if (currentBalance.asKnown().isPresent) 1 else 0) + + (loan.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + /** The loan balances for the Account. */ + class Loan + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dueAt: JsonField, + private val dueBalance: JsonField, + private val pastDueBalance: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("due_at") + @ExcludeMissing + dueAt: JsonField = JsonMissing.of(), + @JsonProperty("due_balance") + @ExcludeMissing + dueBalance: JsonField = JsonMissing.of(), + @JsonProperty("past_due_balance") + @ExcludeMissing + pastDueBalance: JsonField = JsonMissing.of(), + ) : this(dueAt, dueBalance, pastDueBalance, mutableMapOf()) + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the loan payment is + * due. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dueAt(): Optional = dueAt.getOptional("due_at") + + /** + * The total amount due on the loan. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dueBalance(): Long = dueBalance.getRequired("due_balance") + + /** + * The amount past due on the loan. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pastDueBalance(): Long = pastDueBalance.getRequired("past_due_balance") + + /** + * Returns the raw JSON value of [dueAt]. + * + * Unlike [dueAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("due_at") @ExcludeMissing fun _dueAt(): JsonField = dueAt + + /** + * Returns the raw JSON value of [dueBalance]. + * + * Unlike [dueBalance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("due_balance") @ExcludeMissing fun _dueBalance(): JsonField = dueBalance + + /** + * Returns the raw JSON value of [pastDueBalance]. + * + * Unlike [pastDueBalance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("past_due_balance") + @ExcludeMissing + fun _pastDueBalance(): JsonField = pastDueBalance + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Loan]. + * + * The following fields are required: + * ```java + * .dueAt() + * .dueBalance() + * .pastDueBalance() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Loan]. */ + class Builder internal constructor() { + + private var dueAt: JsonField? = null + private var dueBalance: JsonField? = null + private var pastDueBalance: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(loan: Loan) = apply { + dueAt = loan.dueAt + dueBalance = loan.dueBalance + pastDueBalance = loan.pastDueBalance + additionalProperties = loan.additionalProperties.toMutableMap() + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the loan payment + * is due. + */ + fun dueAt(dueAt: OffsetDateTime?) = dueAt(JsonField.ofNullable(dueAt)) + + /** Alias for calling [Builder.dueAt] with `dueAt.orElse(null)`. */ + fun dueAt(dueAt: Optional) = dueAt(dueAt.getOrNull()) + + /** + * Sets [Builder.dueAt] to an arbitrary JSON value. + * + * You should usually call [Builder.dueAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dueAt(dueAt: JsonField) = apply { this.dueAt = dueAt } + + /** The total amount due on the loan. */ + fun dueBalance(dueBalance: Long) = dueBalance(JsonField.of(dueBalance)) + + /** + * Sets [Builder.dueBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.dueBalance] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dueBalance(dueBalance: JsonField) = apply { this.dueBalance = dueBalance } + + /** The amount past due on the loan. */ + fun pastDueBalance(pastDueBalance: Long) = pastDueBalance(JsonField.of(pastDueBalance)) + + /** + * Sets [Builder.pastDueBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.pastDueBalance] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pastDueBalance(pastDueBalance: JsonField) = apply { + this.pastDueBalance = pastDueBalance + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Loan]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dueAt() + * .dueBalance() + * .pastDueBalance() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Loan = + Loan( + checkRequired("dueAt", dueAt), + checkRequired("dueBalance", dueBalance), + checkRequired("pastDueBalance", pastDueBalance), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Loan = apply { + if (validated) { + return@apply + } + + dueAt() + dueBalance() + pastDueBalance() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dueAt.asKnown().isPresent) 1 else 0) + + (if (dueBalance.asKnown().isPresent) 1 else 0) + + (if (pastDueBalance.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Loan && + dueAt == other.dueAt && + dueBalance == other.dueBalance && + pastDueBalance == other.pastDueBalance && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dueAt, dueBalance, pastDueBalance, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Loan{dueAt=$dueAt, dueBalance=$dueBalance, pastDueBalance=$pastDueBalance, additionalProperties=$additionalProperties}" + } + /** * A constant representing the object's type. For this resource it will always be * `balance_lookup`. @@ -427,16 +723,17 @@ private constructor( accountId == other.accountId && availableBalance == other.availableBalance && currentBalance == other.currentBalance && + loan == other.loan && type == other.type && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(accountId, availableBalance, currentBalance, type, additionalProperties) + Objects.hash(accountId, availableBalance, currentBalance, loan, type, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "BalanceLookup{accountId=$accountId, availableBalance=$availableBalance, currentBalance=$currentBalance, type=$type, additionalProperties=$additionalProperties}" + "BalanceLookup{accountId=$accountId, availableBalance=$availableBalance, currentBalance=$currentBalance, loan=$loan, type=$type, additionalProperties=$additionalProperties}" } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/accountstatements/AccountStatement.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/accountstatements/AccountStatement.kt index 2d367f4ce..131405744 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/accountstatements/AccountStatement.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/accountstatements/AccountStatement.kt @@ -16,6 +16,7 @@ import com.increase.api.errors.IncreaseInvalidDataException import java.time.OffsetDateTime import java.util.Collections import java.util.Objects +import java.util.Optional import kotlin.jvm.optionals.getOrNull /** @@ -30,6 +31,7 @@ private constructor( private val createdAt: JsonField, private val endingBalance: JsonField, private val fileId: JsonField, + private val loan: JsonField, private val startingBalance: JsonField, private val statementPeriodEnd: JsonField, private val statementPeriodStart: JsonField, @@ -48,6 +50,7 @@ private constructor( @ExcludeMissing endingBalance: JsonField = JsonMissing.of(), @JsonProperty("file_id") @ExcludeMissing fileId: JsonField = JsonMissing.of(), + @JsonProperty("loan") @ExcludeMissing loan: JsonField = JsonMissing.of(), @JsonProperty("starting_balance") @ExcludeMissing startingBalance: JsonField = JsonMissing.of(), @@ -64,6 +67,7 @@ private constructor( createdAt, endingBalance, fileId, + loan, startingBalance, statementPeriodEnd, statementPeriodStart, @@ -112,6 +116,14 @@ private constructor( */ fun fileId(): String = fileId.getRequired("file_id") + /** + * The loan balances. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loan(): Optional = loan.getOptional("loan") + /** * The Account's balance at the start of its statement period. * @@ -188,6 +200,13 @@ private constructor( */ @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId + /** + * Returns the raw JSON value of [loan]. + * + * Unlike [loan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loan") @ExcludeMissing fun _loan(): JsonField = loan + /** * Returns the raw JSON value of [startingBalance]. * @@ -248,6 +267,7 @@ private constructor( * .createdAt() * .endingBalance() * .fileId() + * .loan() * .startingBalance() * .statementPeriodEnd() * .statementPeriodStart() @@ -265,6 +285,7 @@ private constructor( private var createdAt: JsonField? = null private var endingBalance: JsonField? = null private var fileId: JsonField? = null + private var loan: JsonField? = null private var startingBalance: JsonField? = null private var statementPeriodEnd: JsonField? = null private var statementPeriodStart: JsonField? = null @@ -278,6 +299,7 @@ private constructor( createdAt = accountStatement.createdAt endingBalance = accountStatement.endingBalance fileId = accountStatement.fileId + loan = accountStatement.loan startingBalance = accountStatement.startingBalance statementPeriodEnd = accountStatement.statementPeriodEnd statementPeriodStart = accountStatement.statementPeriodStart @@ -348,6 +370,20 @@ private constructor( */ fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + /** The loan balances. */ + fun loan(loan: Loan?) = loan(JsonField.ofNullable(loan)) + + /** Alias for calling [Builder.loan] with `loan.orElse(null)`. */ + fun loan(loan: Optional) = loan(loan.getOrNull()) + + /** + * Sets [Builder.loan] to an arbitrary JSON value. + * + * You should usually call [Builder.loan] with a well-typed [Loan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun loan(loan: JsonField) = apply { this.loan = loan } + /** The Account's balance at the start of its statement period. */ fun startingBalance(startingBalance: Long) = startingBalance(JsonField.of(startingBalance)) @@ -443,6 +479,7 @@ private constructor( * .createdAt() * .endingBalance() * .fileId() + * .loan() * .startingBalance() * .statementPeriodEnd() * .statementPeriodStart() @@ -458,6 +495,7 @@ private constructor( checkRequired("createdAt", createdAt), checkRequired("endingBalance", endingBalance), checkRequired("fileId", fileId), + checkRequired("loan", loan), checkRequired("startingBalance", startingBalance), checkRequired("statementPeriodEnd", statementPeriodEnd), checkRequired("statementPeriodStart", statementPeriodStart), @@ -478,6 +516,7 @@ private constructor( createdAt() endingBalance() fileId() + loan().ifPresent { it.validate() } startingBalance() statementPeriodEnd() statementPeriodStart() @@ -505,11 +544,268 @@ private constructor( (if (createdAt.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (if (fileId.asKnown().isPresent) 1 else 0) + + (loan.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) + (if (statementPeriodEnd.asKnown().isPresent) 1 else 0) + (if (statementPeriodStart.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + /** The loan balances. */ + class Loan + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val dueAt: JsonField, + private val dueBalance: JsonField, + private val pastDueBalance: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("due_at") + @ExcludeMissing + dueAt: JsonField = JsonMissing.of(), + @JsonProperty("due_balance") + @ExcludeMissing + dueBalance: JsonField = JsonMissing.of(), + @JsonProperty("past_due_balance") + @ExcludeMissing + pastDueBalance: JsonField = JsonMissing.of(), + ) : this(dueAt, dueBalance, pastDueBalance, mutableMapOf()) + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the loan payment is + * due. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dueAt(): Optional = dueAt.getOptional("due_at") + + /** + * The total amount due on the loan. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dueBalance(): Long = dueBalance.getRequired("due_balance") + + /** + * The amount past due on the loan. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pastDueBalance(): Long = pastDueBalance.getRequired("past_due_balance") + + /** + * Returns the raw JSON value of [dueAt]. + * + * Unlike [dueAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("due_at") @ExcludeMissing fun _dueAt(): JsonField = dueAt + + /** + * Returns the raw JSON value of [dueBalance]. + * + * Unlike [dueBalance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("due_balance") @ExcludeMissing fun _dueBalance(): JsonField = dueBalance + + /** + * Returns the raw JSON value of [pastDueBalance]. + * + * Unlike [pastDueBalance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("past_due_balance") + @ExcludeMissing + fun _pastDueBalance(): JsonField = pastDueBalance + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Loan]. + * + * The following fields are required: + * ```java + * .dueAt() + * .dueBalance() + * .pastDueBalance() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Loan]. */ + class Builder internal constructor() { + + private var dueAt: JsonField? = null + private var dueBalance: JsonField? = null + private var pastDueBalance: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(loan: Loan) = apply { + dueAt = loan.dueAt + dueBalance = loan.dueBalance + pastDueBalance = loan.pastDueBalance + additionalProperties = loan.additionalProperties.toMutableMap() + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the loan payment + * is due. + */ + fun dueAt(dueAt: OffsetDateTime?) = dueAt(JsonField.ofNullable(dueAt)) + + /** Alias for calling [Builder.dueAt] with `dueAt.orElse(null)`. */ + fun dueAt(dueAt: Optional) = dueAt(dueAt.getOrNull()) + + /** + * Sets [Builder.dueAt] to an arbitrary JSON value. + * + * You should usually call [Builder.dueAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dueAt(dueAt: JsonField) = apply { this.dueAt = dueAt } + + /** The total amount due on the loan. */ + fun dueBalance(dueBalance: Long) = dueBalance(JsonField.of(dueBalance)) + + /** + * Sets [Builder.dueBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.dueBalance] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dueBalance(dueBalance: JsonField) = apply { this.dueBalance = dueBalance } + + /** The amount past due on the loan. */ + fun pastDueBalance(pastDueBalance: Long) = pastDueBalance(JsonField.of(pastDueBalance)) + + /** + * Sets [Builder.pastDueBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.pastDueBalance] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pastDueBalance(pastDueBalance: JsonField) = apply { + this.pastDueBalance = pastDueBalance + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Loan]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .dueAt() + * .dueBalance() + * .pastDueBalance() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Loan = + Loan( + checkRequired("dueAt", dueAt), + checkRequired("dueBalance", dueBalance), + checkRequired("pastDueBalance", pastDueBalance), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Loan = apply { + if (validated) { + return@apply + } + + dueAt() + dueBalance() + pastDueBalance() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (dueAt.asKnown().isPresent) 1 else 0) + + (if (dueBalance.asKnown().isPresent) 1 else 0) + + (if (pastDueBalance.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Loan && + dueAt == other.dueAt && + dueBalance == other.dueBalance && + pastDueBalance == other.pastDueBalance && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(dueAt, dueBalance, pastDueBalance, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Loan{dueAt=$dueAt, dueBalance=$dueBalance, pastDueBalance=$pastDueBalance, additionalProperties=$additionalProperties}" + } + /** * A constant representing the object's type. For this resource it will always be * `account_statement`. @@ -646,6 +942,7 @@ private constructor( createdAt == other.createdAt && endingBalance == other.endingBalance && fileId == other.fileId && + loan == other.loan && startingBalance == other.startingBalance && statementPeriodEnd == other.statementPeriodEnd && statementPeriodStart == other.statementPeriodStart && @@ -660,6 +957,7 @@ private constructor( createdAt, endingBalance, fileId, + loan, startingBalance, statementPeriodEnd, statementPeriodStart, @@ -671,5 +969,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AccountStatement{id=$id, accountId=$accountId, createdAt=$createdAt, endingBalance=$endingBalance, fileId=$fileId, startingBalance=$startingBalance, statementPeriodEnd=$statementPeriodEnd, statementPeriodStart=$statementPeriodStart, type=$type, additionalProperties=$additionalProperties}" + "AccountStatement{id=$id, accountId=$accountId, createdAt=$createdAt, endingBalance=$endingBalance, fileId=$fileId, loan=$loan, startingBalance=$startingBalance, statementPeriodEnd=$statementPeriodEnd, statementPeriodStart=$statementPeriodStart, type=$type, additionalProperties=$additionalProperties}" } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/programs/Program.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/programs/Program.kt index d38738041..20ae373c9 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/programs/Program.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/programs/Program.kt @@ -34,6 +34,7 @@ private constructor( private val createdAt: JsonField, private val defaultDigitalCardProfileId: JsonField, private val interestRate: JsonField, + private val lending: JsonField, private val name: JsonField, private val type: JsonField, private val updatedAt: JsonField, @@ -56,6 +57,7 @@ private constructor( @JsonProperty("interest_rate") @ExcludeMissing interestRate: JsonField = JsonMissing.of(), + @JsonProperty("lending") @ExcludeMissing lending: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("updated_at") @@ -68,6 +70,7 @@ private constructor( createdAt, defaultDigitalCardProfileId, interestRate, + lending, name, type, updatedAt, @@ -124,6 +127,14 @@ private constructor( */ fun interestRate(): String = interestRate.getRequired("interest_rate") + /** + * The lending details for the program. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lending(): Optional = lending.getOptional("lending") + /** * The name of the Program. * @@ -201,6 +212,13 @@ private constructor( @ExcludeMissing fun _interestRate(): JsonField = interestRate + /** + * Returns the raw JSON value of [lending]. + * + * Unlike [lending], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lending") @ExcludeMissing fun _lending(): JsonField = lending + /** * Returns the raw JSON value of [name]. * @@ -249,6 +267,7 @@ private constructor( * .createdAt() * .defaultDigitalCardProfileId() * .interestRate() + * .lending() * .name() * .type() * .updatedAt() @@ -266,6 +285,7 @@ private constructor( private var createdAt: JsonField? = null private var defaultDigitalCardProfileId: JsonField? = null private var interestRate: JsonField? = null + private var lending: JsonField? = null private var name: JsonField? = null private var type: JsonField? = null private var updatedAt: JsonField? = null @@ -279,6 +299,7 @@ private constructor( createdAt = program.createdAt defaultDigitalCardProfileId = program.defaultDigitalCardProfileId interestRate = program.interestRate + lending = program.lending name = program.name type = program.type updatedAt = program.updatedAt @@ -381,6 +402,20 @@ private constructor( this.interestRate = interestRate } + /** The lending details for the program. */ + fun lending(lending: Lending?) = lending(JsonField.ofNullable(lending)) + + /** Alias for calling [Builder.lending] with `lending.orElse(null)`. */ + fun lending(lending: Optional) = lending(lending.getOrNull()) + + /** + * Sets [Builder.lending] to an arbitrary JSON value. + * + * You should usually call [Builder.lending] with a well-typed [Lending] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun lending(lending: JsonField) = apply { this.lending = lending } + /** The name of the Program. */ fun name(name: String) = name(JsonField.of(name)) @@ -452,6 +487,7 @@ private constructor( * .createdAt() * .defaultDigitalCardProfileId() * .interestRate() + * .lending() * .name() * .type() * .updatedAt() @@ -467,6 +503,7 @@ private constructor( checkRequired("createdAt", createdAt), checkRequired("defaultDigitalCardProfileId", defaultDigitalCardProfileId), checkRequired("interestRate", interestRate), + checkRequired("lending", lending), checkRequired("name", name), checkRequired("type", type), checkRequired("updatedAt", updatedAt), @@ -487,6 +524,7 @@ private constructor( createdAt() defaultDigitalCardProfileId() interestRate() + lending().ifPresent { it.validate() } name() type().validate() updatedAt() @@ -514,6 +552,7 @@ private constructor( (if (createdAt.asKnown().isPresent) 1 else 0) + (if (defaultDigitalCardProfileId.asKnown().isPresent) 1 else 0) + (if (interestRate.asKnown().isPresent) 1 else 0) + + (lending.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) @@ -661,6 +700,178 @@ private constructor( override fun toString() = value.toString() } + /** The lending details for the program. */ + class Lending + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val maximumExtendableCredit: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("maximum_extendable_credit") + @ExcludeMissing + maximumExtendableCredit: JsonField = JsonMissing.of() + ) : this(maximumExtendableCredit, mutableMapOf()) + + /** + * The maximum extendable credit of the program. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun maximumExtendableCredit(): Long = + maximumExtendableCredit.getRequired("maximum_extendable_credit") + + /** + * Returns the raw JSON value of [maximumExtendableCredit]. + * + * Unlike [maximumExtendableCredit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("maximum_extendable_credit") + @ExcludeMissing + fun _maximumExtendableCredit(): JsonField = maximumExtendableCredit + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Lending]. + * + * The following fields are required: + * ```java + * .maximumExtendableCredit() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Lending]. */ + class Builder internal constructor() { + + private var maximumExtendableCredit: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(lending: Lending) = apply { + maximumExtendableCredit = lending.maximumExtendableCredit + additionalProperties = lending.additionalProperties.toMutableMap() + } + + /** The maximum extendable credit of the program. */ + fun maximumExtendableCredit(maximumExtendableCredit: Long) = + maximumExtendableCredit(JsonField.of(maximumExtendableCredit)) + + /** + * Sets [Builder.maximumExtendableCredit] to an arbitrary JSON value. + * + * You should usually call [Builder.maximumExtendableCredit] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun maximumExtendableCredit(maximumExtendableCredit: JsonField) = apply { + this.maximumExtendableCredit = maximumExtendableCredit + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Lending]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .maximumExtendableCredit() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Lending = + Lending( + checkRequired("maximumExtendableCredit", maximumExtendableCredit), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Lending = apply { + if (validated) { + return@apply + } + + maximumExtendableCredit() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (maximumExtendableCredit.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Lending && + maximumExtendableCredit == other.maximumExtendableCredit && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(maximumExtendableCredit, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Lending{maximumExtendableCredit=$maximumExtendableCredit, additionalProperties=$additionalProperties}" + } + /** A constant representing the object's type. For this resource it will always be `program`. */ class Type @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -795,6 +1006,7 @@ private constructor( createdAt == other.createdAt && defaultDigitalCardProfileId == other.defaultDigitalCardProfileId && interestRate == other.interestRate && + lending == other.lending && name == other.name && type == other.type && updatedAt == other.updatedAt && @@ -809,6 +1021,7 @@ private constructor( createdAt, defaultDigitalCardProfileId, interestRate, + lending, name, type, updatedAt, @@ -819,5 +1032,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Program{id=$id, bank=$bank, billingAccountId=$billingAccountId, createdAt=$createdAt, defaultDigitalCardProfileId=$defaultDigitalCardProfileId, interestRate=$interestRate, name=$name, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + "Program{id=$id, bank=$bank, billingAccountId=$billingAccountId, createdAt=$createdAt, defaultDigitalCardProfileId=$defaultDigitalCardProfileId, interestRate=$interestRate, lending=$lending, name=$name, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/programs/ProgramCreateParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/programs/ProgramCreateParams.kt index 9d7cbc51f..a354609ff 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/programs/ProgramCreateParams.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/programs/ProgramCreateParams.kt @@ -49,6 +49,14 @@ private constructor( */ fun bank(): Optional = body.bank() + /** + * The maximum extendable credit of the program being added. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lendingMaximumExtendableCredit(): Optional = body.lendingMaximumExtendableCredit() + /** * The identifier of the Account the Program should be added to is for. * @@ -71,6 +79,14 @@ private constructor( */ fun _bank(): JsonField = body._bank() + /** + * Returns the raw JSON value of [lendingMaximumExtendableCredit]. + * + * Unlike [lendingMaximumExtendableCredit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _lendingMaximumExtendableCredit(): JsonField = body._lendingMaximumExtendableCredit() + /** * Returns the raw JSON value of [reserveAccountId]. * @@ -123,6 +139,7 @@ private constructor( * Otherwise, it's more convenient to use the top-level setters instead: * - [name] * - [bank] + * - [lendingMaximumExtendableCredit] * - [reserveAccountId] */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -149,6 +166,23 @@ private constructor( */ fun bank(bank: JsonField) = apply { body.bank(bank) } + /** The maximum extendable credit of the program being added. */ + fun lendingMaximumExtendableCredit(lendingMaximumExtendableCredit: Long) = apply { + body.lendingMaximumExtendableCredit(lendingMaximumExtendableCredit) + } + + /** + * Sets [Builder.lendingMaximumExtendableCredit] to an arbitrary JSON value. + * + * You should usually call [Builder.lendingMaximumExtendableCredit] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lendingMaximumExtendableCredit(lendingMaximumExtendableCredit: JsonField) = + apply { + body.lendingMaximumExtendableCredit(lendingMaximumExtendableCredit) + } + /** The identifier of the Account the Program should be added to is for. */ fun reserveAccountId(reserveAccountId: String) = apply { body.reserveAccountId(reserveAccountId) @@ -313,6 +347,7 @@ private constructor( private constructor( private val name: JsonField, private val bank: JsonField, + private val lendingMaximumExtendableCredit: JsonField, private val reserveAccountId: JsonField, private val additionalProperties: MutableMap, ) { @@ -321,10 +356,13 @@ private constructor( private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("bank") @ExcludeMissing bank: JsonField = JsonMissing.of(), + @JsonProperty("lending_maximum_extendable_credit") + @ExcludeMissing + lendingMaximumExtendableCredit: JsonField = JsonMissing.of(), @JsonProperty("reserve_account_id") @ExcludeMissing reserveAccountId: JsonField = JsonMissing.of(), - ) : this(name, bank, reserveAccountId, mutableMapOf()) + ) : this(name, bank, lendingMaximumExtendableCredit, reserveAccountId, mutableMapOf()) /** * The name of the program being added. @@ -342,6 +380,15 @@ private constructor( */ fun bank(): Optional = bank.getOptional("bank") + /** + * The maximum extendable credit of the program being added. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lendingMaximumExtendableCredit(): Optional = + lendingMaximumExtendableCredit.getOptional("lending_maximum_extendable_credit") + /** * The identifier of the Account the Program should be added to is for. * @@ -365,6 +412,16 @@ private constructor( */ @JsonProperty("bank") @ExcludeMissing fun _bank(): JsonField = bank + /** + * Returns the raw JSON value of [lendingMaximumExtendableCredit]. + * + * Unlike [lendingMaximumExtendableCredit], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("lending_maximum_extendable_credit") + @ExcludeMissing + fun _lendingMaximumExtendableCredit(): JsonField = lendingMaximumExtendableCredit + /** * Returns the raw JSON value of [reserveAccountId]. * @@ -405,6 +462,7 @@ private constructor( private var name: JsonField? = null private var bank: JsonField = JsonMissing.of() + private var lendingMaximumExtendableCredit: JsonField = JsonMissing.of() private var reserveAccountId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -412,6 +470,7 @@ private constructor( internal fun from(body: Body) = apply { name = body.name bank = body.bank + lendingMaximumExtendableCredit = body.lendingMaximumExtendableCredit reserveAccountId = body.reserveAccountId additionalProperties = body.additionalProperties.toMutableMap() } @@ -440,6 +499,22 @@ private constructor( */ fun bank(bank: JsonField) = apply { this.bank = bank } + /** The maximum extendable credit of the program being added. */ + fun lendingMaximumExtendableCredit(lendingMaximumExtendableCredit: Long) = + lendingMaximumExtendableCredit(JsonField.of(lendingMaximumExtendableCredit)) + + /** + * Sets [Builder.lendingMaximumExtendableCredit] to an arbitrary JSON value. + * + * You should usually call [Builder.lendingMaximumExtendableCredit] with a well-typed + * [Long] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lendingMaximumExtendableCredit(lendingMaximumExtendableCredit: JsonField) = + apply { + this.lendingMaximumExtendableCredit = lendingMaximumExtendableCredit + } + /** The identifier of the Account the Program should be added to is for. */ fun reserveAccountId(reserveAccountId: String) = reserveAccountId(JsonField.of(reserveAccountId)) @@ -490,6 +565,7 @@ private constructor( Body( checkRequired("name", name), bank, + lendingMaximumExtendableCredit, reserveAccountId, additionalProperties.toMutableMap(), ) @@ -504,6 +580,7 @@ private constructor( name() bank().ifPresent { it.validate() } + lendingMaximumExtendableCredit() reserveAccountId() validated = true } @@ -526,6 +603,7 @@ private constructor( internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + (bank.asKnown().getOrNull()?.validity() ?: 0) + + (if (lendingMaximumExtendableCredit.asKnown().isPresent) 1 else 0) + (if (reserveAccountId.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -536,18 +614,25 @@ private constructor( return other is Body && name == other.name && bank == other.bank && + lendingMaximumExtendableCredit == other.lendingMaximumExtendableCredit && reserveAccountId == other.reserveAccountId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(name, bank, reserveAccountId, additionalProperties) + Objects.hash( + name, + bank, + lendingMaximumExtendableCredit, + reserveAccountId, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{name=$name, bank=$bank, reserveAccountId=$reserveAccountId, additionalProperties=$additionalProperties}" + "Body{name=$name, bank=$bank, lendingMaximumExtendableCredit=$lendingMaximumExtendableCredit, reserveAccountId=$reserveAccountId, additionalProperties=$additionalProperties}" } /** The bank for the program's accounts, defaults to First Internet Bank. */ diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountCreateParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountCreateParamsTest.kt index 50d8648be..b90541cd6 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountCreateParamsTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountCreateParamsTest.kt @@ -2,6 +2,7 @@ package com.increase.api.models.accounts +import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -12,7 +13,17 @@ internal class AccountCreateParamsTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType(AccountCreateParams.Loan.StatementPaymentType.BALANCE) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() } @@ -23,7 +34,17 @@ internal class AccountCreateParamsTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType(AccountCreateParams.Loan.StatementPaymentType.BALANCE) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() @@ -31,7 +52,18 @@ internal class AccountCreateParamsTest { assertThat(body.name()).isEqualTo("New Account!") assertThat(body.entityId()).contains("entity_n8y8tnk2p9339ti393yi") + assertThat(body.funding()).contains(AccountCreateParams.Funding.LOAN) assertThat(body.informationalEntityId()).contains("informational_entity_id") + assertThat(body.loan()) + .contains( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType(AccountCreateParams.Loan.StatementPaymentType.BALANCE) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) assertThat(body.programId()).contains("program_i2v2os4mwza1oetokh9i") } diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountListPageResponseTest.kt index a9a2fab89..34b128abb 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountListPageResponseTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountListPageResponseTest.kt @@ -24,11 +24,21 @@ internal class AccountListPageResponseTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .currency(Account.Currency.USD) .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(null) .idempotencyKey(null) .informationalEntityId(null) .interestAccrued("0.01") .interestAccruedAt(LocalDate.parse("2020-01-31")) .interestRate("0.055") + .loan( + Account.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .maturityDate(LocalDate.parse("2019-12-27")) + .statementDayOfMonth(0L) + .statementPaymentType(Account.Loan.StatementPaymentType.BALANCE) + .build() + ) .name("My first account!") .programId("program_i2v2os4mwza1oetokh9i") .status(Account.Status.OPEN) @@ -48,11 +58,21 @@ internal class AccountListPageResponseTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .currency(Account.Currency.USD) .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(null) .idempotencyKey(null) .informationalEntityId(null) .interestAccrued("0.01") .interestAccruedAt(LocalDate.parse("2020-01-31")) .interestRate("0.055") + .loan( + Account.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .maturityDate(LocalDate.parse("2019-12-27")) + .statementDayOfMonth(0L) + .statementPaymentType(Account.Loan.StatementPaymentType.BALANCE) + .build() + ) .name("My first account!") .programId("program_i2v2os4mwza1oetokh9i") .status(Account.Status.OPEN) @@ -76,11 +96,21 @@ internal class AccountListPageResponseTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .currency(Account.Currency.USD) .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(null) .idempotencyKey(null) .informationalEntityId(null) .interestAccrued("0.01") .interestAccruedAt(LocalDate.parse("2020-01-31")) .interestRate("0.055") + .loan( + Account.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .maturityDate(LocalDate.parse("2019-12-27")) + .statementDayOfMonth(0L) + .statementPaymentType(Account.Loan.StatementPaymentType.BALANCE) + .build() + ) .name("My first account!") .programId("program_i2v2os4mwza1oetokh9i") .status(Account.Status.OPEN) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountTest.kt index 04a6ca32f..e463c7198 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountTest.kt @@ -22,11 +22,21 @@ internal class AccountTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .currency(Account.Currency.USD) .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(null) .idempotencyKey(null) .informationalEntityId(null) .interestAccrued("0.01") .interestAccruedAt(LocalDate.parse("2020-01-31")) .interestRate("0.055") + .loan( + Account.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .maturityDate(LocalDate.parse("2019-12-27")) + .statementDayOfMonth(0L) + .statementPaymentType(Account.Loan.StatementPaymentType.BALANCE) + .build() + ) .name("My first account!") .programId("program_i2v2os4mwza1oetokh9i") .status(Account.Status.OPEN) @@ -40,11 +50,22 @@ internal class AccountTest { assertThat(account.createdAt()).isEqualTo(OffsetDateTime.parse("2020-01-31T23:59:59Z")) assertThat(account.currency()).isEqualTo(Account.Currency.USD) assertThat(account.entityId()).isEqualTo("entity_n8y8tnk2p9339ti393yi") + assertThat(account.funding()).isEmpty assertThat(account.idempotencyKey()).isEmpty assertThat(account.informationalEntityId()).isEmpty assertThat(account.interestAccrued()).isEqualTo("0.01") assertThat(account.interestAccruedAt()).contains(LocalDate.parse("2020-01-31")) assertThat(account.interestRate()).isEqualTo("0.055") + assertThat(account.loan()) + .contains( + Account.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .maturityDate(LocalDate.parse("2019-12-27")) + .statementDayOfMonth(0L) + .statementPaymentType(Account.Loan.StatementPaymentType.BALANCE) + .build() + ) assertThat(account.name()).isEqualTo("My first account!") assertThat(account.programId()).isEqualTo("program_i2v2os4mwza1oetokh9i") assertThat(account.status()).isEqualTo(Account.Status.OPEN) @@ -63,11 +84,21 @@ internal class AccountTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .currency(Account.Currency.USD) .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(null) .idempotencyKey(null) .informationalEntityId(null) .interestAccrued("0.01") .interestAccruedAt(LocalDate.parse("2020-01-31")) .interestRate("0.055") + .loan( + Account.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .maturityDate(LocalDate.parse("2019-12-27")) + .statementDayOfMonth(0L) + .statementPaymentType(Account.Loan.StatementPaymentType.BALANCE) + .build() + ) .name("My first account!") .programId("program_i2v2os4mwza1oetokh9i") .status(Account.Status.OPEN) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountUpdateParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountUpdateParamsTest.kt index bd0e0b3e9..81307daa2 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountUpdateParamsTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/AccountUpdateParamsTest.kt @@ -11,6 +11,7 @@ internal class AccountUpdateParamsTest { fun create() { AccountUpdateParams.builder() .accountId("account_in71c4amph0vgo2qllky") + .loan(AccountUpdateParams.Loan.builder().creditLimit(0L).build()) .name("My renamed account") .build() } @@ -29,11 +30,13 @@ internal class AccountUpdateParamsTest { val params = AccountUpdateParams.builder() .accountId("account_in71c4amph0vgo2qllky") + .loan(AccountUpdateParams.Loan.builder().creditLimit(0L).build()) .name("My renamed account") .build() val body = params._body() + assertThat(body.loan()).contains(AccountUpdateParams.Loan.builder().creditLimit(0L).build()) assertThat(body.name()).contains("My renamed account") } diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/BalanceLookupTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/BalanceLookupTest.kt index b509bd4fa..b4c6ae88a 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/BalanceLookupTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/accounts/BalanceLookupTest.kt @@ -4,6 +4,7 @@ package com.increase.api.models.accounts import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.increase.api.core.jsonMapper +import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -16,12 +17,27 @@ internal class BalanceLookupTest { .accountId("account_in71c4amph0vgo2qllky") .availableBalance(100L) .currentBalance(100L) + .loan( + BalanceLookup.Loan.builder() + .dueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dueBalance(0L) + .pastDueBalance(0L) + .build() + ) .type(BalanceLookup.Type.BALANCE_LOOKUP) .build() assertThat(balanceLookup.accountId()).isEqualTo("account_in71c4amph0vgo2qllky") assertThat(balanceLookup.availableBalance()).isEqualTo(100L) assertThat(balanceLookup.currentBalance()).isEqualTo(100L) + assertThat(balanceLookup.loan()) + .contains( + BalanceLookup.Loan.builder() + .dueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dueBalance(0L) + .pastDueBalance(0L) + .build() + ) assertThat(balanceLookup.type()).isEqualTo(BalanceLookup.Type.BALANCE_LOOKUP) } @@ -33,6 +49,13 @@ internal class BalanceLookupTest { .accountId("account_in71c4amph0vgo2qllky") .availableBalance(100L) .currentBalance(100L) + .loan( + BalanceLookup.Loan.builder() + .dueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dueBalance(0L) + .pastDueBalance(0L) + .build() + ) .type(BalanceLookup.Type.BALANCE_LOOKUP) .build() diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/accountstatements/AccountStatementListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/accountstatements/AccountStatementListPageResponseTest.kt index 0db8780d7..b75bc3b8a 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/accountstatements/AccountStatementListPageResponseTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/accountstatements/AccountStatementListPageResponseTest.kt @@ -21,6 +21,13 @@ internal class AccountStatementListPageResponseTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .endingBalance(100L) .fileId("file_makxrc67oh9l6sg7w9yc") + .loan( + AccountStatement.Loan.builder() + .dueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dueBalance(0L) + .pastDueBalance(0L) + .build() + ) .startingBalance(0L) .statementPeriodEnd(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .statementPeriodStart(OffsetDateTime.parse("2020-01-31T23:59:59Z")) @@ -38,6 +45,13 @@ internal class AccountStatementListPageResponseTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .endingBalance(100L) .fileId("file_makxrc67oh9l6sg7w9yc") + .loan( + AccountStatement.Loan.builder() + .dueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dueBalance(0L) + .pastDueBalance(0L) + .build() + ) .startingBalance(0L) .statementPeriodEnd(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .statementPeriodStart(OffsetDateTime.parse("2020-01-31T23:59:59Z")) @@ -59,6 +73,13 @@ internal class AccountStatementListPageResponseTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .endingBalance(100L) .fileId("file_makxrc67oh9l6sg7w9yc") + .loan( + AccountStatement.Loan.builder() + .dueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dueBalance(0L) + .pastDueBalance(0L) + .build() + ) .startingBalance(0L) .statementPeriodEnd(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .statementPeriodStart(OffsetDateTime.parse("2020-01-31T23:59:59Z")) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/accountstatements/AccountStatementTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/accountstatements/AccountStatementTest.kt index ad89db910..f2d97bf3e 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/accountstatements/AccountStatementTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/accountstatements/AccountStatementTest.kt @@ -19,6 +19,13 @@ internal class AccountStatementTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .endingBalance(100L) .fileId("file_makxrc67oh9l6sg7w9yc") + .loan( + AccountStatement.Loan.builder() + .dueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dueBalance(0L) + .pastDueBalance(0L) + .build() + ) .startingBalance(0L) .statementPeriodEnd(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .statementPeriodStart(OffsetDateTime.parse("2020-01-31T23:59:59Z")) @@ -31,6 +38,14 @@ internal class AccountStatementTest { .isEqualTo(OffsetDateTime.parse("2020-01-31T23:59:59Z")) assertThat(accountStatement.endingBalance()).isEqualTo(100L) assertThat(accountStatement.fileId()).isEqualTo("file_makxrc67oh9l6sg7w9yc") + assertThat(accountStatement.loan()) + .contains( + AccountStatement.Loan.builder() + .dueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dueBalance(0L) + .pastDueBalance(0L) + .build() + ) assertThat(accountStatement.startingBalance()).isEqualTo(0L) assertThat(accountStatement.statementPeriodEnd()) .isEqualTo(OffsetDateTime.parse("2020-01-31T23:59:59Z")) @@ -49,6 +64,13 @@ internal class AccountStatementTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .endingBalance(100L) .fileId("file_makxrc67oh9l6sg7w9yc") + .loan( + AccountStatement.Loan.builder() + .dueAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dueBalance(0L) + .pastDueBalance(0L) + .build() + ) .startingBalance(0L) .statementPeriodEnd(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .statementPeriodStart(OffsetDateTime.parse("2020-01-31T23:59:59Z")) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/programs/ProgramListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/programs/ProgramListPageResponseTest.kt index 6f1391854..79558501b 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/programs/ProgramListPageResponseTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/programs/ProgramListPageResponseTest.kt @@ -22,6 +22,7 @@ internal class ProgramListPageResponseTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .defaultDigitalCardProfileId(null) .interestRate("0.01") + .lending(Program.Lending.builder().maximumExtendableCredit(0L).build()) .name("Commercial Banking") .type(Program.Type.PROGRAM) .updatedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) @@ -39,6 +40,7 @@ internal class ProgramListPageResponseTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .defaultDigitalCardProfileId(null) .interestRate("0.01") + .lending(Program.Lending.builder().maximumExtendableCredit(0L).build()) .name("Commercial Banking") .type(Program.Type.PROGRAM) .updatedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) @@ -60,6 +62,7 @@ internal class ProgramListPageResponseTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .defaultDigitalCardProfileId(null) .interestRate("0.01") + .lending(Program.Lending.builder().maximumExtendableCredit(0L).build()) .name("Commercial Banking") .type(Program.Type.PROGRAM) .updatedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/programs/ProgramTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/programs/ProgramTest.kt index 93aa8a828..6e3d4ac2a 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/programs/ProgramTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/programs/ProgramTest.kt @@ -20,6 +20,7 @@ internal class ProgramTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .defaultDigitalCardProfileId(null) .interestRate("0.01") + .lending(Program.Lending.builder().maximumExtendableCredit(0L).build()) .name("Commercial Banking") .type(Program.Type.PROGRAM) .updatedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) @@ -31,6 +32,8 @@ internal class ProgramTest { assertThat(program.createdAt()).isEqualTo(OffsetDateTime.parse("2020-01-31T23:59:59Z")) assertThat(program.defaultDigitalCardProfileId()).isEmpty assertThat(program.interestRate()).isEqualTo("0.01") + assertThat(program.lending()) + .contains(Program.Lending.builder().maximumExtendableCredit(0L).build()) assertThat(program.name()).isEqualTo("Commercial Banking") assertThat(program.type()).isEqualTo(Program.Type.PROGRAM) assertThat(program.updatedAt()).isEqualTo(OffsetDateTime.parse("2020-01-31T23:59:59Z")) @@ -47,6 +50,7 @@ internal class ProgramTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .defaultDigitalCardProfileId(null) .interestRate("0.01") + .lending(Program.Lending.builder().maximumExtendableCredit(0L).build()) .name("Commercial Banking") .type(Program.Type.PROGRAM) .updatedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/programs/ProgramCreateParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/programs/ProgramCreateParamsTest.kt index 48cf2ec97..9332a9a05 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/programs/ProgramCreateParamsTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/programs/ProgramCreateParamsTest.kt @@ -12,6 +12,7 @@ internal class ProgramCreateParamsTest { ProgramCreateParams.builder() .name("For Benefit Of") .bank(ProgramCreateParams.Bank.BLUE_RIDGE_BANK) + .lendingMaximumExtendableCredit(0L) .reserveAccountId("reserve_account_id") .build() } @@ -22,6 +23,7 @@ internal class ProgramCreateParamsTest { ProgramCreateParams.builder() .name("For Benefit Of") .bank(ProgramCreateParams.Bank.BLUE_RIDGE_BANK) + .lendingMaximumExtendableCredit(0L) .reserveAccountId("reserve_account_id") .build() @@ -29,6 +31,7 @@ internal class ProgramCreateParamsTest { assertThat(body.name()).isEqualTo("For Benefit Of") assertThat(body.bank()).contains(ProgramCreateParams.Bank.BLUE_RIDGE_BANK) + assertThat(body.lendingMaximumExtendableCredit()).contains(0L) assertThat(body.reserveAccountId()).contains("reserve_account_id") } diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/ErrorHandlingTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/ErrorHandlingTest.kt index 3868bdc9c..9bb4881b9 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/ErrorHandlingTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/ErrorHandlingTest.kt @@ -23,6 +23,7 @@ import com.increase.api.errors.UnauthorizedException import com.increase.api.errors.UnexpectedStatusCodeException import com.increase.api.errors.UnprocessableEntityException import com.increase.api.models.accounts.AccountCreateParams +import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.entry import org.junit.jupiter.api.BeforeEach @@ -74,7 +75,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -101,7 +114,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -128,7 +153,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -155,7 +192,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -182,7 +231,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -209,7 +270,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -236,7 +309,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -263,7 +348,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -290,7 +387,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -317,7 +426,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -344,7 +465,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -371,7 +504,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -398,7 +543,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -425,7 +582,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -452,7 +621,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -479,7 +660,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -504,7 +697,19 @@ internal class ErrorHandlingTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/ServiceParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/ServiceParamsTest.kt index c5702d6dc..6513ddf6d 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/ServiceParamsTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/ServiceParamsTest.kt @@ -16,6 +16,7 @@ import com.increase.api.client.IncreaseClient import com.increase.api.client.okhttp.IncreaseOkHttpClient import com.increase.api.core.JsonValue import com.increase.api.models.accounts.AccountCreateParams +import java.time.LocalDate import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.parallel.ResourceLock @@ -44,7 +45,17 @@ internal class ServiceParamsTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType(AccountCreateParams.Loan.StatementPaymentType.BALANCE) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/AccountServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/AccountServiceAsyncTest.kt index 8363c6030..ac0167555 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/async/AccountServiceAsyncTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/AccountServiceAsyncTest.kt @@ -7,6 +7,7 @@ import com.increase.api.client.okhttp.IncreaseOkHttpClientAsync import com.increase.api.models.accounts.AccountBalanceParams import com.increase.api.models.accounts.AccountCreateParams import com.increase.api.models.accounts.AccountUpdateParams +import java.time.LocalDate import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -28,7 +29,19 @@ internal class AccountServiceAsyncTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -65,6 +78,7 @@ internal class AccountServiceAsyncTest { accountServiceAsync.update( AccountUpdateParams.builder() .accountId("account_in71c4amph0vgo2qllky") + .loan(AccountUpdateParams.Loan.builder().creditLimit(0L).build()) .name("My renamed account") .build() ) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/ProgramServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/ProgramServiceAsyncTest.kt index f0d8a967a..d38b51b66 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/ProgramServiceAsyncTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/ProgramServiceAsyncTest.kt @@ -25,6 +25,7 @@ internal class ProgramServiceAsyncTest { ProgramCreateParams.builder() .name("For Benefit Of") .bank(ProgramCreateParams.Bank.BLUE_RIDGE_BANK) + .lendingMaximumExtendableCredit(0L) .reserveAccountId("reserve_account_id") .build() ) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/AccountServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/AccountServiceTest.kt index c942dafad..291483c6c 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/AccountServiceTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/AccountServiceTest.kt @@ -7,6 +7,7 @@ import com.increase.api.client.okhttp.IncreaseOkHttpClient import com.increase.api.models.accounts.AccountBalanceParams import com.increase.api.models.accounts.AccountCreateParams import com.increase.api.models.accounts.AccountUpdateParams +import java.time.LocalDate import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -28,7 +29,19 @@ internal class AccountServiceTest { AccountCreateParams.builder() .name("New Account!") .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(AccountCreateParams.Funding.LOAN) .informationalEntityId("informational_entity_id") + .loan( + AccountCreateParams.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .statementDayOfMonth(1L) + .statementPaymentType( + AccountCreateParams.Loan.StatementPaymentType.BALANCE + ) + .maturityDate(LocalDate.parse("2019-12-27")) + .build() + ) .programId("program_i2v2os4mwza1oetokh9i") .build() ) @@ -63,6 +76,7 @@ internal class AccountServiceTest { accountService.update( AccountUpdateParams.builder() .accountId("account_in71c4amph0vgo2qllky") + .loan(AccountUpdateParams.Loan.builder().creditLimit(0L).build()) .name("My renamed account") .build() ) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/ProgramServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/ProgramServiceTest.kt index 47a2150ff..0dfdd13cc 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/ProgramServiceTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/ProgramServiceTest.kt @@ -25,6 +25,7 @@ internal class ProgramServiceTest { ProgramCreateParams.builder() .name("For Benefit Of") .bank(ProgramCreateParams.Bank.BLUE_RIDGE_BANK) + .lendingMaximumExtendableCredit(0L) .reserveAccountId("reserve_account_id") .build() ) diff --git a/increase-java-proguard-test/src/test/kotlin/com/increase/api/proguard/ProGuardCompatibilityTest.kt b/increase-java-proguard-test/src/test/kotlin/com/increase/api/proguard/ProGuardCompatibilityTest.kt index 296d3762c..b63ca5d7c 100644 --- a/increase-java-proguard-test/src/test/kotlin/com/increase/api/proguard/ProGuardCompatibilityTest.kt +++ b/increase-java-proguard-test/src/test/kotlin/com/increase/api/proguard/ProGuardCompatibilityTest.kt @@ -120,11 +120,21 @@ internal class ProGuardCompatibilityTest { .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .currency(Account.Currency.USD) .entityId("entity_n8y8tnk2p9339ti393yi") + .funding(null) .idempotencyKey(null) .informationalEntityId(null) .interestAccrued("0.01") .interestAccruedAt(LocalDate.parse("2020-01-31")) .interestRate("0.055") + .loan( + Account.Loan.builder() + .creditLimit(0L) + .gracePeriodDays(0L) + .maturityDate(LocalDate.parse("2019-12-27")) + .statementDayOfMonth(0L) + .statementPaymentType(Account.Loan.StatementPaymentType.BALANCE) + .build() + ) .name("My first account!") .programId("program_i2v2os4mwza1oetokh9i") .status(Account.Status.OPEN)