diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 32ac2e3af..7478ed0a4 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.431.0" + ".": "0.432.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 9bcba9df2..9cbf59fe9 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-1127bb6ee64bebab1bbf8ecbd9ec71c0deb5ca8552fd454fa2ec120fd9eac14a.yml -openapi_spec_hash: 9fedc9dc133202e4d39bf7bffe4839d9 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-7da80155087dd9d883acaa10229e34ed5a3097f884c77b5f28c4c76a62b82432.yml +openapi_spec_hash: c5050ba45eb587316583060c1efef8a8 config_hash: 4b562e97b3d8b4cba758a87d4927a76d diff --git a/CHANGELOG.md b/CHANGELOG.md index d565ddb64..ab1d6283f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.432.0 (2026-02-18) + +Full Changelog: [v0.431.0...v0.432.0](https://github.com/Increase/increase-java/compare/v0.431.0...v0.432.0) + +### Features + +* **api:** api update ([22a662d](https://github.com/Increase/increase-java/commit/22a662d82f09741e4361a702210763ccd076730d)) + + +### Chores + +* **internal:** remove unnecessary base URL ([7c309fb](https://github.com/Increase/increase-java/commit/7c309fb93123e67c60271753f5248e6fb9a34622)) +* **internal:** update `TestServerExtension` comment ([680d244](https://github.com/Increase/increase-java/commit/680d244bb1753465a3629aa51d15e51b885ea67a)) + ## 0.431.0 (2026-02-14) Full Changelog: [v0.430.0...v0.431.0](https://github.com/Increase/increase-java/compare/v0.430.0...v0.431.0) diff --git a/README.md b/README.md index 6d81eda43..8ecd2ee7a 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.431.0) -[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.431.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.431.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.432.0) +[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.432.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.432.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.431.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.432.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.431.0") +implementation("com.increase.api:increase-java:0.432.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.increase.api:increase-java:0.431.0") com.increase.api increase-java - 0.431.0 + 0.432.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 276321b12..5143529bd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.increase.api" - version = "0.431.0" // x-release-please-version + version = "0.432.0" // x-release-please-version } subprojects { diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/checkdeposits/CheckDepositSubmitParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/checkdeposits/CheckDepositSubmitParams.kt index 732ea0f7b..37953a942 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/checkdeposits/CheckDepositSubmitParams.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/checkdeposits/CheckDepositSubmitParams.kt @@ -2,11 +2,20 @@ package com.increase.api.models.simulations.checkdeposits +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.ExcludeMissing +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.core.toImmutable +import com.increase.api.errors.IncreaseInvalidDataException +import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -18,16 +27,30 @@ import kotlin.jvm.optionals.getOrNull class CheckDepositSubmitParams private constructor( private val checkDepositId: String?, + private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, ) : Params { /** The identifier of the Check Deposit you wish to submit. */ fun checkDepositId(): Optional = Optional.ofNullable(checkDepositId) - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties + /** + * If set, the simulation will use these values for the check's scanned MICR data. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun scan(): Optional = body.scan() + + /** + * Returns the raw JSON value of [scan]. + * + * Unlike [scan], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _scan(): JsonField = body._scan() + + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -49,17 +72,16 @@ private constructor( class Builder internal constructor() { private var checkDepositId: String? = null + private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(checkDepositSubmitParams: CheckDepositSubmitParams) = apply { checkDepositId = checkDepositSubmitParams.checkDepositId + body = checkDepositSubmitParams.body.toBuilder() additionalHeaders = checkDepositSubmitParams.additionalHeaders.toBuilder() additionalQueryParams = checkDepositSubmitParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - checkDepositSubmitParams.additionalBodyProperties.toMutableMap() } /** The identifier of the Check Deposit you wish to submit. */ @@ -69,6 +91,45 @@ private constructor( fun checkDepositId(checkDepositId: Optional) = checkDepositId(checkDepositId.getOrNull()) + /** + * Sets the entire request body. + * + * 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: + * - [scan] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** If set, the simulation will use these values for the check's scanned MICR data. */ + fun scan(scan: Scan) = apply { body.scan(scan) } + + /** + * Sets [Builder.scan] to an arbitrary JSON value. + * + * You should usually call [Builder.scan] with a well-typed [Scan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun scan(scan: JsonField) = apply { body.scan(scan) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -167,28 +228,6 @@ private constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - /** * Returns an immutable instance of [CheckDepositSubmitParams]. * @@ -197,14 +236,13 @@ private constructor( fun build(): CheckDepositSubmitParams = CheckDepositSubmitParams( checkDepositId, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + fun _body(): Body = body fun _pathParam(index: Int): String = when (index) { @@ -216,6 +254,403 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val scan: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("scan") @ExcludeMissing scan: JsonField = JsonMissing.of() + ) : this(scan, mutableMapOf()) + + /** + * If set, the simulation will use these values for the check's scanned MICR data. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun scan(): Optional = scan.getOptional("scan") + + /** + * Returns the raw JSON value of [scan]. + * + * Unlike [scan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scan") @ExcludeMissing fun _scan(): JsonField = scan + + @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 [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var scan: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + scan = body.scan + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** If set, the simulation will use these values for the check's scanned MICR data. */ + fun scan(scan: Scan) = scan(JsonField.of(scan)) + + /** + * Sets [Builder.scan] to an arbitrary JSON value. + * + * You should usually call [Builder.scan] with a well-typed [Scan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scan(scan: JsonField) = apply { this.scan = scan } + + 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 [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(scan, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + scan().ifPresent { it.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 = (scan.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + scan == other.scan && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(scan, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{scan=$scan, additionalProperties=$additionalProperties}" + } + + /** If set, the simulation will use these values for the check's scanned MICR data. */ + class Scan + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accountNumber: JsonField, + private val routingNumber: JsonField, + private val auxiliaryOnUs: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("account_number") + @ExcludeMissing + accountNumber: JsonField = JsonMissing.of(), + @JsonProperty("routing_number") + @ExcludeMissing + routingNumber: JsonField = JsonMissing.of(), + @JsonProperty("auxiliary_on_us") + @ExcludeMissing + auxiliaryOnUs: JsonField = JsonMissing.of(), + ) : this(accountNumber, routingNumber, auxiliaryOnUs, mutableMapOf()) + + /** + * The account number to be returned in the check deposit's scan data. + * + * @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 accountNumber(): String = accountNumber.getRequired("account_number") + + /** + * The routing number to be returned in the check deposit's scan data. + * + * @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 routingNumber(): String = routingNumber.getRequired("routing_number") + + /** + * The auxiliary on-us data to be returned in the check deposit's scan data. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun auxiliaryOnUs(): Optional = auxiliaryOnUs.getOptional("auxiliary_on_us") + + /** + * Returns the raw JSON value of [accountNumber]. + * + * Unlike [accountNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("account_number") + @ExcludeMissing + fun _accountNumber(): JsonField = accountNumber + + /** + * Returns the raw JSON value of [routingNumber]. + * + * Unlike [routingNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber + + /** + * Returns the raw JSON value of [auxiliaryOnUs]. + * + * Unlike [auxiliaryOnUs], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auxiliary_on_us") + @ExcludeMissing + fun _auxiliaryOnUs(): JsonField = auxiliaryOnUs + + @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 [Scan]. + * + * The following fields are required: + * ```java + * .accountNumber() + * .routingNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Scan]. */ + class Builder internal constructor() { + + private var accountNumber: JsonField? = null + private var routingNumber: JsonField? = null + private var auxiliaryOnUs: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(scan: Scan) = apply { + accountNumber = scan.accountNumber + routingNumber = scan.routingNumber + auxiliaryOnUs = scan.auxiliaryOnUs + additionalProperties = scan.additionalProperties.toMutableMap() + } + + /** The account number to be returned in the check deposit's scan data. */ + fun accountNumber(accountNumber: String) = accountNumber(JsonField.of(accountNumber)) + + /** + * Sets [Builder.accountNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.accountNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accountNumber(accountNumber: JsonField) = apply { + this.accountNumber = accountNumber + } + + /** The routing number to be returned in the check deposit's scan data. */ + fun routingNumber(routingNumber: String) = routingNumber(JsonField.of(routingNumber)) + + /** + * Sets [Builder.routingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.routingNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun routingNumber(routingNumber: JsonField) = apply { + this.routingNumber = routingNumber + } + + /** The auxiliary on-us data to be returned in the check deposit's scan data. */ + fun auxiliaryOnUs(auxiliaryOnUs: String) = auxiliaryOnUs(JsonField.of(auxiliaryOnUs)) + + /** + * Sets [Builder.auxiliaryOnUs] to an arbitrary JSON value. + * + * You should usually call [Builder.auxiliaryOnUs] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun auxiliaryOnUs(auxiliaryOnUs: JsonField) = apply { + this.auxiliaryOnUs = auxiliaryOnUs + } + + 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 [Scan]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountNumber() + * .routingNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Scan = + Scan( + checkRequired("accountNumber", accountNumber), + checkRequired("routingNumber", routingNumber), + auxiliaryOnUs, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Scan = apply { + if (validated) { + return@apply + } + + accountNumber() + routingNumber() + auxiliaryOnUs() + 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 (accountNumber.asKnown().isPresent) 1 else 0) + + (if (routingNumber.asKnown().isPresent) 1 else 0) + + (if (auxiliaryOnUs.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scan && + accountNumber == other.accountNumber && + routingNumber == other.routingNumber && + auxiliaryOnUs == other.auxiliaryOnUs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(accountNumber, routingNumber, auxiliaryOnUs, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Scan{accountNumber=$accountNumber, routingNumber=$routingNumber, auxiliaryOnUs=$auxiliaryOnUs, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -223,19 +658,14 @@ private constructor( return other is CheckDepositSubmitParams && checkDepositId == other.checkDepositId && + body == other.body && additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties + additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash( - checkDepositId, - additionalHeaders, - additionalQueryParams, - additionalBodyProperties, - ) + Objects.hash(checkDepositId, body, additionalHeaders, additionalQueryParams) override fun toString() = - "CheckDepositSubmitParams{checkDepositId=$checkDepositId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "CheckDepositSubmitParams{checkDepositId=$checkDepositId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CheckDepositServiceAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CheckDepositServiceAsyncImpl.kt index 4b2e40fcf..24f03975b 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CheckDepositServiceAsyncImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CheckDepositServiceAsyncImpl.kt @@ -168,7 +168,7 @@ class CheckDepositServiceAsyncImpl internal constructor(private val clientOption params._pathParam(0), "submit", ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CheckDepositServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CheckDepositServiceImpl.kt index 53b47052c..cc02438da 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CheckDepositServiceImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CheckDepositServiceImpl.kt @@ -161,7 +161,7 @@ class CheckDepositServiceImpl internal constructor(private val clientOptions: Cl params._pathParam(0), "submit", ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/TestServerExtension.kt b/increase-java-core/src/test/kotlin/com/increase/api/TestServerExtension.kt index 7ae08e28b..d931ac9fe 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/TestServerExtension.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/TestServerExtension.kt @@ -15,25 +15,12 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { } catch (e: Exception) { throw RuntimeException( """ - The test suite will not run without a mock Prism server running against your OpenAPI spec. + The test suite will not run without a mock server running against your OpenAPI spec. You can set the environment variable `SKIP_MOCK_TESTS` to `true` to skip running any tests that require the mock server. - To fix: - - 1. Install Prism (requires Node 16+): - - With npm: - $ npm install -g @stoplight/prism-cli - - With yarn: - $ yarn global add @stoplight/prism-cli - - 2. Run the mock server - - To run the server, pass in the path of your OpenAPI spec to the prism command: - $ prism mock path/to/your.openapi.yml + To fix run `./scripts/mock` in a separate terminal. """ .trimIndent(), e, diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/checkdeposits/CheckDepositSubmitParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/checkdeposits/CheckDepositSubmitParamsTest.kt index 45aaa1369..1bcbe6c00 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/checkdeposits/CheckDepositSubmitParamsTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/checkdeposits/CheckDepositSubmitParamsTest.kt @@ -11,6 +11,13 @@ internal class CheckDepositSubmitParamsTest { fun create() { CheckDepositSubmitParams.builder() .checkDepositId("check_deposit_f06n9gpg7sxn8t19lfc1") + .scan( + CheckDepositSubmitParams.Scan.builder() + .accountNumber("x") + .routingNumber("x") + .auxiliaryOnUs("x") + .build() + ) .build() } @@ -25,4 +32,40 @@ internal class CheckDepositSubmitParamsTest { // out-of-bound path param assertThat(params._pathParam(1)).isEqualTo("") } + + @Test + fun body() { + val params = + CheckDepositSubmitParams.builder() + .checkDepositId("check_deposit_f06n9gpg7sxn8t19lfc1") + .scan( + CheckDepositSubmitParams.Scan.builder() + .accountNumber("x") + .routingNumber("x") + .auxiliaryOnUs("x") + .build() + ) + .build() + + val body = params._body() + + assertThat(body.scan()) + .contains( + CheckDepositSubmitParams.Scan.builder() + .accountNumber("x") + .routingNumber("x") + .auxiliaryOnUs("x") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + CheckDepositSubmitParams.builder() + .checkDepositId("check_deposit_f06n9gpg7sxn8t19lfc1") + .build() + + val body = params._body() + } } diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/EventServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/EventServiceAsyncTest.kt index 4c761a5b8..688ad8377 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/async/EventServiceAsyncTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/EventServiceAsyncTest.kt @@ -48,11 +48,7 @@ internal class EventServiceAsyncTest { @Test fun unwrap() { - val client = - IncreaseOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = IncreaseOkHttpClientAsync.builder().apiKey("My API Key").build() val eventServiceAsync = client.events() val payload = diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CheckDepositServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CheckDepositServiceAsyncTest.kt index 1a9a8cde9..2d290bf66 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CheckDepositServiceAsyncTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CheckDepositServiceAsyncTest.kt @@ -4,6 +4,7 @@ package com.increase.api.services.async.simulations import com.increase.api.TestServerExtension import com.increase.api.client.okhttp.IncreaseOkHttpClientAsync +import com.increase.api.models.simulations.checkdeposits.CheckDepositSubmitParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -52,7 +53,18 @@ internal class CheckDepositServiceAsyncTest { val checkDepositServiceAsync = client.simulations().checkDeposits() val checkDepositFuture = - checkDepositServiceAsync.submit("check_deposit_f06n9gpg7sxn8t19lfc1") + checkDepositServiceAsync.submit( + CheckDepositSubmitParams.builder() + .checkDepositId("check_deposit_f06n9gpg7sxn8t19lfc1") + .scan( + CheckDepositSubmitParams.Scan.builder() + .accountNumber("x") + .routingNumber("x") + .auxiliaryOnUs("x") + .build() + ) + .build() + ) val checkDeposit = checkDepositFuture.get() checkDeposit.validate() diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/EventServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/EventServiceTest.kt index f263fd80c..390cd59fd 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/EventServiceTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/EventServiceTest.kt @@ -46,11 +46,7 @@ internal class EventServiceTest { @Test fun unwrap() { - val client = - IncreaseOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() + val client = IncreaseOkHttpClient.builder().apiKey("My API Key").build() val eventService = client.events() val payload = diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CheckDepositServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CheckDepositServiceTest.kt index 5563762c4..fd139b3fe 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CheckDepositServiceTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CheckDepositServiceTest.kt @@ -4,6 +4,7 @@ package com.increase.api.services.blocking.simulations import com.increase.api.TestServerExtension import com.increase.api.client.okhttp.IncreaseOkHttpClient +import com.increase.api.models.simulations.checkdeposits.CheckDepositSubmitParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -47,7 +48,19 @@ internal class CheckDepositServiceTest { .build() val checkDepositService = client.simulations().checkDeposits() - val checkDeposit = checkDepositService.submit("check_deposit_f06n9gpg7sxn8t19lfc1") + val checkDeposit = + checkDepositService.submit( + CheckDepositSubmitParams.builder() + .checkDepositId("check_deposit_f06n9gpg7sxn8t19lfc1") + .scan( + CheckDepositSubmitParams.Scan.builder() + .accountNumber("x") + .routingNumber("x") + .auxiliaryOnUs("x") + .build() + ) + .build() + ) checkDeposit.validate() }