diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6c3521308..a7fe876e2 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.459.0" + ".": "0.460.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 40873533c..9d5bfb4e6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 234 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-b42ffa447aa14da70d972676b1d5ad0c2720ff4e33a483037b2b1bb51190a69f.yml -openapi_spec_hash: f2a5c5e804880a8e8d13f5f32ca264a1 -config_hash: b7ec7f54fa76c1f8bde7a548710a1d38 +configured_endpoints: 236 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-f46fe8b546ee1a4ad24918ef0803f48e6586e061d5445ae1aeb6abc7b8cf64a3.yml +openapi_spec_hash: 440b743a615d5ecc832affd6c3154809 +config_hash: dda988c5565c2f15cc708122984d7691 diff --git a/CHANGELOG.md b/CHANGELOG.md index 395eefe51..3643e4569 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.460.0 (2026-03-10) + +Full Changelog: [v0.459.0...v0.460.0](https://github.com/Increase/increase-java/compare/v0.459.0...v0.460.0) + +### Features + +* **api:** api update ([71ea8bb](https://github.com/Increase/increase-java/commit/71ea8bbfe4c515f375acd142a6bbc42732f94f0a)) + + +### Chores + +* **internal:** codegen related update ([31c4344](https://github.com/Increase/increase-java/commit/31c43441e0a17c08ee7c6dde491e75d28dc26edf)) + ## 0.459.0 (2026-03-09) Full Changelog: [v0.458.0...v0.459.0](https://github.com/Increase/increase-java/compare/v0.458.0...v0.459.0) diff --git a/README.md b/README.md index 6852e3cf6..40a76a1a5 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.459.0) -[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.459.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.459.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.460.0) +[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.460.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.460.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.459.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.460.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.459.0") +implementation("com.increase.api:increase-java:0.460.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.increase.api:increase-java:0.459.0") com.increase.api increase-java - 0.459.0 + 0.460.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 06d9d83c9..bf6148852 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.increase.api" - version = "0.459.0" // x-release-please-version + version = "0.460.0" // x-release-please-version } subprojects { diff --git a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClient.kt b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClient.kt index 45a95b6a6..5628c7f29 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClient.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClient.kt @@ -9,6 +9,7 @@ import com.increase.api.services.blocking.AccountStatementService import com.increase.api.services.blocking.AccountTransferService import com.increase.api.services.blocking.AchPrenotificationService import com.increase.api.services.blocking.AchTransferService +import com.increase.api.services.blocking.BeneficialOwnerService import com.increase.api.services.blocking.BookkeepingAccountService import com.increase.api.services.blocking.BookkeepingEntryService import com.increase.api.services.blocking.BookkeepingEntrySetService @@ -167,6 +168,8 @@ interface IncreaseClient { fun entities(): EntityService + fun beneficialOwners(): BeneficialOwnerService + fun supplementalDocuments(): SupplementalDocumentService fun programs(): ProgramService @@ -307,6 +310,8 @@ interface IncreaseClient { fun entities(): EntityService.WithRawResponse + fun beneficialOwners(): BeneficialOwnerService.WithRawResponse + fun supplementalDocuments(): SupplementalDocumentService.WithRawResponse fun programs(): ProgramService.WithRawResponse diff --git a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsync.kt index 869f37b2a..e20bc342c 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsync.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsync.kt @@ -9,6 +9,7 @@ import com.increase.api.services.async.AccountStatementServiceAsync import com.increase.api.services.async.AccountTransferServiceAsync import com.increase.api.services.async.AchPrenotificationServiceAsync import com.increase.api.services.async.AchTransferServiceAsync +import com.increase.api.services.async.BeneficialOwnerServiceAsync import com.increase.api.services.async.BookkeepingAccountServiceAsync import com.increase.api.services.async.BookkeepingEntryServiceAsync import com.increase.api.services.async.BookkeepingEntrySetServiceAsync @@ -167,6 +168,8 @@ interface IncreaseClientAsync { fun entities(): EntityServiceAsync + fun beneficialOwners(): BeneficialOwnerServiceAsync + fun supplementalDocuments(): SupplementalDocumentServiceAsync fun programs(): ProgramServiceAsync @@ -311,6 +314,8 @@ interface IncreaseClientAsync { fun entities(): EntityServiceAsync.WithRawResponse + fun beneficialOwners(): BeneficialOwnerServiceAsync.WithRawResponse + fun supplementalDocuments(): SupplementalDocumentServiceAsync.WithRawResponse fun programs(): ProgramServiceAsync.WithRawResponse diff --git a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt index 6691e016c..0e6801386 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt @@ -16,6 +16,8 @@ import com.increase.api.services.async.AchPrenotificationServiceAsync import com.increase.api.services.async.AchPrenotificationServiceAsyncImpl import com.increase.api.services.async.AchTransferServiceAsync import com.increase.api.services.async.AchTransferServiceAsyncImpl +import com.increase.api.services.async.BeneficialOwnerServiceAsync +import com.increase.api.services.async.BeneficialOwnerServiceAsyncImpl import com.increase.api.services.async.BookkeepingAccountServiceAsync import com.increase.api.services.async.BookkeepingAccountServiceAsyncImpl import com.increase.api.services.async.BookkeepingEntryServiceAsync @@ -274,6 +276,10 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa EntityServiceAsyncImpl(clientOptionsWithUserAgent) } + private val beneficialOwners: BeneficialOwnerServiceAsync by lazy { + BeneficialOwnerServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val supplementalDocuments: SupplementalDocumentServiceAsync by lazy { SupplementalDocumentServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -446,6 +452,8 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa override fun entities(): EntityServiceAsync = entities + override fun beneficialOwners(): BeneficialOwnerServiceAsync = beneficialOwners + override fun supplementalDocuments(): SupplementalDocumentServiceAsync = supplementalDocuments override fun programs(): ProgramServiceAsync = programs @@ -641,6 +649,10 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa EntityServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val beneficialOwners: BeneficialOwnerServiceAsync.WithRawResponse by lazy { + BeneficialOwnerServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val supplementalDocuments: SupplementalDocumentServiceAsync.WithRawResponse by lazy { SupplementalDocumentServiceAsyncImpl.WithRawResponseImpl(clientOptions) @@ -829,6 +841,9 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa override fun entities(): EntityServiceAsync.WithRawResponse = entities + override fun beneficialOwners(): BeneficialOwnerServiceAsync.WithRawResponse = + beneficialOwners + override fun supplementalDocuments(): SupplementalDocumentServiceAsync.WithRawResponse = supplementalDocuments diff --git a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt index 9d3e2f55f..b4d9db6a8 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt @@ -16,6 +16,8 @@ import com.increase.api.services.blocking.AchPrenotificationService import com.increase.api.services.blocking.AchPrenotificationServiceImpl import com.increase.api.services.blocking.AchTransferService import com.increase.api.services.blocking.AchTransferServiceImpl +import com.increase.api.services.blocking.BeneficialOwnerService +import com.increase.api.services.blocking.BeneficialOwnerServiceImpl import com.increase.api.services.blocking.BookkeepingAccountService import com.increase.api.services.blocking.BookkeepingAccountServiceImpl import com.increase.api.services.blocking.BookkeepingEntryService @@ -267,6 +269,10 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli private val entities: EntityService by lazy { EntityServiceImpl(clientOptionsWithUserAgent) } + private val beneficialOwners: BeneficialOwnerService by lazy { + BeneficialOwnerServiceImpl(clientOptionsWithUserAgent) + } + private val supplementalDocuments: SupplementalDocumentService by lazy { SupplementalDocumentServiceImpl(clientOptionsWithUserAgent) } @@ -429,6 +435,8 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli override fun entities(): EntityService = entities + override fun beneficialOwners(): BeneficialOwnerService = beneficialOwners + override fun supplementalDocuments(): SupplementalDocumentService = supplementalDocuments override fun programs(): ProgramService = programs @@ -622,6 +630,10 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli EntityServiceImpl.WithRawResponseImpl(clientOptions) } + private val beneficialOwners: BeneficialOwnerService.WithRawResponse by lazy { + BeneficialOwnerServiceImpl.WithRawResponseImpl(clientOptions) + } + private val supplementalDocuments: SupplementalDocumentService.WithRawResponse by lazy { SupplementalDocumentServiceImpl.WithRawResponseImpl(clientOptions) } @@ -806,6 +818,8 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli override fun entities(): EntityService.WithRawResponse = entities + override fun beneficialOwners(): BeneficialOwnerService.WithRawResponse = beneficialOwners + override fun supplementalDocuments(): SupplementalDocumentService.WithRawResponse = supplementalDocuments diff --git a/increase-java-core/src/main/kotlin/com/increase/api/core/http/RetryingHttpClient.kt b/increase-java-core/src/main/kotlin/com/increase/api/core/http/RetryingHttpClient.kt index d9326237a..533af09a6 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/core/http/RetryingHttpClient.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/core/http/RetryingHttpClient.kt @@ -201,7 +201,7 @@ private constructor( ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) ?: try { - ChronoUnit.MILLIS.between( + ChronoUnit.NANOS.between( OffsetDateTime.now(clock), OffsetDateTime.parse( retryAfter, diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListPage.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListPage.kt new file mode 100644 index 000000000..130859440 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListPage.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.beneficialowners + +import com.increase.api.core.AutoPager +import com.increase.api.core.Page +import com.increase.api.core.checkRequired +import com.increase.api.services.blocking.BeneficialOwnerService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see BeneficialOwnerService.list */ +class BeneficialOwnerListPage +private constructor( + private val service: BeneficialOwnerService, + private val params: BeneficialOwnerListParams, + private val response: BeneficialOwnerListPageResponse, +) : Page { + + /** + * Delegates to [BeneficialOwnerListPageResponse], but gracefully handles missing data. + * + * @see BeneficialOwnerListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [BeneficialOwnerListPageResponse], but gracefully handles missing data. + * + * @see BeneficialOwnerListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("next_cursor") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): BeneficialOwnerListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): BeneficialOwnerListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): BeneficialOwnerListParams = params + + /** The response that this page was parsed from. */ + fun response(): BeneficialOwnerListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BeneficialOwnerListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BeneficialOwnerListPage]. */ + class Builder internal constructor() { + + private var service: BeneficialOwnerService? = null + private var params: BeneficialOwnerListParams? = null + private var response: BeneficialOwnerListPageResponse? = null + + @JvmSynthetic + internal fun from(beneficialOwnerListPage: BeneficialOwnerListPage) = apply { + service = beneficialOwnerListPage.service + params = beneficialOwnerListPage.params + response = beneficialOwnerListPage.response + } + + fun service(service: BeneficialOwnerService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: BeneficialOwnerListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: BeneficialOwnerListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [BeneficialOwnerListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BeneficialOwnerListPage = + BeneficialOwnerListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BeneficialOwnerListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "BeneficialOwnerListPage{service=$service, params=$params, response=$response}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListPageAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListPageAsync.kt new file mode 100644 index 000000000..b48371a5f --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListPageAsync.kt @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.beneficialowners + +import com.increase.api.core.AutoPagerAsync +import com.increase.api.core.PageAsync +import com.increase.api.core.checkRequired +import com.increase.api.services.async.BeneficialOwnerServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see BeneficialOwnerServiceAsync.list */ +class BeneficialOwnerListPageAsync +private constructor( + private val service: BeneficialOwnerServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: BeneficialOwnerListParams, + private val response: BeneficialOwnerListPageResponse, +) : PageAsync { + + /** + * Delegates to [BeneficialOwnerListPageResponse], but gracefully handles missing data. + * + * @see BeneficialOwnerListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [BeneficialOwnerListPageResponse], but gracefully handles missing data. + * + * @see BeneficialOwnerListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("next_cursor") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): BeneficialOwnerListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): BeneficialOwnerListParams = params + + /** The response that this page was parsed from. */ + fun response(): BeneficialOwnerListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BeneficialOwnerListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BeneficialOwnerListPageAsync]. */ + class Builder internal constructor() { + + private var service: BeneficialOwnerServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: BeneficialOwnerListParams? = null + private var response: BeneficialOwnerListPageResponse? = null + + @JvmSynthetic + internal fun from(beneficialOwnerListPageAsync: BeneficialOwnerListPageAsync) = apply { + service = beneficialOwnerListPageAsync.service + streamHandlerExecutor = beneficialOwnerListPageAsync.streamHandlerExecutor + params = beneficialOwnerListPageAsync.params + response = beneficialOwnerListPageAsync.response + } + + fun service(service: BeneficialOwnerServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: BeneficialOwnerListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: BeneficialOwnerListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [BeneficialOwnerListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BeneficialOwnerListPageAsync = + BeneficialOwnerListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BeneficialOwnerListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "BeneficialOwnerListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListPageResponse.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListPageResponse.kt new file mode 100644 index 000000000..ecf6a70a4 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListPageResponse.kt @@ -0,0 +1,242 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.beneficialowners + +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.checkKnown +import com.increase.api.core.checkRequired +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 + +/** A list of Beneficial Owner objects. */ +class BeneficialOwnerListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val nextCursor: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + ) : this(data, nextCursor, mutableMapOf()) + + /** + * The contents of the list. + * + * @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 data(): List = data.getRequired("data") + + /** + * A pointer to a place in the list. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextCursor(): Optional = nextCursor.getOptional("next_cursor") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + @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 + * [BeneficialOwnerListPageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .nextCursor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BeneficialOwnerListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var nextCursor: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(beneficialOwnerListPageResponse: BeneficialOwnerListPageResponse) = + apply { + data = beneficialOwnerListPageResponse.data.map { it.toMutableList() } + nextCursor = beneficialOwnerListPageResponse.nextCursor + additionalProperties = + beneficialOwnerListPageResponse.additionalProperties.toMutableMap() + } + + /** The contents of the list. */ + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [EntityBeneficialOwner] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: EntityBeneficialOwner) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + /** A pointer to a place in the list. */ + fun nextCursor(nextCursor: String?) = nextCursor(JsonField.ofNullable(nextCursor)) + + /** Alias for calling [Builder.nextCursor] with `nextCursor.orElse(null)`. */ + fun nextCursor(nextCursor: Optional) = nextCursor(nextCursor.getOrNull()) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + 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 [BeneficialOwnerListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .nextCursor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BeneficialOwnerListPageResponse = + BeneficialOwnerListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("nextCursor", nextCursor), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BeneficialOwnerListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + nextCursor() + 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 = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BeneficialOwnerListPageResponse && + data == other.data && + nextCursor == other.nextCursor && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, nextCursor, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BeneficialOwnerListPageResponse{data=$data, nextCursor=$nextCursor, additionalProperties=$additionalProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListParams.kt new file mode 100644 index 000000000..55f214c59 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListParams.kt @@ -0,0 +1,283 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.beneficialowners + +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 java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List Beneficial Owners */ +class BeneficialOwnerListParams +private constructor( + private val entityId: String, + private val cursor: String?, + private val idempotencyKey: String?, + private val limit: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The identifier of the Entity to list beneficial owners for. Only `corporation` entities have + * beneficial owners. + */ + fun entityId(): String = entityId + + /** Return the page of entries after this one. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** + * Filter records to the one with the specified `idempotency_key` you chose for that object. + * This value is unique across Increase and is used to ensure that a request is only processed + * once. Learn more about [idempotency](https://increase.com/documentation/idempotency-keys). + */ + fun idempotencyKey(): Optional = Optional.ofNullable(idempotencyKey) + + /** Limit the size of the list that is returned. The default (and maximum) is 100 objects. */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BeneficialOwnerListParams]. + * + * The following fields are required: + * ```java + * .entityId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BeneficialOwnerListParams]. */ + class Builder internal constructor() { + + private var entityId: String? = null + private var cursor: String? = null + private var idempotencyKey: String? = null + private var limit: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(beneficialOwnerListParams: BeneficialOwnerListParams) = apply { + entityId = beneficialOwnerListParams.entityId + cursor = beneficialOwnerListParams.cursor + idempotencyKey = beneficialOwnerListParams.idempotencyKey + limit = beneficialOwnerListParams.limit + additionalHeaders = beneficialOwnerListParams.additionalHeaders.toBuilder() + additionalQueryParams = beneficialOwnerListParams.additionalQueryParams.toBuilder() + } + + /** + * The identifier of the Entity to list beneficial owners for. Only `corporation` entities + * have beneficial owners. + */ + fun entityId(entityId: String) = apply { this.entityId = entityId } + + /** Return the page of entries after this one. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * Filter records to the one with the specified `idempotency_key` you chose for that object. + * This value is unique across Increase and is used to ensure that a request is only + * processed once. Learn more about + * [idempotency](https://increase.com/documentation/idempotency-keys). + */ + fun idempotencyKey(idempotencyKey: String?) = apply { this.idempotencyKey = idempotencyKey } + + /** Alias for calling [Builder.idempotencyKey] with `idempotencyKey.orElse(null)`. */ + fun idempotencyKey(idempotencyKey: Optional) = + idempotencyKey(idempotencyKey.getOrNull()) + + /** + * Limit the size of the list that is returned. The default (and maximum) is 100 objects. + */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BeneficialOwnerListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entityId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BeneficialOwnerListParams = + BeneficialOwnerListParams( + checkRequired("entityId", entityId), + cursor, + idempotencyKey, + limit, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("entity_id", entityId) + cursor?.let { put("cursor", it) } + idempotencyKey?.let { put("idempotency_key", it) } + limit?.let { put("limit", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BeneficialOwnerListParams && + entityId == other.entityId && + cursor == other.cursor && + idempotencyKey == other.idempotencyKey && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + entityId, + cursor, + idempotencyKey, + limit, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "BeneficialOwnerListParams{entityId=$entityId, cursor=$cursor, idempotencyKey=$idempotencyKey, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerRetrieveParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerRetrieveParams.kt new file mode 100644 index 000000000..b6f4b6c49 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerRetrieveParams.kt @@ -0,0 +1,205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.beneficialowners + +import com.increase.api.core.Params +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieve a Beneficial Owner */ +class BeneficialOwnerRetrieveParams +private constructor( + private val entityBeneficialOwnerId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The identifier of the Beneficial Owner to retrieve. */ + fun entityBeneficialOwnerId(): Optional = Optional.ofNullable(entityBeneficialOwnerId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BeneficialOwnerRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [BeneficialOwnerRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BeneficialOwnerRetrieveParams]. */ + class Builder internal constructor() { + + private var entityBeneficialOwnerId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(beneficialOwnerRetrieveParams: BeneficialOwnerRetrieveParams) = apply { + entityBeneficialOwnerId = beneficialOwnerRetrieveParams.entityBeneficialOwnerId + additionalHeaders = beneficialOwnerRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = beneficialOwnerRetrieveParams.additionalQueryParams.toBuilder() + } + + /** The identifier of the Beneficial Owner to retrieve. */ + fun entityBeneficialOwnerId(entityBeneficialOwnerId: String?) = apply { + this.entityBeneficialOwnerId = entityBeneficialOwnerId + } + + /** + * Alias for calling [Builder.entityBeneficialOwnerId] with + * `entityBeneficialOwnerId.orElse(null)`. + */ + fun entityBeneficialOwnerId(entityBeneficialOwnerId: Optional) = + entityBeneficialOwnerId(entityBeneficialOwnerId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BeneficialOwnerRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BeneficialOwnerRetrieveParams = + BeneficialOwnerRetrieveParams( + entityBeneficialOwnerId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> entityBeneficialOwnerId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BeneficialOwnerRetrieveParams && + entityBeneficialOwnerId == other.entityBeneficialOwnerId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(entityBeneficialOwnerId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BeneficialOwnerRetrieveParams{entityBeneficialOwnerId=$entityBeneficialOwnerId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/EntityBeneficialOwner.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/EntityBeneficialOwner.kt new file mode 100644 index 000000000..1c3f5f471 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/beneficialowners/EntityBeneficialOwner.kt @@ -0,0 +1,1714 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.beneficialowners + +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 +import com.increase.api.core.JsonValue +import com.increase.api.core.checkKnown +import com.increase.api.core.checkRequired +import com.increase.api.core.toImmutable +import com.increase.api.errors.IncreaseInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class EntityBeneficialOwner +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val companyTitle: JsonField, + private val createdAt: JsonField, + private val individual: JsonField, + private val prongs: JsonField>, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("company_title") + @ExcludeMissing + companyTitle: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("individual") + @ExcludeMissing + individual: JsonField = JsonMissing.of(), + @JsonProperty("prongs") @ExcludeMissing prongs: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(id, companyTitle, createdAt, individual, prongs, type, mutableMapOf()) + + /** + * The identifier of this beneficial owner. + * + * @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 id(): String = id.getRequired("id") + + /** + * This person's role or title within the entity. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun companyTitle(): Optional = companyTitle.getOptional("company_title") + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the Beneficial Owner was + * created. + * + * @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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * Personal details for the beneficial owner. + * + * @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 individual(): Individual = individual.getRequired("individual") + + /** + * Why this person is considered a beneficial owner of the entity. + * + * @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 prongs(): List = prongs.getRequired("prongs") + + /** + * A constant representing the object's type. For this resource it will always be + * `entity_beneficial_owner`. + * + * @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 type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [companyTitle]. + * + * Unlike [companyTitle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("company_title") + @ExcludeMissing + fun _companyTitle(): JsonField = companyTitle + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [individual]. + * + * Unlike [individual], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("individual") + @ExcludeMissing + fun _individual(): JsonField = individual + + /** + * Returns the raw JSON value of [prongs]. + * + * Unlike [prongs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prongs") @ExcludeMissing fun _prongs(): JsonField> = prongs + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @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 [EntityBeneficialOwner]. + * + * The following fields are required: + * ```java + * .id() + * .companyTitle() + * .createdAt() + * .individual() + * .prongs() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EntityBeneficialOwner]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var companyTitle: JsonField? = null + private var createdAt: JsonField? = null + private var individual: JsonField? = null + private var prongs: JsonField>? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(entityBeneficialOwner: EntityBeneficialOwner) = apply { + id = entityBeneficialOwner.id + companyTitle = entityBeneficialOwner.companyTitle + createdAt = entityBeneficialOwner.createdAt + individual = entityBeneficialOwner.individual + prongs = entityBeneficialOwner.prongs.map { it.toMutableList() } + type = entityBeneficialOwner.type + additionalProperties = entityBeneficialOwner.additionalProperties.toMutableMap() + } + + /** The identifier of this beneficial owner. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** This person's role or title within the entity. */ + fun companyTitle(companyTitle: String?) = companyTitle(JsonField.ofNullable(companyTitle)) + + /** Alias for calling [Builder.companyTitle] with `companyTitle.orElse(null)`. */ + fun companyTitle(companyTitle: Optional) = companyTitle(companyTitle.getOrNull()) + + /** + * Sets [Builder.companyTitle] to an arbitrary JSON value. + * + * You should usually call [Builder.companyTitle] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun companyTitle(companyTitle: JsonField) = apply { + this.companyTitle = companyTitle + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the Beneficial Owner + * was created. + */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** Personal details for the beneficial owner. */ + fun individual(individual: Individual) = individual(JsonField.of(individual)) + + /** + * Sets [Builder.individual] to an arbitrary JSON value. + * + * You should usually call [Builder.individual] with a well-typed [Individual] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun individual(individual: JsonField) = apply { this.individual = individual } + + /** Why this person is considered a beneficial owner of the entity. */ + fun prongs(prongs: List) = prongs(JsonField.of(prongs)) + + /** + * Sets [Builder.prongs] to an arbitrary JSON value. + * + * You should usually call [Builder.prongs] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun prongs(prongs: JsonField>) = apply { + this.prongs = prongs.map { it.toMutableList() } + } + + /** + * Adds a single [Prong] to [prongs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addProng(prong: Prong) = apply { + prongs = + (prongs ?: JsonField.of(mutableListOf())).also { + checkKnown("prongs", it).add(prong) + } + } + + /** + * A constant representing the object's type. For this resource it will always be + * `entity_beneficial_owner`. + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + 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 [EntityBeneficialOwner]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .companyTitle() + * .createdAt() + * .individual() + * .prongs() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EntityBeneficialOwner = + EntityBeneficialOwner( + checkRequired("id", id), + checkRequired("companyTitle", companyTitle), + checkRequired("createdAt", createdAt), + checkRequired("individual", individual), + checkRequired("prongs", prongs).map { it.toImmutable() }, + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EntityBeneficialOwner = apply { + if (validated) { + return@apply + } + + id() + companyTitle() + createdAt() + individual().validate() + prongs().forEach { it.validate() } + type().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 (id.asKnown().isPresent) 1 else 0) + + (if (companyTitle.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (individual.asKnown().getOrNull()?.validity() ?: 0) + + (prongs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Personal details for the beneficial owner. */ + class Individual + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val address: JsonField
, + private val dateOfBirth: JsonField, + private val identification: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("address") @ExcludeMissing address: JsonField
= JsonMissing.of(), + @JsonProperty("date_of_birth") + @ExcludeMissing + dateOfBirth: JsonField = JsonMissing.of(), + @JsonProperty("identification") + @ExcludeMissing + identification: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(address, dateOfBirth, identification, name, mutableMapOf()) + + /** + * The person's address. + * + * @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 address(): Address = address.getRequired("address") + + /** + * The person's date of birth in YYYY-MM-DD format. + * + * @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 dateOfBirth(): LocalDate = dateOfBirth.getRequired("date_of_birth") + + /** + * A means of verifying the person's identity. + * + * @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 identification(): Identification = identification.getRequired("identification") + + /** + * The person's legal name. + * + * @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 name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [address]. + * + * Unlike [address], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("address") @ExcludeMissing fun _address(): JsonField
= address + + /** + * Returns the raw JSON value of [dateOfBirth]. + * + * Unlike [dateOfBirth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("date_of_birth") + @ExcludeMissing + fun _dateOfBirth(): JsonField = dateOfBirth + + /** + * Returns the raw JSON value of [identification]. + * + * Unlike [identification], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("identification") + @ExcludeMissing + fun _identification(): JsonField = identification + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 [Individual]. + * + * The following fields are required: + * ```java + * .address() + * .dateOfBirth() + * .identification() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Individual]. */ + class Builder internal constructor() { + + private var address: JsonField
? = null + private var dateOfBirth: JsonField? = null + private var identification: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(individual: Individual) = apply { + address = individual.address + dateOfBirth = individual.dateOfBirth + identification = individual.identification + name = individual.name + additionalProperties = individual.additionalProperties.toMutableMap() + } + + /** The person's address. */ + fun address(address: Address) = address(JsonField.of(address)) + + /** + * Sets [Builder.address] to an arbitrary JSON value. + * + * You should usually call [Builder.address] with a well-typed [Address] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun address(address: JsonField
) = apply { this.address = address } + + /** The person's date of birth in YYYY-MM-DD format. */ + fun dateOfBirth(dateOfBirth: LocalDate) = dateOfBirth(JsonField.of(dateOfBirth)) + + /** + * Sets [Builder.dateOfBirth] to an arbitrary JSON value. + * + * You should usually call [Builder.dateOfBirth] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateOfBirth(dateOfBirth: JsonField) = apply { + this.dateOfBirth = dateOfBirth + } + + /** A means of verifying the person's identity. */ + fun identification(identification: Identification) = + identification(JsonField.of(identification)) + + /** + * Sets [Builder.identification] to an arbitrary JSON value. + * + * You should usually call [Builder.identification] with a well-typed [Identification] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun identification(identification: JsonField) = apply { + this.identification = identification + } + + /** The person's legal name. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + 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 [Individual]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .address() + * .dateOfBirth() + * .identification() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Individual = + Individual( + checkRequired("address", address), + checkRequired("dateOfBirth", dateOfBirth), + checkRequired("identification", identification), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Individual = apply { + if (validated) { + return@apply + } + + address().validate() + dateOfBirth() + identification().validate() + name() + 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 = + (address.asKnown().getOrNull()?.validity() ?: 0) + + (if (dateOfBirth.asKnown().isPresent) 1 else 0) + + (identification.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + /** The person's address. */ + class Address + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val city: JsonField, + private val country: JsonField, + private val line1: JsonField, + private val line2: JsonField, + private val state: JsonField, + private val zip: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("city") @ExcludeMissing city: JsonField = JsonMissing.of(), + @JsonProperty("country") + @ExcludeMissing + country: JsonField = JsonMissing.of(), + @JsonProperty("line1") @ExcludeMissing line1: JsonField = JsonMissing.of(), + @JsonProperty("line2") @ExcludeMissing line2: JsonField = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), + @JsonProperty("zip") @ExcludeMissing zip: JsonField = JsonMissing.of(), + ) : this(city, country, line1, line2, state, zip, mutableMapOf()) + + /** + * The city, district, town, or village of the address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun city(): Optional = city.getOptional("city") + + /** + * The two-letter ISO 3166-1 alpha-2 code for the country of the address. + * + * @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 country(): String = country.getRequired("country") + + /** + * The first line of the address. + * + * @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 line1(): String = line1.getRequired("line1") + + /** + * The second line of the address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun line2(): Optional = line2.getOptional("line2") + + /** + * The two-letter United States Postal Service (USPS) abbreviation for the US state, + * province, or region of the address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun state(): Optional = state.getOptional("state") + + /** + * The ZIP or postal code of the address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun zip(): Optional = zip.getOptional("zip") + + /** + * Returns the raw JSON value of [city]. + * + * Unlike [city], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + /** + * Returns the raw JSON value of [line1]. + * + * Unlike [line1], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 + + /** + * Returns the raw JSON value of [line2]. + * + * Unlike [line2], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 + + /** + * Returns the raw JSON value of [state]. + * + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + + /** + * Returns the raw JSON value of [zip]. + * + * Unlike [zip], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("zip") @ExcludeMissing fun _zip(): JsonField = zip + + @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 [Address]. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * .line2() + * .state() + * .zip() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Address]. */ + class Builder internal constructor() { + + private var city: JsonField? = null + private var country: JsonField? = null + private var line1: JsonField? = null + private var line2: JsonField? = null + private var state: JsonField? = null + private var zip: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(address: Address) = apply { + city = address.city + country = address.country + line1 = address.line1 + line2 = address.line2 + state = address.state + zip = address.zip + additionalProperties = address.additionalProperties.toMutableMap() + } + + /** The city, district, town, or village of the address. */ + fun city(city: String?) = city(JsonField.ofNullable(city)) + + /** Alias for calling [Builder.city] with `city.orElse(null)`. */ + fun city(city: Optional) = city(city.getOrNull()) + + /** + * Sets [Builder.city] to an arbitrary JSON value. + * + * You should usually call [Builder.city] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun city(city: JsonField) = apply { this.city = city } + + /** The two-letter ISO 3166-1 alpha-2 code for the country of the address. */ + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + /** The first line of the address. */ + fun line1(line1: String) = line1(JsonField.of(line1)) + + /** + * Sets [Builder.line1] to an arbitrary JSON value. + * + * You should usually call [Builder.line1] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun line1(line1: JsonField) = apply { this.line1 = line1 } + + /** The second line of the address. */ + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) + + /** Alias for calling [Builder.line2] with `line2.orElse(null)`. */ + fun line2(line2: Optional) = line2(line2.getOrNull()) + + /** + * Sets [Builder.line2] to an arbitrary JSON value. + * + * You should usually call [Builder.line2] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun line2(line2: JsonField) = apply { this.line2 = line2 } + + /** + * The two-letter United States Postal Service (USPS) abbreviation for the US state, + * province, or region of the address. + */ + fun state(state: String?) = state(JsonField.ofNullable(state)) + + /** Alias for calling [Builder.state] with `state.orElse(null)`. */ + fun state(state: Optional) = state(state.getOrNull()) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun state(state: JsonField) = apply { this.state = state } + + /** The ZIP or postal code of the address. */ + fun zip(zip: String?) = zip(JsonField.ofNullable(zip)) + + /** Alias for calling [Builder.zip] with `zip.orElse(null)`. */ + fun zip(zip: Optional) = zip(zip.getOrNull()) + + /** + * Sets [Builder.zip] to an arbitrary JSON value. + * + * You should usually call [Builder.zip] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun zip(zip: JsonField) = apply { this.zip = zip } + + 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 [Address]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * .line2() + * .state() + * .zip() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Address = + Address( + checkRequired("city", city), + checkRequired("country", country), + checkRequired("line1", line1), + checkRequired("line2", line2), + checkRequired("state", state), + checkRequired("zip", zip), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Address = apply { + if (validated) { + return@apply + } + + city() + country() + line1() + line2() + state() + zip() + 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 (city.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (line1.asKnown().isPresent) 1 else 0) + + (if (line2.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + + (if (zip.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Address && + city == other.city && + country == other.country && + line1 == other.line1 && + line2 == other.line2 && + state == other.state && + zip == other.zip && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(city, country, line1, line2, state, zip, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Address{city=$city, country=$country, line1=$line1, line2=$line2, state=$state, zip=$zip, additionalProperties=$additionalProperties}" + } + + /** A means of verifying the person's identity. */ + class Identification + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val method: JsonField, + private val numberLast4: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("method") + @ExcludeMissing + method: JsonField = JsonMissing.of(), + @JsonProperty("number_last4") + @ExcludeMissing + numberLast4: JsonField = JsonMissing.of(), + ) : this(method, numberLast4, mutableMapOf()) + + /** + * A method that can be used to verify the individual's identity. + * + * @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 method(): Method = method.getRequired("method") + + /** + * The last 4 digits of the identification number that can be used to verify the + * individual's identity. + * + * @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 numberLast4(): String = numberLast4.getRequired("number_last4") + + /** + * Returns the raw JSON value of [method]. + * + * Unlike [method], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method + + /** + * Returns the raw JSON value of [numberLast4]. + * + * Unlike [numberLast4], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("number_last4") + @ExcludeMissing + fun _numberLast4(): JsonField = numberLast4 + + @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 [Identification]. + * + * The following fields are required: + * ```java + * .method() + * .numberLast4() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Identification]. */ + class Builder internal constructor() { + + private var method: JsonField? = null + private var numberLast4: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(identification: Identification) = apply { + method = identification.method + numberLast4 = identification.numberLast4 + additionalProperties = identification.additionalProperties.toMutableMap() + } + + /** A method that can be used to verify the individual's identity. */ + fun method(method: Method) = method(JsonField.of(method)) + + /** + * Sets [Builder.method] to an arbitrary JSON value. + * + * You should usually call [Builder.method] with a well-typed [Method] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun method(method: JsonField) = apply { this.method = method } + + /** + * The last 4 digits of the identification number that can be used to verify the + * individual's identity. + */ + fun numberLast4(numberLast4: String) = numberLast4(JsonField.of(numberLast4)) + + /** + * Sets [Builder.numberLast4] to an arbitrary JSON value. + * + * You should usually call [Builder.numberLast4] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun numberLast4(numberLast4: JsonField) = apply { + this.numberLast4 = numberLast4 + } + + 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 [Identification]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .method() + * .numberLast4() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Identification = + Identification( + checkRequired("method", method), + checkRequired("numberLast4", numberLast4), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Identification = apply { + if (validated) { + return@apply + } + + method().validate() + numberLast4() + 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 = + (method.asKnown().getOrNull()?.validity() ?: 0) + + (if (numberLast4.asKnown().isPresent) 1 else 0) + + /** A method that can be used to verify the individual's identity. */ + class Method @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 { + + /** A social security number. */ + @JvmField val SOCIAL_SECURITY_NUMBER = of("social_security_number") + + /** An individual taxpayer identification number (ITIN). */ + @JvmField + val INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER = + of("individual_taxpayer_identification_number") + + /** A passport number. */ + @JvmField val PASSPORT = of("passport") + + /** A driver's license number. */ + @JvmField val DRIVERS_LICENSE = of("drivers_license") + + /** Another identifying document. */ + @JvmField val OTHER = of("other") + + @JvmStatic fun of(value: String) = Method(JsonField.of(value)) + } + + /** An enum containing [Method]'s known values. */ + enum class Known { + /** A social security number. */ + SOCIAL_SECURITY_NUMBER, + /** An individual taxpayer identification number (ITIN). */ + INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER, + /** A passport number. */ + PASSPORT, + /** A driver's license number. */ + DRIVERS_LICENSE, + /** Another identifying document. */ + OTHER, + } + + /** + * An enum containing [Method]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Method] 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 { + /** A social security number. */ + SOCIAL_SECURITY_NUMBER, + /** An individual taxpayer identification number (ITIN). */ + INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER, + /** A passport number. */ + PASSPORT, + /** A driver's license number. */ + DRIVERS_LICENSE, + /** Another identifying document. */ + OTHER, + /** + * An enum member indicating that [Method] 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) { + SOCIAL_SECURITY_NUMBER -> Value.SOCIAL_SECURITY_NUMBER + INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER -> + Value.INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER + PASSPORT -> Value.PASSPORT + DRIVERS_LICENSE -> Value.DRIVERS_LICENSE + OTHER -> Value.OTHER + 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) { + SOCIAL_SECURITY_NUMBER -> Known.SOCIAL_SECURITY_NUMBER + INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER -> + Known.INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER + PASSPORT -> Known.PASSPORT + DRIVERS_LICENSE -> Known.DRIVERS_LICENSE + OTHER -> Known.OTHER + else -> throw IncreaseInvalidDataException("Unknown Method: $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(): Method = 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 Method && 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 Identification && + method == other.method && + numberLast4 == other.numberLast4 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(method, numberLast4, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Identification{method=$method, numberLast4=$numberLast4, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Individual && + address == other.address && + dateOfBirth == other.dateOfBirth && + identification == other.identification && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(address, dateOfBirth, identification, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Individual{address=$address, dateOfBirth=$dateOfBirth, identification=$identification, name=$name, additionalProperties=$additionalProperties}" + } + + class Prong @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 { + + /** A person with 25% or greater direct or indirect ownership of the entity. */ + @JvmField val OWNERSHIP = of("ownership") + + /** A person who manages, directs, or has significant control of the entity. */ + @JvmField val CONTROL = of("control") + + @JvmStatic fun of(value: String) = Prong(JsonField.of(value)) + } + + /** An enum containing [Prong]'s known values. */ + enum class Known { + /** A person with 25% or greater direct or indirect ownership of the entity. */ + OWNERSHIP, + /** A person who manages, directs, or has significant control of the entity. */ + CONTROL, + } + + /** + * An enum containing [Prong]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Prong] 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 { + /** A person with 25% or greater direct or indirect ownership of the entity. */ + OWNERSHIP, + /** A person who manages, directs, or has significant control of the entity. */ + CONTROL, + /** An enum member indicating that [Prong] 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) { + OWNERSHIP -> Value.OWNERSHIP + CONTROL -> Value.CONTROL + 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) { + OWNERSHIP -> Known.OWNERSHIP + CONTROL -> Known.CONTROL + else -> throw IncreaseInvalidDataException("Unknown Prong: $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(): Prong = 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 Prong && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * A constant representing the object's type. For this resource it will always be + * `entity_beneficial_owner`. + */ + class Type @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 { + + @JvmField val ENTITY_BENEFICIAL_OWNER = of("entity_beneficial_owner") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ENTITY_BENEFICIAL_OWNER + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + ENTITY_BENEFICIAL_OWNER, + /** An enum member indicating that [Type] 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) { + ENTITY_BENEFICIAL_OWNER -> Value.ENTITY_BENEFICIAL_OWNER + 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) { + ENTITY_BENEFICIAL_OWNER -> Known.ENTITY_BENEFICIAL_OWNER + else -> throw IncreaseInvalidDataException("Unknown Type: $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(): Type = 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 Type && 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 EntityBeneficialOwner && + id == other.id && + companyTitle == other.companyTitle && + createdAt == other.createdAt && + individual == other.individual && + prongs == other.prongs && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, companyTitle, createdAt, individual, prongs, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EntityBeneficialOwner{id=$id, companyTitle=$companyTitle, createdAt=$createdAt, individual=$individual, prongs=$prongs, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/entities/Entity.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/entities/Entity.kt index ede15978d..abd4f55cd 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/entities/Entity.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/entities/Entity.kt @@ -15,6 +15,7 @@ import com.increase.api.core.checkKnown import com.increase.api.core.checkRequired import com.increase.api.core.toImmutable import com.increase.api.errors.IncreaseInvalidDataException +import com.increase.api.models.beneficialowners.EntityBeneficialOwner import com.increase.api.models.supplementaldocuments.EntitySupplementalDocument import java.time.LocalDate import java.time.OffsetDateTime @@ -954,7 +955,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val address: JsonField
, - private val beneficialOwners: JsonField>, + private val beneficialOwners: JsonField>, private val email: JsonField, private val incorporationState: JsonField, private val industryCode: JsonField, @@ -969,7 +970,7 @@ private constructor( @JsonProperty("address") @ExcludeMissing address: JsonField
= JsonMissing.of(), @JsonProperty("beneficial_owners") @ExcludeMissing - beneficialOwners: JsonField> = JsonMissing.of(), + beneficialOwners: JsonField> = JsonMissing.of(), @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), @JsonProperty("incorporation_state") @ExcludeMissing @@ -1008,7 +1009,7 @@ private constructor( * @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 beneficialOwners(): List = + fun beneficialOwners(): List = beneficialOwners.getRequired("beneficial_owners") /** @@ -1077,7 +1078,7 @@ private constructor( */ @JsonProperty("beneficial_owners") @ExcludeMissing - fun _beneficialOwners(): JsonField> = beneficialOwners + fun _beneficialOwners(): JsonField> = beneficialOwners /** * Returns the raw JSON value of [email]. @@ -1166,7 +1167,7 @@ private constructor( class Builder internal constructor() { private var address: JsonField
? = null - private var beneficialOwners: JsonField>? = null + private var beneficialOwners: JsonField>? = null private var email: JsonField? = null private var incorporationState: JsonField? = null private var industryCode: JsonField? = null @@ -1204,26 +1205,26 @@ private constructor( * The identifying details of anyone controlling or owning 25% or more of the * corporation. */ - fun beneficialOwners(beneficialOwners: List) = + fun beneficialOwners(beneficialOwners: List) = beneficialOwners(JsonField.of(beneficialOwners)) /** * Sets [Builder.beneficialOwners] to an arbitrary JSON value. * * You should usually call [Builder.beneficialOwners] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun beneficialOwners(beneficialOwners: JsonField>) = apply { + fun beneficialOwners(beneficialOwners: JsonField>) = apply { this.beneficialOwners = beneficialOwners.map { it.toMutableList() } } /** - * Adds a single [BeneficialOwner] to [beneficialOwners]. + * Adds a single [EntityBeneficialOwner] to [beneficialOwners]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addBeneficialOwner(beneficialOwner: BeneficialOwner) = apply { + fun addBeneficialOwner(beneficialOwner: EntityBeneficialOwner) = apply { beneficialOwners = (beneficialOwners ?: JsonField.of(mutableListOf())).also { checkKnown("beneficialOwners", it).add(beneficialOwner) @@ -1759,1554 +1760,6 @@ private constructor( "Address{city=$city, line1=$line1, line2=$line2, state=$state, zip=$zip, additionalProperties=$additionalProperties}" } - class BeneficialOwner - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val companyTitle: JsonField, - private val individual: JsonField, - private val prongs: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("company_title") - @ExcludeMissing - companyTitle: JsonField = JsonMissing.of(), - @JsonProperty("individual") - @ExcludeMissing - individual: JsonField = JsonMissing.of(), - @JsonProperty("prongs") - @ExcludeMissing - prongs: JsonField> = JsonMissing.of(), - ) : this(id, companyTitle, individual, prongs, mutableMapOf()) - - /** - * The identifier of this beneficial owner. - * - * @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 id(): String = id.getRequired("id") - - /** - * This person's role or title within the entity. - * - * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun companyTitle(): Optional = companyTitle.getOptional("company_title") - - /** - * Personal details for the beneficial owner. - * - * @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 individual(): Individual = individual.getRequired("individual") - - /** - * Why this person is considered a beneficial owner of the entity. - * - * @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 prongs(): List = prongs.getRequired("prongs") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [companyTitle]. - * - * Unlike [companyTitle], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("company_title") - @ExcludeMissing - fun _companyTitle(): JsonField = companyTitle - - /** - * Returns the raw JSON value of [individual]. - * - * Unlike [individual], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("individual") - @ExcludeMissing - fun _individual(): JsonField = individual - - /** - * Returns the raw JSON value of [prongs]. - * - * Unlike [prongs], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("prongs") @ExcludeMissing fun _prongs(): JsonField> = prongs - - @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 [BeneficialOwner]. - * - * The following fields are required: - * ```java - * .id() - * .companyTitle() - * .individual() - * .prongs() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BeneficialOwner]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var companyTitle: JsonField? = null - private var individual: JsonField? = null - private var prongs: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(beneficialOwner: BeneficialOwner) = apply { - id = beneficialOwner.id - companyTitle = beneficialOwner.companyTitle - individual = beneficialOwner.individual - prongs = beneficialOwner.prongs.map { it.toMutableList() } - additionalProperties = beneficialOwner.additionalProperties.toMutableMap() - } - - /** The identifier of this beneficial owner. */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - /** This person's role or title within the entity. */ - fun companyTitle(companyTitle: String?) = - companyTitle(JsonField.ofNullable(companyTitle)) - - /** Alias for calling [Builder.companyTitle] with `companyTitle.orElse(null)`. */ - fun companyTitle(companyTitle: Optional) = - companyTitle(companyTitle.getOrNull()) - - /** - * Sets [Builder.companyTitle] to an arbitrary JSON value. - * - * You should usually call [Builder.companyTitle] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun companyTitle(companyTitle: JsonField) = apply { - this.companyTitle = companyTitle - } - - /** Personal details for the beneficial owner. */ - fun individual(individual: Individual) = individual(JsonField.of(individual)) - - /** - * Sets [Builder.individual] to an arbitrary JSON value. - * - * You should usually call [Builder.individual] with a well-typed [Individual] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun individual(individual: JsonField) = apply { - this.individual = individual - } - - /** Why this person is considered a beneficial owner of the entity. */ - fun prongs(prongs: List) = prongs(JsonField.of(prongs)) - - /** - * Sets [Builder.prongs] to an arbitrary JSON value. - * - * You should usually call [Builder.prongs] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun prongs(prongs: JsonField>) = apply { - this.prongs = prongs.map { it.toMutableList() } - } - - /** - * Adds a single [Prong] to [prongs]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addProng(prong: Prong) = apply { - prongs = - (prongs ?: JsonField.of(mutableListOf())).also { - checkKnown("prongs", it).add(prong) - } - } - - 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 [BeneficialOwner]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .companyTitle() - * .individual() - * .prongs() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BeneficialOwner = - BeneficialOwner( - checkRequired("id", id), - checkRequired("companyTitle", companyTitle), - checkRequired("individual", individual), - checkRequired("prongs", prongs).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BeneficialOwner = apply { - if (validated) { - return@apply - } - - id() - companyTitle() - individual().validate() - prongs().forEach { 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 = - (if (id.asKnown().isPresent) 1 else 0) + - (if (companyTitle.asKnown().isPresent) 1 else 0) + - (individual.asKnown().getOrNull()?.validity() ?: 0) + - (prongs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** Personal details for the beneficial owner. */ - class Individual - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val address: JsonField
, - private val dateOfBirth: JsonField, - private val identification: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("address") - @ExcludeMissing - address: JsonField
= JsonMissing.of(), - @JsonProperty("date_of_birth") - @ExcludeMissing - dateOfBirth: JsonField = JsonMissing.of(), - @JsonProperty("identification") - @ExcludeMissing - identification: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(address, dateOfBirth, identification, name, mutableMapOf()) - - /** - * The person's address. - * - * @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 address(): Address = address.getRequired("address") - - /** - * The person's date of birth in YYYY-MM-DD format. - * - * @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 dateOfBirth(): LocalDate = dateOfBirth.getRequired("date_of_birth") - - /** - * A means of verifying the person's identity. - * - * @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 identification(): Identification = identification.getRequired("identification") - - /** - * The person's legal name. - * - * @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 name(): String = name.getRequired("name") - - /** - * Returns the raw JSON value of [address]. - * - * Unlike [address], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("address") - @ExcludeMissing - fun _address(): JsonField
= address - - /** - * Returns the raw JSON value of [dateOfBirth]. - * - * Unlike [dateOfBirth], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("date_of_birth") - @ExcludeMissing - fun _dateOfBirth(): JsonField = dateOfBirth - - /** - * Returns the raw JSON value of [identification]. - * - * Unlike [identification], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("identification") - @ExcludeMissing - fun _identification(): JsonField = identification - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @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 [Individual]. - * - * The following fields are required: - * ```java - * .address() - * .dateOfBirth() - * .identification() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Individual]. */ - class Builder internal constructor() { - - private var address: JsonField
? = null - private var dateOfBirth: JsonField? = null - private var identification: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(individual: Individual) = apply { - address = individual.address - dateOfBirth = individual.dateOfBirth - identification = individual.identification - name = individual.name - additionalProperties = individual.additionalProperties.toMutableMap() - } - - /** The person's address. */ - fun address(address: Address) = address(JsonField.of(address)) - - /** - * Sets [Builder.address] to an arbitrary JSON value. - * - * You should usually call [Builder.address] with a well-typed [Address] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun address(address: JsonField
) = apply { this.address = address } - - /** The person's date of birth in YYYY-MM-DD format. */ - fun dateOfBirth(dateOfBirth: LocalDate) = dateOfBirth(JsonField.of(dateOfBirth)) - - /** - * Sets [Builder.dateOfBirth] to an arbitrary JSON value. - * - * You should usually call [Builder.dateOfBirth] with a well-typed [LocalDate] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun dateOfBirth(dateOfBirth: JsonField) = apply { - this.dateOfBirth = dateOfBirth - } - - /** A means of verifying the person's identity. */ - fun identification(identification: Identification) = - identification(JsonField.of(identification)) - - /** - * Sets [Builder.identification] to an arbitrary JSON value. - * - * You should usually call [Builder.identification] with a well-typed - * [Identification] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun identification(identification: JsonField) = apply { - this.identification = identification - } - - /** The person's legal name. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - 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 [Individual]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .address() - * .dateOfBirth() - * .identification() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Individual = - Individual( - checkRequired("address", address), - checkRequired("dateOfBirth", dateOfBirth), - checkRequired("identification", identification), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Individual = apply { - if (validated) { - return@apply - } - - address().validate() - dateOfBirth() - identification().validate() - name() - 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 = - (address.asKnown().getOrNull()?.validity() ?: 0) + - (if (dateOfBirth.asKnown().isPresent) 1 else 0) + - (identification.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) - - /** The person's address. */ - class Address - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val city: JsonField, - private val country: JsonField, - private val line1: JsonField, - private val line2: JsonField, - private val state: JsonField, - private val zip: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("city") - @ExcludeMissing - city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - line2: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - state: JsonField = JsonMissing.of(), - @JsonProperty("zip") - @ExcludeMissing - zip: JsonField = JsonMissing.of(), - ) : this(city, country, line1, line2, state, zip, mutableMapOf()) - - /** - * The city, district, town, or village of the address. - * - * @throws IncreaseInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun city(): Optional = city.getOptional("city") - - /** - * The two-letter ISO 3166-1 alpha-2 code for the country of the address. - * - * @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 country(): String = country.getRequired("country") - - /** - * The first line of the address. - * - * @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 line1(): String = line1.getRequired("line1") - - /** - * The second line of the address. - * - * @throws IncreaseInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun line2(): Optional = line2.getOptional("line2") - - /** - * The two-letter United States Postal Service (USPS) abbreviation for the US - * state, province, or region of the address. - * - * @throws IncreaseInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun state(): Optional = state.getOptional("state") - - /** - * The ZIP or postal code of the address. - * - * @throws IncreaseInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun zip(): Optional = zip.getOptional("zip") - - /** - * Returns the raw JSON value of [city]. - * - * Unlike [city], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - /** - * Returns the raw JSON value of [country]. - * - * Unlike [country], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("country") - @ExcludeMissing - fun _country(): JsonField = country - - /** - * Returns the raw JSON value of [line1]. - * - * Unlike [line1], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - /** - * Returns the raw JSON value of [line2]. - * - * Unlike [line2], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - /** - * Returns the raw JSON value of [state]. - * - * Unlike [state], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - /** - * Returns the raw JSON value of [zip]. - * - * Unlike [zip], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("zip") @ExcludeMissing fun _zip(): JsonField = zip - - @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 [Address]. - * - * The following fields are required: - * ```java - * .city() - * .country() - * .line1() - * .line2() - * .state() - * .zip() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Address]. */ - class Builder internal constructor() { - - private var city: JsonField? = null - private var country: JsonField? = null - private var line1: JsonField? = null - private var line2: JsonField? = null - private var state: JsonField? = null - private var zip: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(address: Address) = apply { - city = address.city - country = address.country - line1 = address.line1 - line2 = address.line2 - state = address.state - zip = address.zip - additionalProperties = address.additionalProperties.toMutableMap() - } - - /** The city, district, town, or village of the address. */ - fun city(city: String?) = city(JsonField.ofNullable(city)) - - /** Alias for calling [Builder.city] with `city.orElse(null)`. */ - fun city(city: Optional) = city(city.getOrNull()) - - /** - * Sets [Builder.city] to an arbitrary JSON value. - * - * You should usually call [Builder.city] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun city(city: JsonField) = apply { this.city = city } - - /** - * The two-letter ISO 3166-1 alpha-2 code for the country of the address. - */ - fun country(country: String) = country(JsonField.of(country)) - - /** - * Sets [Builder.country] to an arbitrary JSON value. - * - * You should usually call [Builder.country] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun country(country: JsonField) = apply { this.country = country } - - /** The first line of the address. */ - fun line1(line1: String) = line1(JsonField.of(line1)) - - /** - * Sets [Builder.line1] to an arbitrary JSON value. - * - * You should usually call [Builder.line1] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - /** The second line of the address. */ - fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) - - /** Alias for calling [Builder.line2] with `line2.orElse(null)`. */ - fun line2(line2: Optional) = line2(line2.getOrNull()) - - /** - * Sets [Builder.line2] to an arbitrary JSON value. - * - * You should usually call [Builder.line2] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - /** - * The two-letter United States Postal Service (USPS) abbreviation for the - * US state, province, or region of the address. - */ - fun state(state: String?) = state(JsonField.ofNullable(state)) - - /** Alias for calling [Builder.state] with `state.orElse(null)`. */ - fun state(state: Optional) = state(state.getOrNull()) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun state(state: JsonField) = apply { this.state = state } - - /** The ZIP or postal code of the address. */ - fun zip(zip: String?) = zip(JsonField.ofNullable(zip)) - - /** Alias for calling [Builder.zip] with `zip.orElse(null)`. */ - fun zip(zip: Optional) = zip(zip.getOrNull()) - - /** - * Sets [Builder.zip] to an arbitrary JSON value. - * - * You should usually call [Builder.zip] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun zip(zip: JsonField) = apply { this.zip = zip } - - 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 [Address]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .city() - * .country() - * .line1() - * .line2() - * .state() - * .zip() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Address = - Address( - checkRequired("city", city), - checkRequired("country", country), - checkRequired("line1", line1), - checkRequired("line2", line2), - checkRequired("state", state), - checkRequired("zip", zip), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Address = apply { - if (validated) { - return@apply - } - - city() - country() - line1() - line2() - state() - zip() - 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 (city.asKnown().isPresent) 1 else 0) + - (if (country.asKnown().isPresent) 1 else 0) + - (if (line1.asKnown().isPresent) 1 else 0) + - (if (line2.asKnown().isPresent) 1 else 0) + - (if (state.asKnown().isPresent) 1 else 0) + - (if (zip.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Address && - city == other.city && - country == other.country && - line1 == other.line1 && - line2 == other.line2 && - state == other.state && - zip == other.zip && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(city, country, line1, line2, state, zip, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Address{city=$city, country=$country, line1=$line1, line2=$line2, state=$state, zip=$zip, additionalProperties=$additionalProperties}" - } - - /** A means of verifying the person's identity. */ - class Identification - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val method: JsonField, - private val numberLast4: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("method") - @ExcludeMissing - method: JsonField = JsonMissing.of(), - @JsonProperty("number_last4") - @ExcludeMissing - numberLast4: JsonField = JsonMissing.of(), - ) : this(method, numberLast4, mutableMapOf()) - - /** - * A method that can be used to verify the individual's identity. - * - * @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 method(): Method = method.getRequired("method") - - /** - * The last 4 digits of the identification number that can be used to verify the - * individual's identity. - * - * @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 numberLast4(): String = numberLast4.getRequired("number_last4") - - /** - * Returns the raw JSON value of [method]. - * - * Unlike [method], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("method") - @ExcludeMissing - fun _method(): JsonField = method - - /** - * Returns the raw JSON value of [numberLast4]. - * - * Unlike [numberLast4], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("number_last4") - @ExcludeMissing - fun _numberLast4(): JsonField = numberLast4 - - @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 - * [Identification]. - * - * The following fields are required: - * ```java - * .method() - * .numberLast4() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Identification]. */ - class Builder internal constructor() { - - private var method: JsonField? = null - private var numberLast4: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(identification: Identification) = apply { - method = identification.method - numberLast4 = identification.numberLast4 - additionalProperties = - identification.additionalProperties.toMutableMap() - } - - /** A method that can be used to verify the individual's identity. */ - fun method(method: Method) = method(JsonField.of(method)) - - /** - * Sets [Builder.method] to an arbitrary JSON value. - * - * You should usually call [Builder.method] with a well-typed [Method] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun method(method: JsonField) = apply { this.method = method } - - /** - * The last 4 digits of the identification number that can be used to verify - * the individual's identity. - */ - fun numberLast4(numberLast4: String) = - numberLast4(JsonField.of(numberLast4)) - - /** - * Sets [Builder.numberLast4] to an arbitrary JSON value. - * - * You should usually call [Builder.numberLast4] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun numberLast4(numberLast4: JsonField) = apply { - this.numberLast4 = numberLast4 - } - - 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 [Identification]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .method() - * .numberLast4() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Identification = - Identification( - checkRequired("method", method), - checkRequired("numberLast4", numberLast4), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Identification = apply { - if (validated) { - return@apply - } - - method().validate() - numberLast4() - 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 = - (method.asKnown().getOrNull()?.validity() ?: 0) + - (if (numberLast4.asKnown().isPresent) 1 else 0) - - /** A method that can be used to verify the individual's identity. */ - class Method - @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 { - - /** A social security number. */ - @JvmField val SOCIAL_SECURITY_NUMBER = of("social_security_number") - - /** An individual taxpayer identification number (ITIN). */ - @JvmField - val INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER = - of("individual_taxpayer_identification_number") - - /** A passport number. */ - @JvmField val PASSPORT = of("passport") - - /** A driver's license number. */ - @JvmField val DRIVERS_LICENSE = of("drivers_license") - - /** Another identifying document. */ - @JvmField val OTHER = of("other") - - @JvmStatic fun of(value: String) = Method(JsonField.of(value)) - } - - /** An enum containing [Method]'s known values. */ - enum class Known { - /** A social security number. */ - SOCIAL_SECURITY_NUMBER, - /** An individual taxpayer identification number (ITIN). */ - INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER, - /** A passport number. */ - PASSPORT, - /** A driver's license number. */ - DRIVERS_LICENSE, - /** Another identifying document. */ - OTHER, - } - - /** - * An enum containing [Method]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Method] 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 { - /** A social security number. */ - SOCIAL_SECURITY_NUMBER, - /** An individual taxpayer identification number (ITIN). */ - INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER, - /** A passport number. */ - PASSPORT, - /** A driver's license number. */ - DRIVERS_LICENSE, - /** Another identifying document. */ - OTHER, - /** - * An enum member indicating that [Method] 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) { - SOCIAL_SECURITY_NUMBER -> Value.SOCIAL_SECURITY_NUMBER - INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER -> - Value.INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER - PASSPORT -> Value.PASSPORT - DRIVERS_LICENSE -> Value.DRIVERS_LICENSE - OTHER -> Value.OTHER - 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) { - SOCIAL_SECURITY_NUMBER -> Known.SOCIAL_SECURITY_NUMBER - INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER -> - Known.INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER - PASSPORT -> Known.PASSPORT - DRIVERS_LICENSE -> Known.DRIVERS_LICENSE - OTHER -> Known.OTHER - else -> throw IncreaseInvalidDataException("Unknown Method: $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(): Method = 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 Method && 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 Identification && - method == other.method && - numberLast4 == other.numberLast4 && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(method, numberLast4, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Identification{method=$method, numberLast4=$numberLast4, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Individual && - address == other.address && - dateOfBirth == other.dateOfBirth && - identification == other.identification && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(address, dateOfBirth, identification, name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Individual{address=$address, dateOfBirth=$dateOfBirth, identification=$identification, name=$name, additionalProperties=$additionalProperties}" - } - - class Prong @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 { - - /** A person with 25% or greater direct or indirect ownership of the entity. */ - @JvmField val OWNERSHIP = of("ownership") - - /** A person who manages, directs, or has significant control of the entity. */ - @JvmField val CONTROL = of("control") - - @JvmStatic fun of(value: String) = Prong(JsonField.of(value)) - } - - /** An enum containing [Prong]'s known values. */ - enum class Known { - /** A person with 25% or greater direct or indirect ownership of the entity. */ - OWNERSHIP, - /** A person who manages, directs, or has significant control of the entity. */ - CONTROL, - } - - /** - * An enum containing [Prong]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Prong] 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 { - /** A person with 25% or greater direct or indirect ownership of the entity. */ - OWNERSHIP, - /** A person who manages, directs, or has significant control of the entity. */ - CONTROL, - /** - * An enum member indicating that [Prong] 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) { - OWNERSHIP -> Value.OWNERSHIP - CONTROL -> Value.CONTROL - 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) { - OWNERSHIP -> Known.OWNERSHIP - CONTROL -> Known.CONTROL - else -> throw IncreaseInvalidDataException("Unknown Prong: $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(): Prong = 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 Prong && 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 BeneficialOwner && - id == other.id && - companyTitle == other.companyTitle && - individual == other.individual && - prongs == other.prongs && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, companyTitle, individual, prongs, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BeneficialOwner{id=$id, companyTitle=$companyTitle, individual=$individual, prongs=$prongs, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/BeneficialOwnerServiceAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/BeneficialOwnerServiceAsync.kt new file mode 100644 index 000000000..9624e44a3 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/BeneficialOwnerServiceAsync.kt @@ -0,0 +1,155 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.beneficialowners.BeneficialOwnerListPageAsync +import com.increase.api.models.beneficialowners.BeneficialOwnerListParams +import com.increase.api.models.beneficialowners.BeneficialOwnerRetrieveParams +import com.increase.api.models.beneficialowners.EntityBeneficialOwner +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface BeneficialOwnerServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BeneficialOwnerServiceAsync + + /** Retrieve a Beneficial Owner */ + fun retrieve(entityBeneficialOwnerId: String): CompletableFuture = + retrieve(entityBeneficialOwnerId, BeneficialOwnerRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + entityBeneficialOwnerId: String, + params: BeneficialOwnerRetrieveParams = BeneficialOwnerRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve( + params.toBuilder().entityBeneficialOwnerId(entityBeneficialOwnerId).build(), + requestOptions, + ) + + /** @see retrieve */ + fun retrieve( + entityBeneficialOwnerId: String, + params: BeneficialOwnerRetrieveParams = BeneficialOwnerRetrieveParams.none(), + ): CompletableFuture = + retrieve(entityBeneficialOwnerId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: BeneficialOwnerRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: BeneficialOwnerRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + entityBeneficialOwnerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(entityBeneficialOwnerId, BeneficialOwnerRetrieveParams.none(), requestOptions) + + /** List Beneficial Owners */ + fun list(params: BeneficialOwnerListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: BeneficialOwnerListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [BeneficialOwnerServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): BeneficialOwnerServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /entity_beneficial_owners/{entity_beneficial_owner_id}`, but is otherwise the same as + * [BeneficialOwnerServiceAsync.retrieve]. + */ + fun retrieve( + entityBeneficialOwnerId: String + ): CompletableFuture> = + retrieve(entityBeneficialOwnerId, BeneficialOwnerRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + entityBeneficialOwnerId: String, + params: BeneficialOwnerRetrieveParams = BeneficialOwnerRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve( + params.toBuilder().entityBeneficialOwnerId(entityBeneficialOwnerId).build(), + requestOptions, + ) + + /** @see retrieve */ + fun retrieve( + entityBeneficialOwnerId: String, + params: BeneficialOwnerRetrieveParams = BeneficialOwnerRetrieveParams.none(), + ): CompletableFuture> = + retrieve(entityBeneficialOwnerId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: BeneficialOwnerRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: BeneficialOwnerRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + entityBeneficialOwnerId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(entityBeneficialOwnerId, BeneficialOwnerRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /entity_beneficial_owners`, but is otherwise the + * same as [BeneficialOwnerServiceAsync.list]. + */ + fun list( + params: BeneficialOwnerListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: BeneficialOwnerListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/BeneficialOwnerServiceAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/BeneficialOwnerServiceAsyncImpl.kt new file mode 100644 index 000000000..8b79fc7fb --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/BeneficialOwnerServiceAsyncImpl.kt @@ -0,0 +1,139 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.checkRequired +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.parseable +import com.increase.api.core.prepareAsync +import com.increase.api.models.beneficialowners.BeneficialOwnerListPageAsync +import com.increase.api.models.beneficialowners.BeneficialOwnerListPageResponse +import com.increase.api.models.beneficialowners.BeneficialOwnerListParams +import com.increase.api.models.beneficialowners.BeneficialOwnerRetrieveParams +import com.increase.api.models.beneficialowners.EntityBeneficialOwner +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class BeneficialOwnerServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : BeneficialOwnerServiceAsync { + + private val withRawResponse: BeneficialOwnerServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BeneficialOwnerServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): BeneficialOwnerServiceAsync = + BeneficialOwnerServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: BeneficialOwnerRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /entity_beneficial_owners/{entity_beneficial_owner_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: BeneficialOwnerListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /entity_beneficial_owners + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BeneficialOwnerServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BeneficialOwnerServiceAsync.WithRawResponse = + BeneficialOwnerServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: BeneficialOwnerRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("entityBeneficialOwnerId", params.entityBeneficialOwnerId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("entity_beneficial_owners", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: BeneficialOwnerListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("entity_beneficial_owners") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + BeneficialOwnerListPageAsync.builder() + .service(BeneficialOwnerServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/BeneficialOwnerService.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/BeneficialOwnerService.kt new file mode 100644 index 000000000..4be5fa304 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/BeneficialOwnerService.kt @@ -0,0 +1,157 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.beneficialowners.BeneficialOwnerListPage +import com.increase.api.models.beneficialowners.BeneficialOwnerListParams +import com.increase.api.models.beneficialowners.BeneficialOwnerRetrieveParams +import com.increase.api.models.beneficialowners.EntityBeneficialOwner +import java.util.function.Consumer + +interface BeneficialOwnerService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BeneficialOwnerService + + /** Retrieve a Beneficial Owner */ + fun retrieve(entityBeneficialOwnerId: String): EntityBeneficialOwner = + retrieve(entityBeneficialOwnerId, BeneficialOwnerRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + entityBeneficialOwnerId: String, + params: BeneficialOwnerRetrieveParams = BeneficialOwnerRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): EntityBeneficialOwner = + retrieve( + params.toBuilder().entityBeneficialOwnerId(entityBeneficialOwnerId).build(), + requestOptions, + ) + + /** @see retrieve */ + fun retrieve( + entityBeneficialOwnerId: String, + params: BeneficialOwnerRetrieveParams = BeneficialOwnerRetrieveParams.none(), + ): EntityBeneficialOwner = retrieve(entityBeneficialOwnerId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: BeneficialOwnerRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): EntityBeneficialOwner + + /** @see retrieve */ + fun retrieve(params: BeneficialOwnerRetrieveParams): EntityBeneficialOwner = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + entityBeneficialOwnerId: String, + requestOptions: RequestOptions, + ): EntityBeneficialOwner = + retrieve(entityBeneficialOwnerId, BeneficialOwnerRetrieveParams.none(), requestOptions) + + /** List Beneficial Owners */ + fun list(params: BeneficialOwnerListParams): BeneficialOwnerListPage = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: BeneficialOwnerListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BeneficialOwnerListPage + + /** + * A view of [BeneficialOwnerService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): BeneficialOwnerService.WithRawResponse + + /** + * Returns a raw HTTP response for `get + * /entity_beneficial_owners/{entity_beneficial_owner_id}`, but is otherwise the same as + * [BeneficialOwnerService.retrieve]. + */ + @MustBeClosed + fun retrieve(entityBeneficialOwnerId: String): HttpResponseFor = + retrieve(entityBeneficialOwnerId, BeneficialOwnerRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + entityBeneficialOwnerId: String, + params: BeneficialOwnerRetrieveParams = BeneficialOwnerRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve( + params.toBuilder().entityBeneficialOwnerId(entityBeneficialOwnerId).build(), + requestOptions, + ) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + entityBeneficialOwnerId: String, + params: BeneficialOwnerRetrieveParams = BeneficialOwnerRetrieveParams.none(), + ): HttpResponseFor = + retrieve(entityBeneficialOwnerId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: BeneficialOwnerRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: BeneficialOwnerRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + entityBeneficialOwnerId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(entityBeneficialOwnerId, BeneficialOwnerRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /entity_beneficial_owners`, but is otherwise the + * same as [BeneficialOwnerService.list]. + */ + @MustBeClosed + fun list(params: BeneficialOwnerListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: BeneficialOwnerListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/BeneficialOwnerServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/BeneficialOwnerServiceImpl.kt new file mode 100644 index 000000000..2ee3d2971 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/BeneficialOwnerServiceImpl.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.checkRequired +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.parseable +import com.increase.api.core.prepare +import com.increase.api.models.beneficialowners.BeneficialOwnerListPage +import com.increase.api.models.beneficialowners.BeneficialOwnerListPageResponse +import com.increase.api.models.beneficialowners.BeneficialOwnerListParams +import com.increase.api.models.beneficialowners.BeneficialOwnerRetrieveParams +import com.increase.api.models.beneficialowners.EntityBeneficialOwner +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class BeneficialOwnerServiceImpl internal constructor(private val clientOptions: ClientOptions) : + BeneficialOwnerService { + + private val withRawResponse: BeneficialOwnerService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BeneficialOwnerService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BeneficialOwnerService = + BeneficialOwnerServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: BeneficialOwnerRetrieveParams, + requestOptions: RequestOptions, + ): EntityBeneficialOwner = + // get /entity_beneficial_owners/{entity_beneficial_owner_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: BeneficialOwnerListParams, + requestOptions: RequestOptions, + ): BeneficialOwnerListPage = + // get /entity_beneficial_owners + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BeneficialOwnerService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BeneficialOwnerService.WithRawResponse = + BeneficialOwnerServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: BeneficialOwnerRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("entityBeneficialOwnerId", params.entityBeneficialOwnerId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("entity_beneficial_owners", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: BeneficialOwnerListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("entity_beneficial_owners") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + BeneficialOwnerListPage.builder() + .service(BeneficialOwnerServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/core/http/RetryingHttpClientTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/core/http/RetryingHttpClientTest.kt index 15bacd974..48ebd9832 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/core/http/RetryingHttpClientTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/core/http/RetryingHttpClientTest.kt @@ -20,7 +20,11 @@ import com.increase.api.core.RequestOptions import com.increase.api.core.Sleeper import com.increase.api.errors.IncreaseRetryableException import java.io.InputStream +import java.time.Clock import java.time.Duration +import java.time.OffsetDateTime +import java.time.ZoneOffset +import java.time.format.DateTimeFormatter import java.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach @@ -36,6 +40,21 @@ internal class RetryingHttpClientTest { private lateinit var baseUrl: String private lateinit var httpClient: HttpClient + private class RecordingSleeper : Sleeper { + val durations = mutableListOf() + + override fun sleep(duration: Duration) { + durations.add(duration) + } + + override fun sleepAsync(duration: Duration): CompletableFuture { + durations.add(duration) + return CompletableFuture.completedFuture(null) + } + + override fun close() {} + } + @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { baseUrl = wmRuntimeInfo.httpBaseUrl @@ -86,7 +105,8 @@ internal class RetryingHttpClientTest { @ValueSource(booleans = [false, true]) fun execute(async: Boolean) { stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) - val retryingClient = retryingHttpClientBuilder().build() + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).build() val response = retryingClient.execute( @@ -100,6 +120,7 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).isEmpty() assertNoResponseLeaks() } @@ -111,8 +132,12 @@ internal class RetryingHttpClientTest { .withHeader("X-Some-Header", matching("increase-java-retry-.+")) .willReturn(ok()) ) + val sleeper = RecordingSleeper() val retryingClient = - retryingHttpClientBuilder().maxRetries(2).idempotencyHeader("X-Some-Header").build() + retryingHttpClientBuilder(sleeper) + .maxRetries(2) + .idempotencyHeader("X-Some-Header") + .build() val response = retryingClient.execute( @@ -126,20 +151,20 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).isEmpty() assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) fun execute_withRetryAfterHeader(async: Boolean) { + val retryAfterDate = "Wed, 21 Oct 2015 07:28:00 GMT" stubFor( post(urlPathEqualTo("/something")) // First we fail with a retry after header given as a date .inScenario("foo") .whenScenarioStateIs(Scenario.STARTED) - .willReturn( - serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") - ) + .willReturn(serviceUnavailable().withHeader("Retry-After", retryAfterDate)) .willSetStateTo("RETRY_AFTER_DATE") ) stubFor( @@ -158,7 +183,13 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + // Fix the clock to 5 seconds before the Retry-After date so the date-based backoff is + // deterministic. + val retryAfterDateTime = + OffsetDateTime.parse(retryAfterDate, DateTimeFormatter.RFC_1123_DATE_TIME) + val clock = Clock.fixed(retryAfterDateTime.minusSeconds(5).toInstant(), ZoneOffset.UTC) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper, clock).maxRetries(2).build() val response = retryingClient.execute( @@ -186,19 +217,20 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("2")), ) + assertThat(sleeper.durations) + .containsExactly(Duration.ofSeconds(5), Duration.ofMillis(1234)) assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) fun execute_withOverwrittenRetryCountHeader(async: Boolean) { + val retryAfterDate = "Wed, 21 Oct 2015 07:28:00 GMT" stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") // first we fail with a retry after header given as a date .whenScenarioStateIs(Scenario.STARTED) - .willReturn( - serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") - ) + .willReturn(serviceUnavailable().withHeader("Retry-After", retryAfterDate)) .willSetStateTo("RETRY_AFTER_DATE") ) stubFor( @@ -208,7 +240,11 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + val retryAfterDateTime = + OffsetDateTime.parse(retryAfterDate, DateTimeFormatter.RFC_1123_DATE_TIME) + val clock = Clock.fixed(retryAfterDateTime.minusSeconds(5).toInstant(), ZoneOffset.UTC) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper, clock).maxRetries(2).build() val response = retryingClient.execute( @@ -227,6 +263,7 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("42")), ) + assertThat(sleeper.durations).containsExactly(Duration.ofSeconds(5)) assertNoResponseLeaks() } @@ -247,7 +284,8 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = retryingHttpClientBuilder().maxRetries(1).build() + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() val response = retryingClient.execute( @@ -261,6 +299,7 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(200) verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).containsExactly(Duration.ofMillis(10)) assertNoResponseLeaks() } @@ -301,21 +340,12 @@ internal class RetryingHttpClientTest { override fun close() = httpClient.close() } + val sleeper = RecordingSleeper() val retryingClient = RetryingHttpClient.builder() .httpClient(failingHttpClient) .maxRetries(2) - .sleeper( - object : Sleeper { - - override fun sleep(duration: Duration) {} - - override fun sleepAsync(duration: Duration): CompletableFuture = - CompletableFuture.completedFuture(null) - - override fun close() {} - } - ) + .sleeper(sleeper) .build() val response = @@ -339,25 +369,153 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("0")), ) + // Exponential backoff with jitter: 0.5s * jitter where jitter is in [0.75, 1.0]. + assertThat(sleeper.durations).hasSize(1) + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) assertNoResponseLeaks() } - private fun retryingHttpClientBuilder() = - RetryingHttpClient.builder() - .httpClient(httpClient) - // Use a no-op `Sleeper` to make the test fast. - .sleeper( - object : Sleeper { + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withExponentialBackoff(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(serviceUnavailable())) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(3).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) - override fun sleep(duration: Duration) {} + // All retries exhausted; the last 503 response is returned. + assertThat(response.statusCode()).isEqualTo(503) + verify(4, postRequestedFor(urlPathEqualTo("/something"))) + // Exponential backoff with jitter: backoff = min(0.5 * 2^(retries-1), 8) * jitter where + // jitter is in [0.75, 1.0]. + assertThat(sleeper.durations).hasSize(3) + // retries=1: 0.5s * [0.75, 1.0] + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) + // retries=2: 1.0s * [0.75, 1.0] + assertThat(sleeper.durations[1]).isBetween(Duration.ofMillis(750), Duration.ofMillis(1000)) + // retries=3: 2.0s * [0.75, 1.0] + assertThat(sleeper.durations[2]).isBetween(Duration.ofMillis(1500), Duration.ofMillis(2000)) + assertNoResponseLeaks() + } - override fun sleepAsync(duration: Duration): CompletableFuture = - CompletableFuture.completedFuture(null) + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withExponentialBackoffCap(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(serviceUnavailable())) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(6).build() - override fun close() {} - } + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, ) + assertThat(response.statusCode()).isEqualTo(503) + verify(7, postRequestedFor(urlPathEqualTo("/something"))) + assertThat(sleeper.durations).hasSize(6) + // retries=5: min(0.5 * 2^4, 8) = 8.0s * [0.75, 1.0] + assertThat(sleeper.durations[4]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) + // retries=6: min(0.5 * 2^5, 8) = min(16, 8) = 8.0s * [0.75, 1.0] (capped) + assertThat(sleeper.durations[5]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsPriorityOverRetryAfter(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn( + serviceUnavailable() + .withHeader("Retry-After-Ms", "50") + .withHeader("Retry-After", "2") + ) + .willSetStateTo("RETRY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs("RETRY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + // Retry-After-Ms (50ms) takes priority over Retry-After (2s). + assertThat(sleeper.durations).containsExactly(Duration.ofMillis(50)) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterUnparseable(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn(serviceUnavailable().withHeader("Retry-After", "not-a-date-or-number")) + .willSetStateTo("RETRY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs("RETRY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val sleeper = RecordingSleeper() + val retryingClient = retryingHttpClientBuilder(sleeper).maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + // Unparseable Retry-After falls through to exponential backoff. + assertThat(sleeper.durations).hasSize(1) + assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) + assertNoResponseLeaks() + } + + private fun retryingHttpClientBuilder( + sleeper: RecordingSleeper, + clock: Clock = Clock.systemUTC(), + ) = RetryingHttpClient.builder().httpClient(httpClient).sleeper(sleeper).clock(clock) + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = if (async) executeAsync(request).get() else execute(request) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListPageResponseTest.kt new file mode 100644 index 000000000..24f2cd025 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListPageResponseTest.kt @@ -0,0 +1,147 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.beneficialowners + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.increase.api.core.jsonMapper +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BeneficialOwnerListPageResponseTest { + + @Test + fun create() { + val beneficialOwnerListPageResponse = + BeneficialOwnerListPageResponse.builder() + .addData( + EntityBeneficialOwner.builder() + .id("entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7") + .companyTitle("CEO") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .individual( + EntityBeneficialOwner.Individual.builder() + .address( + EntityBeneficialOwner.Individual.Address.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2(null) + .state("NY") + .zip("10045") + .build() + ) + .dateOfBirth(LocalDate.parse("1970-01-31")) + .identification( + EntityBeneficialOwner.Individual.Identification.builder() + .method( + EntityBeneficialOwner.Individual.Identification.Method + .SOCIAL_SECURITY_NUMBER + ) + .numberLast4("1120") + .build() + ) + .name("Ian Crease") + .build() + ) + .addProng(EntityBeneficialOwner.Prong.CONTROL) + .addProng(EntityBeneficialOwner.Prong.OWNERSHIP) + .type(EntityBeneficialOwner.Type.ENTITY_BENEFICIAL_OWNER) + .build() + ) + .nextCursor("v57w5d") + .build() + + assertThat(beneficialOwnerListPageResponse.data()) + .containsExactly( + EntityBeneficialOwner.builder() + .id("entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7") + .companyTitle("CEO") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .individual( + EntityBeneficialOwner.Individual.builder() + .address( + EntityBeneficialOwner.Individual.Address.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2(null) + .state("NY") + .zip("10045") + .build() + ) + .dateOfBirth(LocalDate.parse("1970-01-31")) + .identification( + EntityBeneficialOwner.Individual.Identification.builder() + .method( + EntityBeneficialOwner.Individual.Identification.Method + .SOCIAL_SECURITY_NUMBER + ) + .numberLast4("1120") + .build() + ) + .name("Ian Crease") + .build() + ) + .addProng(EntityBeneficialOwner.Prong.CONTROL) + .addProng(EntityBeneficialOwner.Prong.OWNERSHIP) + .type(EntityBeneficialOwner.Type.ENTITY_BENEFICIAL_OWNER) + .build() + ) + assertThat(beneficialOwnerListPageResponse.nextCursor()).contains("v57w5d") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val beneficialOwnerListPageResponse = + BeneficialOwnerListPageResponse.builder() + .addData( + EntityBeneficialOwner.builder() + .id("entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7") + .companyTitle("CEO") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .individual( + EntityBeneficialOwner.Individual.builder() + .address( + EntityBeneficialOwner.Individual.Address.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2(null) + .state("NY") + .zip("10045") + .build() + ) + .dateOfBirth(LocalDate.parse("1970-01-31")) + .identification( + EntityBeneficialOwner.Individual.Identification.builder() + .method( + EntityBeneficialOwner.Individual.Identification.Method + .SOCIAL_SECURITY_NUMBER + ) + .numberLast4("1120") + .build() + ) + .name("Ian Crease") + .build() + ) + .addProng(EntityBeneficialOwner.Prong.CONTROL) + .addProng(EntityBeneficialOwner.Prong.OWNERSHIP) + .type(EntityBeneficialOwner.Type.ENTITY_BENEFICIAL_OWNER) + .build() + ) + .nextCursor("v57w5d") + .build() + + val roundtrippedBeneficialOwnerListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(beneficialOwnerListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBeneficialOwnerListPageResponse) + .isEqualTo(beneficialOwnerListPageResponse) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListParamsTest.kt new file mode 100644 index 000000000..e148eb5c0 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerListParamsTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.beneficialowners + +import com.increase.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BeneficialOwnerListParamsTest { + + @Test + fun create() { + BeneficialOwnerListParams.builder() + .entityId("entity_id") + .cursor("cursor") + .idempotencyKey("x") + .limit(1L) + .build() + } + + @Test + fun queryParams() { + val params = + BeneficialOwnerListParams.builder() + .entityId("entity_id") + .cursor("cursor") + .idempotencyKey("x") + .limit(1L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("entity_id", "entity_id") + .put("cursor", "cursor") + .put("idempotency_key", "x") + .put("limit", "1") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = BeneficialOwnerListParams.builder().entityId("entity_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("entity_id", "entity_id").build()) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerRetrieveParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerRetrieveParamsTest.kt new file mode 100644 index 000000000..5f67b9a57 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/beneficialowners/BeneficialOwnerRetrieveParamsTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.beneficialowners + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BeneficialOwnerRetrieveParamsTest { + + @Test + fun create() { + BeneficialOwnerRetrieveParams.builder() + .entityBeneficialOwnerId( + "entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7" + ) + .build() + } + + @Test + fun pathParams() { + val params = + BeneficialOwnerRetrieveParams.builder() + .entityBeneficialOwnerId( + "entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7" + ) + .build() + + assertThat(params._pathParam(0)) + .isEqualTo("entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/beneficialowners/EntityBeneficialOwnerTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/beneficialowners/EntityBeneficialOwnerTest.kt new file mode 100644 index 000000000..dcb272885 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/beneficialowners/EntityBeneficialOwnerTest.kt @@ -0,0 +1,137 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.beneficialowners + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.increase.api.core.jsonMapper +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class EntityBeneficialOwnerTest { + + @Test + fun create() { + val entityBeneficialOwner = + EntityBeneficialOwner.builder() + .id("entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7") + .companyTitle("CEO") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .individual( + EntityBeneficialOwner.Individual.builder() + .address( + EntityBeneficialOwner.Individual.Address.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2(null) + .state("NY") + .zip("10045") + .build() + ) + .dateOfBirth(LocalDate.parse("1970-01-31")) + .identification( + EntityBeneficialOwner.Individual.Identification.builder() + .method( + EntityBeneficialOwner.Individual.Identification.Method + .SOCIAL_SECURITY_NUMBER + ) + .numberLast4("1120") + .build() + ) + .name("Ian Crease") + .build() + ) + .addProng(EntityBeneficialOwner.Prong.CONTROL) + .addProng(EntityBeneficialOwner.Prong.OWNERSHIP) + .type(EntityBeneficialOwner.Type.ENTITY_BENEFICIAL_OWNER) + .build() + + assertThat(entityBeneficialOwner.id()) + .isEqualTo("entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7") + assertThat(entityBeneficialOwner.companyTitle()).contains("CEO") + assertThat(entityBeneficialOwner.createdAt()) + .isEqualTo(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + assertThat(entityBeneficialOwner.individual()) + .isEqualTo( + EntityBeneficialOwner.Individual.builder() + .address( + EntityBeneficialOwner.Individual.Address.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2(null) + .state("NY") + .zip("10045") + .build() + ) + .dateOfBirth(LocalDate.parse("1970-01-31")) + .identification( + EntityBeneficialOwner.Individual.Identification.builder() + .method( + EntityBeneficialOwner.Individual.Identification.Method + .SOCIAL_SECURITY_NUMBER + ) + .numberLast4("1120") + .build() + ) + .name("Ian Crease") + .build() + ) + assertThat(entityBeneficialOwner.prongs()) + .containsExactly( + EntityBeneficialOwner.Prong.CONTROL, + EntityBeneficialOwner.Prong.OWNERSHIP, + ) + assertThat(entityBeneficialOwner.type()) + .isEqualTo(EntityBeneficialOwner.Type.ENTITY_BENEFICIAL_OWNER) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val entityBeneficialOwner = + EntityBeneficialOwner.builder() + .id("entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7") + .companyTitle("CEO") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .individual( + EntityBeneficialOwner.Individual.builder() + .address( + EntityBeneficialOwner.Individual.Address.builder() + .city("New York") + .country("US") + .line1("33 Liberty Street") + .line2(null) + .state("NY") + .zip("10045") + .build() + ) + .dateOfBirth(LocalDate.parse("1970-01-31")) + .identification( + EntityBeneficialOwner.Individual.Identification.builder() + .method( + EntityBeneficialOwner.Individual.Identification.Method + .SOCIAL_SECURITY_NUMBER + ) + .numberLast4("1120") + .build() + ) + .name("Ian Crease") + .build() + ) + .addProng(EntityBeneficialOwner.Prong.CONTROL) + .addProng(EntityBeneficialOwner.Prong.OWNERSHIP) + .type(EntityBeneficialOwner.Type.ENTITY_BENEFICIAL_OWNER) + .build() + + val roundtrippedEntityBeneficialOwner = + jsonMapper.readValue( + jsonMapper.writeValueAsString(entityBeneficialOwner), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEntityBeneficialOwner).isEqualTo(entityBeneficialOwner) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityListPageResponseTest.kt index 2e12db2c0..73756fbc2 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityListPageResponseTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityListPageResponseTest.kt @@ -4,6 +4,7 @@ package com.increase.api.models.entities import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.increase.api.core.jsonMapper +import com.increase.api.models.beneficialowners.EntityBeneficialOwner import com.increase.api.models.supplementaldocuments.EntitySupplementalDocument import java.time.LocalDate import java.time.OffsetDateTime @@ -31,16 +32,16 @@ internal class EntityListPageResponseTest { .build() ) .addBeneficialOwner( - Entity.Corporation.BeneficialOwner.builder() + EntityBeneficialOwner.builder() .id( "entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7" ) .companyTitle("CEO") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .individual( - Entity.Corporation.BeneficialOwner.Individual.builder() + EntityBeneficialOwner.Individual.builder() .address( - Entity.Corporation.BeneficialOwner.Individual - .Address + EntityBeneficialOwner.Individual.Address .builder() .city("New York") .country("US") @@ -52,12 +53,10 @@ internal class EntityListPageResponseTest { ) .dateOfBirth(LocalDate.parse("1970-01-31")) .identification( - Entity.Corporation.BeneficialOwner.Individual - .Identification + EntityBeneficialOwner.Individual.Identification .builder() .method( - Entity.Corporation.BeneficialOwner - .Individual + EntityBeneficialOwner.Individual .Identification .Method .SOCIAL_SECURITY_NUMBER @@ -68,10 +67,9 @@ internal class EntityListPageResponseTest { .name("Ian Crease") .build() ) - .addProng(Entity.Corporation.BeneficialOwner.Prong.CONTROL) - .addProng( - Entity.Corporation.BeneficialOwner.Prong.OWNERSHIP - ) + .addProng(EntityBeneficialOwner.Prong.CONTROL) + .addProng(EntityBeneficialOwner.Prong.OWNERSHIP) + .type(EntityBeneficialOwner.Type.ENTITY_BENEFICIAL_OWNER) .build() ) .email(null) @@ -289,17 +287,16 @@ internal class EntityListPageResponseTest { .build() ) .addBeneficialOwner( - Entity.Corporation.BeneficialOwner.builder() + EntityBeneficialOwner.builder() .id( "entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7" ) .companyTitle("CEO") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .individual( - Entity.Corporation.BeneficialOwner.Individual.builder() + EntityBeneficialOwner.Individual.builder() .address( - Entity.Corporation.BeneficialOwner.Individual - .Address - .builder() + EntityBeneficialOwner.Individual.Address.builder() .city("New York") .country("US") .line1("33 Liberty Street") @@ -310,12 +307,10 @@ internal class EntityListPageResponseTest { ) .dateOfBirth(LocalDate.parse("1970-01-31")) .identification( - Entity.Corporation.BeneficialOwner.Individual - .Identification + EntityBeneficialOwner.Individual.Identification .builder() .method( - Entity.Corporation.BeneficialOwner - .Individual + EntityBeneficialOwner.Individual .Identification .Method .SOCIAL_SECURITY_NUMBER @@ -326,8 +321,9 @@ internal class EntityListPageResponseTest { .name("Ian Crease") .build() ) - .addProng(Entity.Corporation.BeneficialOwner.Prong.CONTROL) - .addProng(Entity.Corporation.BeneficialOwner.Prong.OWNERSHIP) + .addProng(EntityBeneficialOwner.Prong.CONTROL) + .addProng(EntityBeneficialOwner.Prong.OWNERSHIP) + .type(EntityBeneficialOwner.Type.ENTITY_BENEFICIAL_OWNER) .build() ) .email(null) @@ -548,16 +544,16 @@ internal class EntityListPageResponseTest { .build() ) .addBeneficialOwner( - Entity.Corporation.BeneficialOwner.builder() + EntityBeneficialOwner.builder() .id( "entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7" ) .companyTitle("CEO") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .individual( - Entity.Corporation.BeneficialOwner.Individual.builder() + EntityBeneficialOwner.Individual.builder() .address( - Entity.Corporation.BeneficialOwner.Individual - .Address + EntityBeneficialOwner.Individual.Address .builder() .city("New York") .country("US") @@ -569,12 +565,10 @@ internal class EntityListPageResponseTest { ) .dateOfBirth(LocalDate.parse("1970-01-31")) .identification( - Entity.Corporation.BeneficialOwner.Individual - .Identification + EntityBeneficialOwner.Individual.Identification .builder() .method( - Entity.Corporation.BeneficialOwner - .Individual + EntityBeneficialOwner.Individual .Identification .Method .SOCIAL_SECURITY_NUMBER @@ -585,10 +579,9 @@ internal class EntityListPageResponseTest { .name("Ian Crease") .build() ) - .addProng(Entity.Corporation.BeneficialOwner.Prong.CONTROL) - .addProng( - Entity.Corporation.BeneficialOwner.Prong.OWNERSHIP - ) + .addProng(EntityBeneficialOwner.Prong.CONTROL) + .addProng(EntityBeneficialOwner.Prong.OWNERSHIP) + .type(EntityBeneficialOwner.Type.ENTITY_BENEFICIAL_OWNER) .build() ) .email(null) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityTest.kt index 3d81c0678..f95072624 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityTest.kt @@ -4,6 +4,7 @@ package com.increase.api.models.entities import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.increase.api.core.jsonMapper +import com.increase.api.models.beneficialowners.EntityBeneficialOwner import com.increase.api.models.supplementaldocuments.EntitySupplementalDocument import java.time.LocalDate import java.time.OffsetDateTime @@ -29,14 +30,14 @@ internal class EntityTest { .build() ) .addBeneficialOwner( - Entity.Corporation.BeneficialOwner.builder() + EntityBeneficialOwner.builder() .id("entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7") .companyTitle("CEO") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .individual( - Entity.Corporation.BeneficialOwner.Individual.builder() + EntityBeneficialOwner.Individual.builder() .address( - Entity.Corporation.BeneficialOwner.Individual.Address - .builder() + EntityBeneficialOwner.Individual.Address.builder() .city("New York") .country("US") .line1("33 Liberty Street") @@ -47,12 +48,10 @@ internal class EntityTest { ) .dateOfBirth(LocalDate.parse("1970-01-31")) .identification( - Entity.Corporation.BeneficialOwner.Individual - .Identification + EntityBeneficialOwner.Individual.Identification .builder() .method( - Entity.Corporation.BeneficialOwner.Individual - .Identification + EntityBeneficialOwner.Individual.Identification .Method .SOCIAL_SECURITY_NUMBER ) @@ -62,8 +61,9 @@ internal class EntityTest { .name("Ian Crease") .build() ) - .addProng(Entity.Corporation.BeneficialOwner.Prong.CONTROL) - .addProng(Entity.Corporation.BeneficialOwner.Prong.OWNERSHIP) + .addProng(EntityBeneficialOwner.Prong.CONTROL) + .addProng(EntityBeneficialOwner.Prong.OWNERSHIP) + .type(EntityBeneficialOwner.Type.ENTITY_BENEFICIAL_OWNER) .build() ) .email(null) @@ -273,14 +273,14 @@ internal class EntityTest { .build() ) .addBeneficialOwner( - Entity.Corporation.BeneficialOwner.builder() + EntityBeneficialOwner.builder() .id("entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7") .companyTitle("CEO") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .individual( - Entity.Corporation.BeneficialOwner.Individual.builder() + EntityBeneficialOwner.Individual.builder() .address( - Entity.Corporation.BeneficialOwner.Individual.Address - .builder() + EntityBeneficialOwner.Individual.Address.builder() .city("New York") .country("US") .line1("33 Liberty Street") @@ -291,11 +291,9 @@ internal class EntityTest { ) .dateOfBirth(LocalDate.parse("1970-01-31")) .identification( - Entity.Corporation.BeneficialOwner.Individual.Identification - .builder() + EntityBeneficialOwner.Individual.Identification.builder() .method( - Entity.Corporation.BeneficialOwner.Individual - .Identification + EntityBeneficialOwner.Individual.Identification .Method .SOCIAL_SECURITY_NUMBER ) @@ -305,8 +303,9 @@ internal class EntityTest { .name("Ian Crease") .build() ) - .addProng(Entity.Corporation.BeneficialOwner.Prong.CONTROL) - .addProng(Entity.Corporation.BeneficialOwner.Prong.OWNERSHIP) + .addProng(EntityBeneficialOwner.Prong.CONTROL) + .addProng(EntityBeneficialOwner.Prong.OWNERSHIP) + .type(EntityBeneficialOwner.Type.ENTITY_BENEFICIAL_OWNER) .build() ) .email(null) @@ -527,14 +526,14 @@ internal class EntityTest { .build() ) .addBeneficialOwner( - Entity.Corporation.BeneficialOwner.builder() + EntityBeneficialOwner.builder() .id("entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7") .companyTitle("CEO") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .individual( - Entity.Corporation.BeneficialOwner.Individual.builder() + EntityBeneficialOwner.Individual.builder() .address( - Entity.Corporation.BeneficialOwner.Individual.Address - .builder() + EntityBeneficialOwner.Individual.Address.builder() .city("New York") .country("US") .line1("33 Liberty Street") @@ -545,12 +544,10 @@ internal class EntityTest { ) .dateOfBirth(LocalDate.parse("1970-01-31")) .identification( - Entity.Corporation.BeneficialOwner.Individual - .Identification + EntityBeneficialOwner.Individual.Identification .builder() .method( - Entity.Corporation.BeneficialOwner.Individual - .Identification + EntityBeneficialOwner.Individual.Identification .Method .SOCIAL_SECURITY_NUMBER ) @@ -560,8 +557,9 @@ internal class EntityTest { .name("Ian Crease") .build() ) - .addProng(Entity.Corporation.BeneficialOwner.Prong.CONTROL) - .addProng(Entity.Corporation.BeneficialOwner.Prong.OWNERSHIP) + .addProng(EntityBeneficialOwner.Prong.CONTROL) + .addProng(EntityBeneficialOwner.Prong.OWNERSHIP) + .type(EntityBeneficialOwner.Type.ENTITY_BENEFICIAL_OWNER) .build() ) .email(null) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/BeneficialOwnerServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/BeneficialOwnerServiceAsyncTest.kt new file mode 100644 index 000000000..4b0d86f6b --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/BeneficialOwnerServiceAsyncTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClientAsync +import com.increase.api.models.beneficialowners.BeneficialOwnerListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BeneficialOwnerServiceAsyncTest { + + @Test + fun retrieve() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val beneficialOwnerServiceAsync = client.beneficialOwners() + + val entityBeneficialOwnerFuture = + beneficialOwnerServiceAsync.retrieve( + "entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7" + ) + + val entityBeneficialOwner = entityBeneficialOwnerFuture.get() + entityBeneficialOwner.validate() + } + + @Test + fun list() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val beneficialOwnerServiceAsync = client.beneficialOwners() + + val pageFuture = + beneficialOwnerServiceAsync.list( + BeneficialOwnerListParams.builder().entityId("entity_id").build() + ) + + val page = pageFuture.get() + page.response().validate() + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/BeneficialOwnerServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/BeneficialOwnerServiceTest.kt new file mode 100644 index 000000000..927c56ef2 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/BeneficialOwnerServiceTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClient +import com.increase.api.models.beneficialowners.BeneficialOwnerListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BeneficialOwnerServiceTest { + + @Test + fun retrieve() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val beneficialOwnerService = client.beneficialOwners() + + val entityBeneficialOwner = + beneficialOwnerService.retrieve( + "entity_setup_beneficial_owner_submission_vgkyk7dj5eb4sfhdbkx7" + ) + + entityBeneficialOwner.validate() + } + + @Test + fun list() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val beneficialOwnerService = client.beneficialOwners() + + val page = + beneficialOwnerService.list( + BeneficialOwnerListParams.builder().entityId("entity_id").build() + ) + + page.response().validate() + } +} 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 fd5fa79c7..c6a591f77 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 @@ -83,6 +83,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.routingNumbers()).isNotNull() assertThat(client.externalAccounts()).isNotNull() assertThat(client.entities()).isNotNull() + assertThat(client.beneficialOwners()).isNotNull() assertThat(client.supplementalDocuments()).isNotNull() assertThat(client.programs()).isNotNull() assertThat(client.accountStatements()).isNotNull()