diff --git a/.release-please-manifest.json b/.release-please-manifest.json index c15669fda..e817625b2 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.440.0" + ".": "0.441.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index fd12aef62..67156bd51 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 235 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-d23465ee6dfaa64549fa617a3dd213d86a1ddbcf0d01e6595dad4dc8a72d3060.yml -openapi_spec_hash: 48b1e64041179b50d44dd4c58cb515d0 -config_hash: 463c5cf7a7f13cf7db270b287814b56c +configured_endpoints: 232 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-0bdf7012f2b877d17a7dc56e14a67bd22ffee9acdff8627800cc91f5f6487d74.yml +openapi_spec_hash: db9f6935a1a74bee62d494e30122259b +config_hash: d15ecbf4dc8a7a0ef99397d11b557444 diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e37ece1e..752d84fee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.441.0 (2026-03-03) + +Full Changelog: [v0.440.0...v0.441.0](https://github.com/Increase/increase-java/compare/v0.440.0...v0.441.0) + +### Features + +* **api:** api update ([3e746f5](https://github.com/Increase/increase-java/commit/3e746f551edabfc9b658ca937f2d1308086844c9)) + + +### Chores + +* **internal:** codegen related update ([c50789b](https://github.com/Increase/increase-java/commit/c50789b10b74f7e4e78c4e2683b7b5d7c9daedc6)) + ## 0.440.0 (2026-03-03) Full Changelog: [v0.439.0...v0.440.0](https://github.com/Increase/increase-java/compare/v0.439.0...v0.440.0) diff --git a/README.md b/README.md index 921fee9e4..9f4fb9e1f 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.440.0) -[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.440.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.440.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.441.0) +[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.441.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.441.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.440.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.441.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.440.0") +implementation("com.increase.api:increase-java:0.441.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.increase.api:increase-java:0.440.0") com.increase.api increase-java - 0.440.0 + 0.441.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 4b59aaee8..da0aff1a6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.increase.api" - version = "0.440.0" // x-release-please-version + version = "0.441.0" // x-release-please-version } subprojects { diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityConfirmParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityConfirmParams.kt deleted file mode 100644 index e1150f5d6..000000000 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityConfirmParams.kt +++ /dev/null @@ -1,432 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.increase.api.models.entities - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.increase.api.core.ExcludeMissing -import com.increase.api.core.JsonField -import com.increase.api.core.JsonMissing -import com.increase.api.core.JsonValue -import com.increase.api.core.Params -import com.increase.api.core.http.Headers -import com.increase.api.core.http.QueryParams -import com.increase.api.errors.IncreaseInvalidDataException -import java.time.OffsetDateTime -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Depending on your program, you may be required to re-confirm an Entity's details on a recurring - * basis. After making any required updates, call this endpoint to record that your user confirmed - * their details. - */ -class EntityConfirmParams -private constructor( - private val entityId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** The identifier of the Entity to confirm the details of. */ - fun entityId(): Optional = Optional.ofNullable(entityId) - - /** - * When your user confirmed the Entity's details. If not provided, the current time will be - * used. - * - * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun confirmedAt(): Optional = body.confirmedAt() - - /** - * Returns the raw JSON value of [confirmedAt]. - * - * Unlike [confirmedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _confirmedAt(): JsonField = body._confirmedAt() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** 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(): EntityConfirmParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [EntityConfirmParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EntityConfirmParams]. */ - class Builder internal constructor() { - - private var entityId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(entityConfirmParams: EntityConfirmParams) = apply { - entityId = entityConfirmParams.entityId - body = entityConfirmParams.body.toBuilder() - additionalHeaders = entityConfirmParams.additionalHeaders.toBuilder() - additionalQueryParams = entityConfirmParams.additionalQueryParams.toBuilder() - } - - /** The identifier of the Entity to confirm the details of. */ - fun entityId(entityId: String?) = apply { this.entityId = entityId } - - /** Alias for calling [Builder.entityId] with `entityId.orElse(null)`. */ - fun entityId(entityId: Optional) = entityId(entityId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [confirmedAt] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** - * When your user confirmed the Entity's details. If not provided, the current time will be - * used. - */ - fun confirmedAt(confirmedAt: OffsetDateTime) = apply { body.confirmedAt(confirmedAt) } - - /** - * Sets [Builder.confirmedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.confirmedAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun confirmedAt(confirmedAt: JsonField) = apply { - body.confirmedAt(confirmedAt) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - 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 [EntityConfirmParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): EntityConfirmParams = - EntityConfirmParams( - entityId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> entityId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val confirmedAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("confirmed_at") - @ExcludeMissing - confirmedAt: JsonField = JsonMissing.of() - ) : this(confirmedAt, mutableMapOf()) - - /** - * When your user confirmed the Entity's details. If not provided, the current time will be - * used. - * - * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun confirmedAt(): Optional = confirmedAt.getOptional("confirmed_at") - - /** - * Returns the raw JSON value of [confirmedAt]. - * - * Unlike [confirmedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("confirmed_at") - @ExcludeMissing - fun _confirmedAt(): JsonField = confirmedAt - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var confirmedAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - confirmedAt = body.confirmedAt - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** - * When your user confirmed the Entity's details. If not provided, the current time will - * be used. - */ - fun confirmedAt(confirmedAt: OffsetDateTime) = confirmedAt(JsonField.of(confirmedAt)) - - /** - * Sets [Builder.confirmedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.confirmedAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun confirmedAt(confirmedAt: JsonField) = apply { - this.confirmedAt = confirmedAt - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Body = Body(confirmedAt, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - confirmedAt() - 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 (confirmedAt.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - confirmedAt == other.confirmedAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(confirmedAt, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{confirmedAt=$confirmedAt, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EntityConfirmParams && - entityId == other.entityId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(entityId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "EntityConfirmParams{entityId=$entityId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityUpdateAddressParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityUpdateAddressParams.kt deleted file mode 100644 index 47dc690fb..000000000 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityUpdateAddressParams.kt +++ /dev/null @@ -1,764 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.increase.api.models.entities - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.increase.api.core.ExcludeMissing -import com.increase.api.core.JsonField -import com.increase.api.core.JsonMissing -import com.increase.api.core.JsonValue -import com.increase.api.core.Params -import com.increase.api.core.checkRequired -import com.increase.api.core.http.Headers -import com.increase.api.core.http.QueryParams -import com.increase.api.errors.IncreaseInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Update a Natural Person or Corporation's address */ -class EntityUpdateAddressParams -private constructor( - private val entityId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** The identifier of the Entity whose address is being updated. */ - fun entityId(): Optional = Optional.ofNullable(entityId) - - /** - * The entity's physical address. Mail receiving locations like PO Boxes and PMB's are - * disallowed. - * - * @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 = body.address() - - /** - * Returns the raw JSON value of [address]. - * - * Unlike [address], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _address(): JsonField
= body._address() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** 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 [EntityUpdateAddressParams]. - * - * The following fields are required: - * ```java - * .address() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EntityUpdateAddressParams]. */ - class Builder internal constructor() { - - private var entityId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(entityUpdateAddressParams: EntityUpdateAddressParams) = apply { - entityId = entityUpdateAddressParams.entityId - body = entityUpdateAddressParams.body.toBuilder() - additionalHeaders = entityUpdateAddressParams.additionalHeaders.toBuilder() - additionalQueryParams = entityUpdateAddressParams.additionalQueryParams.toBuilder() - } - - /** The identifier of the Entity whose address is being updated. */ - fun entityId(entityId: String?) = apply { this.entityId = entityId } - - /** Alias for calling [Builder.entityId] with `entityId.orElse(null)`. */ - fun entityId(entityId: Optional) = entityId(entityId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [address] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** - * The entity's physical address. Mail receiving locations like PO Boxes and PMB's are - * disallowed. - */ - fun address(address: Address) = apply { body.address(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 { body.address(address) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - 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 [EntityUpdateAddressParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .address() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): EntityUpdateAddressParams = - EntityUpdateAddressParams( - entityId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> entityId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val address: JsonField
, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("address") @ExcludeMissing address: JsonField
= JsonMissing.of() - ) : this(address, mutableMapOf()) - - /** - * The entity's physical address. Mail receiving locations like PO Boxes and PMB's are - * disallowed. - * - * @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") - - /** - * 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 - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .address() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var address: JsonField
? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - address = body.address - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** - * The entity's physical address. Mail receiving locations like PO Boxes and PMB's are - * disallowed. - */ - 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 } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .address() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("address", address), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - address().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 = (address.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - address == other.address && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(address, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{address=$address, additionalProperties=$additionalProperties}" - } - - /** - * The entity's physical address. Mail receiving locations like PO Boxes and PMB's are - * disallowed. - */ - class Address - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val city: JsonField, - private val line1: JsonField, - private val state: JsonField, - private val zip: JsonField, - private val line2: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("city") @ExcludeMissing city: JsonField = JsonMissing.of(), - @JsonProperty("line1") @ExcludeMissing line1: JsonField = JsonMissing.of(), - @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), - @JsonProperty("zip") @ExcludeMissing zip: JsonField = JsonMissing.of(), - @JsonProperty("line2") @ExcludeMissing line2: JsonField = JsonMissing.of(), - ) : this(city, line1, state, zip, line2, mutableMapOf()) - - /** - * The city 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 city(): String = city.getRequired("city") - - /** - * The first line of the address. This is usually the street number and street. - * - * @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 two-letter United States Postal Service (USPS) abbreviation for the state 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 state(): String = state.getRequired("state") - - /** - * The ZIP code 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 zip(): String = zip.getRequired("zip") - - /** - * The second line of the address. This might be the floor or room number. - * - * @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") - - /** - * 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 [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 [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 - - /** - * 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 - - @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() - * .line1() - * .state() - * .zip() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Address]. */ - class Builder internal constructor() { - - private var city: JsonField? = null - private var line1: JsonField? = null - private var state: JsonField? = null - private var zip: JsonField? = null - private var line2: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(address: Address) = apply { - city = address.city - line1 = address.line1 - state = address.state - zip = address.zip - line2 = address.line2 - additionalProperties = address.additionalProperties.toMutableMap() - } - - /** The city of the address. */ - fun city(city: String) = city(JsonField.of(city)) - - /** - * 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 first line of the address. This is usually the street number and street. */ - 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 two-letter United States Postal Service (USPS) abbreviation for the state of the - * address. - */ - fun state(state: String) = state(JsonField.of(state)) - - /** - * 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 code of the address. */ - fun zip(zip: String) = zip(JsonField.of(zip)) - - /** - * 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 } - - /** The second line of the address. This might be the floor or room number. */ - fun line2(line2: String) = line2(JsonField.of(line2)) - - /** - * 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 } - - 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() - * .line1() - * .state() - * .zip() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Address = - Address( - checkRequired("city", city), - checkRequired("line1", line1), - checkRequired("state", state), - checkRequired("zip", zip), - line2, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Address = apply { - if (validated) { - return@apply - } - - city() - line1() - state() - zip() - line2() - 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 (line1.asKnown().isPresent) 1 else 0) + - (if (state.asKnown().isPresent) 1 else 0) + - (if (zip.asKnown().isPresent) 1 else 0) + - (if (line2.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Address && - city == other.city && - line1 == other.line1 && - state == other.state && - zip == other.zip && - line2 == other.line2 && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(city, line1, state, zip, line2, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Address{city=$city, line1=$line1, state=$state, zip=$zip, line2=$line2, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EntityUpdateAddressParams && - entityId == other.entityId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(entityId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "EntityUpdateAddressParams{entityId=$entityId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityUpdateIndustryCodeParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityUpdateIndustryCodeParams.kt deleted file mode 100644 index f46a2ed6f..000000000 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityUpdateIndustryCodeParams.kt +++ /dev/null @@ -1,474 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.increase.api.models.entities - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.increase.api.core.ExcludeMissing -import com.increase.api.core.JsonField -import com.increase.api.core.JsonMissing -import com.increase.api.core.JsonValue -import com.increase.api.core.Params -import com.increase.api.core.checkRequired -import com.increase.api.core.http.Headers -import com.increase.api.core.http.QueryParams -import com.increase.api.errors.IncreaseInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Update the industry code for a corporate Entity */ -class EntityUpdateIndustryCodeParams -private constructor( - private val entityId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * The identifier of the Entity to update. This endpoint only accepts `corporation` entities. - */ - fun entityId(): Optional = Optional.ofNullable(entityId) - - /** - * The North American Industry Classification System (NAICS) code for the corporation's primary - * line of business. This is a number, like `5132` for `Software Publishers`. A full list of - * classification codes is available - * [here](https://increase.com/documentation/data-dictionary#north-american-industry-classification-system-codes). - * - * @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 industryCode(): String = body.industryCode() - - /** - * Returns the raw JSON value of [industryCode]. - * - * Unlike [industryCode], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _industryCode(): JsonField = body._industryCode() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** 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 - * [EntityUpdateIndustryCodeParams]. - * - * The following fields are required: - * ```java - * .industryCode() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EntityUpdateIndustryCodeParams]. */ - class Builder internal constructor() { - - private var entityId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(entityUpdateIndustryCodeParams: EntityUpdateIndustryCodeParams) = apply { - entityId = entityUpdateIndustryCodeParams.entityId - body = entityUpdateIndustryCodeParams.body.toBuilder() - additionalHeaders = entityUpdateIndustryCodeParams.additionalHeaders.toBuilder() - additionalQueryParams = entityUpdateIndustryCodeParams.additionalQueryParams.toBuilder() - } - - /** - * The identifier of the Entity to update. This endpoint only accepts `corporation` - * entities. - */ - fun entityId(entityId: String?) = apply { this.entityId = entityId } - - /** Alias for calling [Builder.entityId] with `entityId.orElse(null)`. */ - fun entityId(entityId: Optional) = entityId(entityId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [industryCode] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** - * The North American Industry Classification System (NAICS) code for the corporation's - * primary line of business. This is a number, like `5132` for `Software Publishers`. A full - * list of classification codes is available - * [here](https://increase.com/documentation/data-dictionary#north-american-industry-classification-system-codes). - */ - fun industryCode(industryCode: String) = apply { body.industryCode(industryCode) } - - /** - * Sets [Builder.industryCode] to an arbitrary JSON value. - * - * You should usually call [Builder.industryCode] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun industryCode(industryCode: JsonField) = apply { - body.industryCode(industryCode) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - 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 [EntityUpdateIndustryCodeParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .industryCode() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): EntityUpdateIndustryCodeParams = - EntityUpdateIndustryCodeParams( - entityId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> entityId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val industryCode: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("industry_code") - @ExcludeMissing - industryCode: JsonField = JsonMissing.of() - ) : this(industryCode, mutableMapOf()) - - /** - * The North American Industry Classification System (NAICS) code for the corporation's - * primary line of business. This is a number, like `5132` for `Software Publishers`. A full - * list of classification codes is available - * [here](https://increase.com/documentation/data-dictionary#north-american-industry-classification-system-codes). - * - * @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 industryCode(): String = industryCode.getRequired("industry_code") - - /** - * Returns the raw JSON value of [industryCode]. - * - * Unlike [industryCode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("industry_code") - @ExcludeMissing - fun _industryCode(): JsonField = industryCode - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .industryCode() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var industryCode: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - industryCode = body.industryCode - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** - * The North American Industry Classification System (NAICS) code for the corporation's - * primary line of business. This is a number, like `5132` for `Software Publishers`. A - * full list of classification codes is available - * [here](https://increase.com/documentation/data-dictionary#north-american-industry-classification-system-codes). - */ - fun industryCode(industryCode: String) = industryCode(JsonField.of(industryCode)) - - /** - * Sets [Builder.industryCode] to an arbitrary JSON value. - * - * You should usually call [Builder.industryCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun industryCode(industryCode: JsonField) = apply { - this.industryCode = industryCode - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .industryCode() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("industryCode", industryCode), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - industryCode() - 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 (industryCode.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - industryCode == other.industryCode && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(industryCode, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{industryCode=$industryCode, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EntityUpdateIndustryCodeParams && - entityId == other.entityId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(entityId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "EntityUpdateIndustryCodeParams{entityId=$entityId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/EntityServiceAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/EntityServiceAsync.kt index 8c250e1c0..7663b656e 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/async/EntityServiceAsync.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/EntityServiceAsync.kt @@ -8,15 +8,12 @@ import com.increase.api.core.http.HttpResponseFor import com.increase.api.models.entities.Entity import com.increase.api.models.entities.EntityArchiveBeneficialOwnerParams import com.increase.api.models.entities.EntityArchiveParams -import com.increase.api.models.entities.EntityConfirmParams import com.increase.api.models.entities.EntityCreateBeneficialOwnerParams import com.increase.api.models.entities.EntityCreateParams import com.increase.api.models.entities.EntityListPageAsync import com.increase.api.models.entities.EntityListParams import com.increase.api.models.entities.EntityRetrieveParams -import com.increase.api.models.entities.EntityUpdateAddressParams import com.increase.api.models.entities.EntityUpdateBeneficialOwnerAddressParams -import com.increase.api.models.entities.EntityUpdateIndustryCodeParams import com.increase.api.models.entities.EntityUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -184,42 +181,6 @@ interface EntityServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** - * Depending on your program, you may be required to re-confirm an Entity's details on a - * recurring basis. After making any required updates, call this endpoint to record that your - * user confirmed their details. - */ - fun confirm(entityId: String): CompletableFuture = - confirm(entityId, EntityConfirmParams.none()) - - /** @see confirm */ - fun confirm( - entityId: String, - params: EntityConfirmParams = EntityConfirmParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - confirm(params.toBuilder().entityId(entityId).build(), requestOptions) - - /** @see confirm */ - fun confirm( - entityId: String, - params: EntityConfirmParams = EntityConfirmParams.none(), - ): CompletableFuture = confirm(entityId, params, RequestOptions.none()) - - /** @see confirm */ - fun confirm( - params: EntityConfirmParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see confirm */ - fun confirm(params: EntityConfirmParams): CompletableFuture = - confirm(params, RequestOptions.none()) - - /** @see confirm */ - fun confirm(entityId: String, requestOptions: RequestOptions): CompletableFuture = - confirm(entityId, EntityConfirmParams.none(), requestOptions) - /** Create a beneficial owner for a corporate Entity */ fun createBeneficialOwner( entityId: String, @@ -245,30 +206,6 @@ interface EntityServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** Update a Natural Person or Corporation's address */ - fun updateAddress( - entityId: String, - params: EntityUpdateAddressParams, - ): CompletableFuture = updateAddress(entityId, params, RequestOptions.none()) - - /** @see updateAddress */ - fun updateAddress( - entityId: String, - params: EntityUpdateAddressParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - updateAddress(params.toBuilder().entityId(entityId).build(), requestOptions) - - /** @see updateAddress */ - fun updateAddress(params: EntityUpdateAddressParams): CompletableFuture = - updateAddress(params, RequestOptions.none()) - - /** @see updateAddress */ - fun updateAddress( - params: EntityUpdateAddressParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - /** Update the address for a beneficial owner belonging to a corporate Entity */ fun updateBeneficialOwnerAddress( entityId: String, @@ -295,30 +232,6 @@ interface EntityServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** Update the industry code for a corporate Entity */ - fun updateIndustryCode( - entityId: String, - params: EntityUpdateIndustryCodeParams, - ): CompletableFuture = updateIndustryCode(entityId, params, RequestOptions.none()) - - /** @see updateIndustryCode */ - fun updateIndustryCode( - entityId: String, - params: EntityUpdateIndustryCodeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - updateIndustryCode(params.toBuilder().entityId(entityId).build(), requestOptions) - - /** @see updateIndustryCode */ - fun updateIndustryCode(params: EntityUpdateIndustryCodeParams): CompletableFuture = - updateIndustryCode(params, RequestOptions.none()) - - /** @see updateIndustryCode */ - fun updateIndustryCode( - params: EntityUpdateIndustryCodeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - /** * A view of [EntityServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -518,45 +431,6 @@ interface EntityServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `post /entities/{entity_id}/confirm`, but is otherwise - * the same as [EntityServiceAsync.confirm]. - */ - fun confirm(entityId: String): CompletableFuture> = - confirm(entityId, EntityConfirmParams.none()) - - /** @see confirm */ - fun confirm( - entityId: String, - params: EntityConfirmParams = EntityConfirmParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - confirm(params.toBuilder().entityId(entityId).build(), requestOptions) - - /** @see confirm */ - fun confirm( - entityId: String, - params: EntityConfirmParams = EntityConfirmParams.none(), - ): CompletableFuture> = - confirm(entityId, params, RequestOptions.none()) - - /** @see confirm */ - fun confirm( - params: EntityConfirmParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see confirm */ - fun confirm(params: EntityConfirmParams): CompletableFuture> = - confirm(params, RequestOptions.none()) - - /** @see confirm */ - fun confirm( - entityId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - confirm(entityId, EntityConfirmParams.none(), requestOptions) - /** * Returns a raw HTTP response for `post /entities/{entity_id}/create_beneficial_owner`, but * is otherwise the same as [EntityServiceAsync.createBeneficialOwner]. @@ -587,35 +461,6 @@ interface EntityServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** - * Returns a raw HTTP response for `post /entities/{entity_id}/update_address`, but is - * otherwise the same as [EntityServiceAsync.updateAddress]. - */ - fun updateAddress( - entityId: String, - params: EntityUpdateAddressParams, - ): CompletableFuture> = - updateAddress(entityId, params, RequestOptions.none()) - - /** @see updateAddress */ - fun updateAddress( - entityId: String, - params: EntityUpdateAddressParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - updateAddress(params.toBuilder().entityId(entityId).build(), requestOptions) - - /** @see updateAddress */ - fun updateAddress( - params: EntityUpdateAddressParams - ): CompletableFuture> = updateAddress(params, RequestOptions.none()) - - /** @see updateAddress */ - fun updateAddress( - params: EntityUpdateAddressParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - /** * Returns a raw HTTP response for `post * /entities/{entity_id}/update_beneficial_owner_address`, but is otherwise the same as @@ -649,35 +494,5 @@ interface EntityServiceAsync { params: EntityUpdateBeneficialOwnerAddressParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - - /** - * Returns a raw HTTP response for `post /entities/{entity_id}/update_industry_code`, but is - * otherwise the same as [EntityServiceAsync.updateIndustryCode]. - */ - fun updateIndustryCode( - entityId: String, - params: EntityUpdateIndustryCodeParams, - ): CompletableFuture> = - updateIndustryCode(entityId, params, RequestOptions.none()) - - /** @see updateIndustryCode */ - fun updateIndustryCode( - entityId: String, - params: EntityUpdateIndustryCodeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - updateIndustryCode(params.toBuilder().entityId(entityId).build(), requestOptions) - - /** @see updateIndustryCode */ - fun updateIndustryCode( - params: EntityUpdateIndustryCodeParams - ): CompletableFuture> = - updateIndustryCode(params, RequestOptions.none()) - - /** @see updateIndustryCode */ - fun updateIndustryCode( - params: EntityUpdateIndustryCodeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> } } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/EntityServiceAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/EntityServiceAsyncImpl.kt index 3f0ad0bdf..19666c2dd 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/async/EntityServiceAsyncImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/EntityServiceAsyncImpl.kt @@ -19,16 +19,13 @@ import com.increase.api.core.prepareAsync import com.increase.api.models.entities.Entity import com.increase.api.models.entities.EntityArchiveBeneficialOwnerParams import com.increase.api.models.entities.EntityArchiveParams -import com.increase.api.models.entities.EntityConfirmParams import com.increase.api.models.entities.EntityCreateBeneficialOwnerParams import com.increase.api.models.entities.EntityCreateParams import com.increase.api.models.entities.EntityListPageAsync import com.increase.api.models.entities.EntityListPageResponse import com.increase.api.models.entities.EntityListParams import com.increase.api.models.entities.EntityRetrieveParams -import com.increase.api.models.entities.EntityUpdateAddressParams import com.increase.api.models.entities.EntityUpdateBeneficialOwnerAddressParams -import com.increase.api.models.entities.EntityUpdateIndustryCodeParams import com.increase.api.models.entities.EntityUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -88,13 +85,6 @@ class EntityServiceAsyncImpl internal constructor(private val clientOptions: Cli // post /entities/{entity_id}/archive_beneficial_owner withRawResponse().archiveBeneficialOwner(params, requestOptions).thenApply { it.parse() } - override fun confirm( - params: EntityConfirmParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /entities/{entity_id}/confirm - withRawResponse().confirm(params, requestOptions).thenApply { it.parse() } - override fun createBeneficialOwner( params: EntityCreateBeneficialOwnerParams, requestOptions: RequestOptions, @@ -102,13 +92,6 @@ class EntityServiceAsyncImpl internal constructor(private val clientOptions: Cli // post /entities/{entity_id}/create_beneficial_owner withRawResponse().createBeneficialOwner(params, requestOptions).thenApply { it.parse() } - override fun updateAddress( - params: EntityUpdateAddressParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /entities/{entity_id}/update_address - withRawResponse().updateAddress(params, requestOptions).thenApply { it.parse() } - override fun updateBeneficialOwnerAddress( params: EntityUpdateBeneficialOwnerAddressParams, requestOptions: RequestOptions, @@ -118,13 +101,6 @@ class EntityServiceAsyncImpl internal constructor(private val clientOptions: Cli it.parse() } - override fun updateIndustryCode( - params: EntityUpdateIndustryCodeParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /entities/{entity_id}/update_industry_code - withRawResponse().updateIndustryCode(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EntityServiceAsync.WithRawResponse { @@ -338,39 +314,6 @@ class EntityServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val confirmHandler: Handler = jsonHandler(clientOptions.jsonMapper) - - override fun confirm( - params: EntityConfirmParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("entityId", params.entityId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("entities", params._pathParam(0), "confirm") - .body(json(clientOptions.jsonMapper, params._body())) - .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 { confirmHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - private val createBeneficialOwnerHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -405,40 +348,6 @@ class EntityServiceAsyncImpl internal constructor(private val clientOptions: Cli } } - private val updateAddressHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun updateAddress( - params: EntityUpdateAddressParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("entityId", params.entityId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("entities", params._pathParam(0), "update_address") - .body(json(clientOptions.jsonMapper, params._body())) - .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 { updateAddressHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - private val updateBeneficialOwnerAddressHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -476,39 +385,5 @@ class EntityServiceAsyncImpl internal constructor(private val clientOptions: Cli } } } - - private val updateIndustryCodeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun updateIndustryCode( - params: EntityUpdateIndustryCodeParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("entityId", params.entityId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("entities", params._pathParam(0), "update_industry_code") - .body(json(clientOptions.jsonMapper, params._body())) - .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 { updateIndustryCodeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } } } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/EntityService.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/EntityService.kt index 30a409ceb..79cdb087e 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/EntityService.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/EntityService.kt @@ -9,15 +9,12 @@ import com.increase.api.core.http.HttpResponseFor import com.increase.api.models.entities.Entity import com.increase.api.models.entities.EntityArchiveBeneficialOwnerParams import com.increase.api.models.entities.EntityArchiveParams -import com.increase.api.models.entities.EntityConfirmParams import com.increase.api.models.entities.EntityCreateBeneficialOwnerParams import com.increase.api.models.entities.EntityCreateParams import com.increase.api.models.entities.EntityListPage import com.increase.api.models.entities.EntityListParams import com.increase.api.models.entities.EntityRetrieveParams -import com.increase.api.models.entities.EntityUpdateAddressParams import com.increase.api.models.entities.EntityUpdateBeneficialOwnerAddressParams -import com.increase.api.models.entities.EntityUpdateIndustryCodeParams import com.increase.api.models.entities.EntityUpdateParams import java.util.function.Consumer @@ -170,39 +167,6 @@ interface EntityService { requestOptions: RequestOptions = RequestOptions.none(), ): Entity - /** - * Depending on your program, you may be required to re-confirm an Entity's details on a - * recurring basis. After making any required updates, call this endpoint to record that your - * user confirmed their details. - */ - fun confirm(entityId: String): Entity = confirm(entityId, EntityConfirmParams.none()) - - /** @see confirm */ - fun confirm( - entityId: String, - params: EntityConfirmParams = EntityConfirmParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): Entity = confirm(params.toBuilder().entityId(entityId).build(), requestOptions) - - /** @see confirm */ - fun confirm( - entityId: String, - params: EntityConfirmParams = EntityConfirmParams.none(), - ): Entity = confirm(entityId, params, RequestOptions.none()) - - /** @see confirm */ - fun confirm( - params: EntityConfirmParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Entity - - /** @see confirm */ - fun confirm(params: EntityConfirmParams): Entity = confirm(params, RequestOptions.none()) - - /** @see confirm */ - fun confirm(entityId: String, requestOptions: RequestOptions): Entity = - confirm(entityId, EntityConfirmParams.none(), requestOptions) - /** Create a beneficial owner for a corporate Entity */ fun createBeneficialOwner(entityId: String, params: EntityCreateBeneficialOwnerParams): Entity = createBeneficialOwner(entityId, params, RequestOptions.none()) @@ -224,27 +188,6 @@ interface EntityService { requestOptions: RequestOptions = RequestOptions.none(), ): Entity - /** Update a Natural Person or Corporation's address */ - fun updateAddress(entityId: String, params: EntityUpdateAddressParams): Entity = - updateAddress(entityId, params, RequestOptions.none()) - - /** @see updateAddress */ - fun updateAddress( - entityId: String, - params: EntityUpdateAddressParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Entity = updateAddress(params.toBuilder().entityId(entityId).build(), requestOptions) - - /** @see updateAddress */ - fun updateAddress(params: EntityUpdateAddressParams): Entity = - updateAddress(params, RequestOptions.none()) - - /** @see updateAddress */ - fun updateAddress( - params: EntityUpdateAddressParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Entity - /** Update the address for a beneficial owner belonging to a corporate Entity */ fun updateBeneficialOwnerAddress( entityId: String, @@ -269,27 +212,6 @@ interface EntityService { requestOptions: RequestOptions = RequestOptions.none(), ): Entity - /** Update the industry code for a corporate Entity */ - fun updateIndustryCode(entityId: String, params: EntityUpdateIndustryCodeParams): Entity = - updateIndustryCode(entityId, params, RequestOptions.none()) - - /** @see updateIndustryCode */ - fun updateIndustryCode( - entityId: String, - params: EntityUpdateIndustryCodeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Entity = updateIndustryCode(params.toBuilder().entityId(entityId).build(), requestOptions) - - /** @see updateIndustryCode */ - fun updateIndustryCode(params: EntityUpdateIndustryCodeParams): Entity = - updateIndustryCode(params, RequestOptions.none()) - - /** @see updateIndustryCode */ - fun updateIndustryCode( - params: EntityUpdateIndustryCodeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Entity - /** A view of [EntityService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -494,47 +416,6 @@ interface EntityService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `post /entities/{entity_id}/confirm`, but is otherwise - * the same as [EntityService.confirm]. - */ - @MustBeClosed - fun confirm(entityId: String): HttpResponseFor = - confirm(entityId, EntityConfirmParams.none()) - - /** @see confirm */ - @MustBeClosed - fun confirm( - entityId: String, - params: EntityConfirmParams = EntityConfirmParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - confirm(params.toBuilder().entityId(entityId).build(), requestOptions) - - /** @see confirm */ - @MustBeClosed - fun confirm( - entityId: String, - params: EntityConfirmParams = EntityConfirmParams.none(), - ): HttpResponseFor = confirm(entityId, params, RequestOptions.none()) - - /** @see confirm */ - @MustBeClosed - fun confirm( - params: EntityConfirmParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see confirm */ - @MustBeClosed - fun confirm(params: EntityConfirmParams): HttpResponseFor = - confirm(params, RequestOptions.none()) - - /** @see confirm */ - @MustBeClosed - fun confirm(entityId: String, requestOptions: RequestOptions): HttpResponseFor = - confirm(entityId, EntityConfirmParams.none(), requestOptions) - /** * Returns a raw HTTP response for `post /entities/{entity_id}/create_beneficial_owner`, but * is otherwise the same as [EntityService.createBeneficialOwner]. @@ -567,37 +448,6 @@ interface EntityService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** - * Returns a raw HTTP response for `post /entities/{entity_id}/update_address`, but is - * otherwise the same as [EntityService.updateAddress]. - */ - @MustBeClosed - fun updateAddress( - entityId: String, - params: EntityUpdateAddressParams, - ): HttpResponseFor = updateAddress(entityId, params, RequestOptions.none()) - - /** @see updateAddress */ - @MustBeClosed - fun updateAddress( - entityId: String, - params: EntityUpdateAddressParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - updateAddress(params.toBuilder().entityId(entityId).build(), requestOptions) - - /** @see updateAddress */ - @MustBeClosed - fun updateAddress(params: EntityUpdateAddressParams): HttpResponseFor = - updateAddress(params, RequestOptions.none()) - - /** @see updateAddress */ - @MustBeClosed - fun updateAddress( - params: EntityUpdateAddressParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - /** * Returns a raw HTTP response for `post * /entities/{entity_id}/update_beneficial_owner_address`, but is otherwise the same as @@ -634,36 +484,5 @@ interface EntityService { params: EntityUpdateBeneficialOwnerAddressParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - - /** - * Returns a raw HTTP response for `post /entities/{entity_id}/update_industry_code`, but is - * otherwise the same as [EntityService.updateIndustryCode]. - */ - @MustBeClosed - fun updateIndustryCode( - entityId: String, - params: EntityUpdateIndustryCodeParams, - ): HttpResponseFor = updateIndustryCode(entityId, params, RequestOptions.none()) - - /** @see updateIndustryCode */ - @MustBeClosed - fun updateIndustryCode( - entityId: String, - params: EntityUpdateIndustryCodeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - updateIndustryCode(params.toBuilder().entityId(entityId).build(), requestOptions) - - /** @see updateIndustryCode */ - @MustBeClosed - fun updateIndustryCode(params: EntityUpdateIndustryCodeParams): HttpResponseFor = - updateIndustryCode(params, RequestOptions.none()) - - /** @see updateIndustryCode */ - @MustBeClosed - fun updateIndustryCode( - params: EntityUpdateIndustryCodeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor } } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/EntityServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/EntityServiceImpl.kt index efb424b7f..f6986074e 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/EntityServiceImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/EntityServiceImpl.kt @@ -19,16 +19,13 @@ import com.increase.api.core.prepare import com.increase.api.models.entities.Entity import com.increase.api.models.entities.EntityArchiveBeneficialOwnerParams import com.increase.api.models.entities.EntityArchiveParams -import com.increase.api.models.entities.EntityConfirmParams import com.increase.api.models.entities.EntityCreateBeneficialOwnerParams import com.increase.api.models.entities.EntityCreateParams import com.increase.api.models.entities.EntityListPage import com.increase.api.models.entities.EntityListPageResponse import com.increase.api.models.entities.EntityListParams import com.increase.api.models.entities.EntityRetrieveParams -import com.increase.api.models.entities.EntityUpdateAddressParams import com.increase.api.models.entities.EntityUpdateBeneficialOwnerAddressParams -import com.increase.api.models.entities.EntityUpdateIndustryCodeParams import com.increase.api.models.entities.EntityUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -72,10 +69,6 @@ class EntityServiceImpl internal constructor(private val clientOptions: ClientOp // post /entities/{entity_id}/archive_beneficial_owner withRawResponse().archiveBeneficialOwner(params, requestOptions).parse() - override fun confirm(params: EntityConfirmParams, requestOptions: RequestOptions): Entity = - // post /entities/{entity_id}/confirm - withRawResponse().confirm(params, requestOptions).parse() - override fun createBeneficialOwner( params: EntityCreateBeneficialOwnerParams, requestOptions: RequestOptions, @@ -83,13 +76,6 @@ class EntityServiceImpl internal constructor(private val clientOptions: ClientOp // post /entities/{entity_id}/create_beneficial_owner withRawResponse().createBeneficialOwner(params, requestOptions).parse() - override fun updateAddress( - params: EntityUpdateAddressParams, - requestOptions: RequestOptions, - ): Entity = - // post /entities/{entity_id}/update_address - withRawResponse().updateAddress(params, requestOptions).parse() - override fun updateBeneficialOwnerAddress( params: EntityUpdateBeneficialOwnerAddressParams, requestOptions: RequestOptions, @@ -97,13 +83,6 @@ class EntityServiceImpl internal constructor(private val clientOptions: ClientOp // post /entities/{entity_id}/update_beneficial_owner_address withRawResponse().updateBeneficialOwnerAddress(params, requestOptions).parse() - override fun updateIndustryCode( - params: EntityUpdateIndustryCodeParams, - requestOptions: RequestOptions, - ): Entity = - // post /entities/{entity_id}/update_industry_code - withRawResponse().updateIndustryCode(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : EntityService.WithRawResponse { @@ -298,36 +277,6 @@ class EntityServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val confirmHandler: Handler = jsonHandler(clientOptions.jsonMapper) - - override fun confirm( - params: EntityConfirmParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("entityId", params.entityId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("entities", params._pathParam(0), "confirm") - .body(json(clientOptions.jsonMapper, params._body())) - .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 { confirmHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - private val createBeneficialOwnerHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -359,37 +308,6 @@ class EntityServiceImpl internal constructor(private val clientOptions: ClientOp } } - private val updateAddressHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun updateAddress( - params: EntityUpdateAddressParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("entityId", params.entityId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("entities", params._pathParam(0), "update_address") - .body(json(clientOptions.jsonMapper, params._body())) - .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 { updateAddressHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - private val updateBeneficialOwnerAddressHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -424,36 +342,5 @@ class EntityServiceImpl internal constructor(private val clientOptions: ClientOp } } } - - private val updateIndustryCodeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun updateIndustryCode( - params: EntityUpdateIndustryCodeParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("entityId", params.entityId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("entities", params._pathParam(0), "update_industry_code") - .body(json(clientOptions.jsonMapper, params._body())) - .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 { updateIndustryCodeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } } } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/EventServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/EventServiceImpl.kt index 67b8ae9a7..60f8eb37f 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/EventServiceImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/EventServiceImpl.kt @@ -67,6 +67,7 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt unwrapParams.secret().getOrNull() ?: clientOptions.webhookSecret().getOrNull(), ) + val headersMap = headers.names().associateWith { name -> headers.values(name) }.toMap() diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityConfirmParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityConfirmParamsTest.kt deleted file mode 100644 index 782e79a13..000000000 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityConfirmParamsTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.increase.api.models.entities - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class EntityConfirmParamsTest { - - @Test - fun create() { - EntityConfirmParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .confirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - } - - @Test - fun pathParams() { - val params = EntityConfirmParams.builder().entityId("entity_n8y8tnk2p9339ti393yi").build() - - assertThat(params._pathParam(0)).isEqualTo("entity_n8y8tnk2p9339ti393yi") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - EntityConfirmParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .confirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - - val body = params._body() - - assertThat(body.confirmedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = EntityConfirmParams.builder().entityId("entity_n8y8tnk2p9339ti393yi").build() - - val body = params._body() - } -} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityUpdateAddressParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityUpdateAddressParamsTest.kt deleted file mode 100644 index e41186824..000000000 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityUpdateAddressParamsTest.kt +++ /dev/null @@ -1,103 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.increase.api.models.entities - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class EntityUpdateAddressParamsTest { - - @Test - fun create() { - EntityUpdateAddressParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .address( - EntityUpdateAddressParams.Address.builder() - .city("New York") - .line1("33 Liberty Street") - .state("NY") - .zip("10045") - .line2("Unit 2") - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - EntityUpdateAddressParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .address( - EntityUpdateAddressParams.Address.builder() - .city("New York") - .line1("33 Liberty Street") - .state("NY") - .zip("10045") - .build() - ) - .build() - - assertThat(params._pathParam(0)).isEqualTo("entity_n8y8tnk2p9339ti393yi") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - EntityUpdateAddressParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .address( - EntityUpdateAddressParams.Address.builder() - .city("New York") - .line1("33 Liberty Street") - .state("NY") - .zip("10045") - .line2("Unit 2") - .build() - ) - .build() - - val body = params._body() - - assertThat(body.address()) - .isEqualTo( - EntityUpdateAddressParams.Address.builder() - .city("New York") - .line1("33 Liberty Street") - .state("NY") - .zip("10045") - .line2("Unit 2") - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - EntityUpdateAddressParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .address( - EntityUpdateAddressParams.Address.builder() - .city("New York") - .line1("33 Liberty Street") - .state("NY") - .zip("10045") - .build() - ) - .build() - - val body = params._body() - - assertThat(body.address()) - .isEqualTo( - EntityUpdateAddressParams.Address.builder() - .city("New York") - .line1("33 Liberty Street") - .state("NY") - .zip("10045") - .build() - ) - } -} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityUpdateIndustryCodeParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityUpdateIndustryCodeParamsTest.kt deleted file mode 100644 index e0ac1ec8b..000000000 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityUpdateIndustryCodeParamsTest.kt +++ /dev/null @@ -1,43 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.increase.api.models.entities - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class EntityUpdateIndustryCodeParamsTest { - - @Test - fun create() { - EntityUpdateIndustryCodeParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .industryCode("5132") - .build() - } - - @Test - fun pathParams() { - val params = - EntityUpdateIndustryCodeParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .industryCode("5132") - .build() - - assertThat(params._pathParam(0)).isEqualTo("entity_n8y8tnk2p9339ti393yi") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - EntityUpdateIndustryCodeParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .industryCode("5132") - .build() - - val body = params._body() - - assertThat(body.industryCode()).isEqualTo("5132") - } -} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/EntityServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/EntityServiceAsyncTest.kt index 61cba1508..ef85dfb2a 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/async/EntityServiceAsyncTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/EntityServiceAsyncTest.kt @@ -5,12 +5,9 @@ package com.increase.api.services.async import com.increase.api.TestServerExtension import com.increase.api.client.okhttp.IncreaseOkHttpClientAsync import com.increase.api.models.entities.EntityArchiveBeneficialOwnerParams -import com.increase.api.models.entities.EntityConfirmParams import com.increase.api.models.entities.EntityCreateBeneficialOwnerParams import com.increase.api.models.entities.EntityCreateParams -import com.increase.api.models.entities.EntityUpdateAddressParams import com.increase.api.models.entities.EntityUpdateBeneficialOwnerAddressParams -import com.increase.api.models.entities.EntityUpdateIndustryCodeParams import com.increase.api.models.entities.EntityUpdateParams import java.time.LocalDate import java.time.OffsetDateTime @@ -624,27 +621,6 @@ internal class EntityServiceAsyncTest { entity.validate() } - @Test - fun confirm() { - val client = - IncreaseOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val entityServiceAsync = client.entities() - - val entityFuture = - entityServiceAsync.confirm( - EntityConfirmParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .confirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - - val entity = entityFuture.get() - entity.validate() - } - @Test fun createBeneficialOwner() { val client = @@ -743,35 +719,6 @@ internal class EntityServiceAsyncTest { entity.validate() } - @Test - fun updateAddress() { - val client = - IncreaseOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val entityServiceAsync = client.entities() - - val entityFuture = - entityServiceAsync.updateAddress( - EntityUpdateAddressParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .address( - EntityUpdateAddressParams.Address.builder() - .city("New York") - .line1("33 Liberty Street") - .state("NY") - .zip("10045") - .line2("Unit 2") - .build() - ) - .build() - ) - - val entity = entityFuture.get() - entity.validate() - } - @Test fun updateBeneficialOwnerAddress() { val client = @@ -804,25 +751,4 @@ internal class EntityServiceAsyncTest { val entity = entityFuture.get() entity.validate() } - - @Test - fun updateIndustryCode() { - val client = - IncreaseOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val entityServiceAsync = client.entities() - - val entityFuture = - entityServiceAsync.updateIndustryCode( - EntityUpdateIndustryCodeParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .industryCode("5132") - .build() - ) - - val entity = entityFuture.get() - entity.validate() - } } diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/EventServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/EventServiceAsyncTest.kt index 688ad8377..406512e6f 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/async/EventServiceAsyncTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/EventServiceAsyncTest.kt @@ -69,7 +69,29 @@ internal class EventServiceAsyncTest { ) .build() - eventServiceAsync.unwrap(payload).validate() + // Correct key should not throw + eventServiceAsync.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(headers) + .secret(webhookSecret) + .build() + ) + eventServiceAsync + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(headers).build()) + + // Secret in method takes precedence to secret on client + val wrongKey = "whsec_aaaaaaaaaa" + eventServiceAsync + .withOptions { it.webhookSecret(wrongKey) } + .unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(headers) + .secret(webhookSecret) + .build() + ) // Wrong key should throw assertThrows { @@ -82,6 +104,29 @@ internal class EventServiceAsyncTest { .build() ) } + assertThrows { + val wrongKey = "whsec_aaaaaaaaaa" + eventServiceAsync + .withOptions { it.webhookSecret(wrongKey) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(headers).build()) + } + + assertThrows { + val wrongKey = "whsec_aaaaaaaaaa" + eventServiceAsync.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(headers) + .secret(wrongKey) + .build() + ) + } + assertThrows { + val wrongKey = "whsec_aaaaaaaaaa" + eventServiceAsync + .withOptions { it.webhookSecret(wrongKey) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(headers).build()) + } // Bad signature should throw assertThrows { @@ -96,6 +141,14 @@ internal class EventServiceAsyncTest { .build() ) } + assertThrows { + val badSig = webhook.sign(messageId, timestampSeconds, "some other payload") + val badHeaders = + headers.toBuilder().replace("webhook-signature", listOf(badSig)).build() + eventServiceAsync + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(badHeaders).build()) + } // Old timestamp should throw assertThrows { @@ -108,6 +161,12 @@ internal class EventServiceAsyncTest { .build() ) } + assertThrows { + val oldHeaders = headers.toBuilder().replace("webhook-timestamp", listOf("5")).build() + eventServiceAsync + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(oldHeaders).build()) + } // Wrong message ID should throw assertThrows { @@ -120,5 +179,11 @@ internal class EventServiceAsyncTest { .build() ) } + assertThrows { + val wrongIdHeaders = headers.toBuilder().replace("webhook-id", listOf("wrong")).build() + eventServiceAsync + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(wrongIdHeaders).build()) + } } } diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/EntityServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/EntityServiceTest.kt index 243dfa549..2c822e1d8 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/EntityServiceTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/EntityServiceTest.kt @@ -5,12 +5,9 @@ package com.increase.api.services.blocking import com.increase.api.TestServerExtension import com.increase.api.client.okhttp.IncreaseOkHttpClient import com.increase.api.models.entities.EntityArchiveBeneficialOwnerParams -import com.increase.api.models.entities.EntityConfirmParams import com.increase.api.models.entities.EntityCreateBeneficialOwnerParams import com.increase.api.models.entities.EntityCreateParams -import com.increase.api.models.entities.EntityUpdateAddressParams import com.increase.api.models.entities.EntityUpdateBeneficialOwnerAddressParams -import com.increase.api.models.entities.EntityUpdateIndustryCodeParams import com.increase.api.models.entities.EntityUpdateParams import java.time.LocalDate import java.time.OffsetDateTime @@ -618,26 +615,6 @@ internal class EntityServiceTest { entity.validate() } - @Test - fun confirm() { - val client = - IncreaseOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val entityService = client.entities() - - val entity = - entityService.confirm( - EntityConfirmParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .confirmedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - - entity.validate() - } - @Test fun createBeneficialOwner() { val client = @@ -735,34 +712,6 @@ internal class EntityServiceTest { entity.validate() } - @Test - fun updateAddress() { - val client = - IncreaseOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val entityService = client.entities() - - val entity = - entityService.updateAddress( - EntityUpdateAddressParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .address( - EntityUpdateAddressParams.Address.builder() - .city("New York") - .line1("33 Liberty Street") - .state("NY") - .zip("10045") - .line2("Unit 2") - .build() - ) - .build() - ) - - entity.validate() - } - @Test fun updateBeneficialOwnerAddress() { val client = @@ -794,24 +743,4 @@ internal class EntityServiceTest { entity.validate() } - - @Test - fun updateIndustryCode() { - val client = - IncreaseOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val entityService = client.entities() - - val entity = - entityService.updateIndustryCode( - EntityUpdateIndustryCodeParams.builder() - .entityId("entity_n8y8tnk2p9339ti393yi") - .industryCode("5132") - .build() - ) - - entity.validate() - } } diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/EventServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/EventServiceTest.kt index 390cd59fd..4e32b3b93 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/EventServiceTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/EventServiceTest.kt @@ -67,7 +67,29 @@ internal class EventServiceTest { ) .build() - eventService.unwrap(payload).validate() + // Correct key should not throw + eventService.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(headers) + .secret(webhookSecret) + .build() + ) + eventService + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(headers).build()) + + // Secret in method takes precedence to secret on client + val wrongKey = "whsec_aaaaaaaaaa" + eventService + .withOptions { it.webhookSecret(wrongKey) } + .unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(headers) + .secret(webhookSecret) + .build() + ) // Wrong key should throw assertThrows { @@ -80,6 +102,29 @@ internal class EventServiceTest { .build() ) } + assertThrows { + val wrongKey = "whsec_aaaaaaaaaa" + eventService + .withOptions { it.webhookSecret(wrongKey) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(headers).build()) + } + + assertThrows { + val wrongKey = "whsec_aaaaaaaaaa" + eventService.unwrap( + UnwrapWebhookParams.builder() + .body(payload) + .headers(headers) + .secret(wrongKey) + .build() + ) + } + assertThrows { + val wrongKey = "whsec_aaaaaaaaaa" + eventService + .withOptions { it.webhookSecret(wrongKey) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(headers).build()) + } // Bad signature should throw assertThrows { @@ -94,6 +139,14 @@ internal class EventServiceTest { .build() ) } + assertThrows { + val badSig = webhook.sign(messageId, timestampSeconds, "some other payload") + val badHeaders = + headers.toBuilder().replace("webhook-signature", listOf(badSig)).build() + eventService + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(badHeaders).build()) + } // Old timestamp should throw assertThrows { @@ -106,6 +159,12 @@ internal class EventServiceTest { .build() ) } + assertThrows { + val oldHeaders = headers.toBuilder().replace("webhook-timestamp", listOf("5")).build() + eventService + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(oldHeaders).build()) + } // Wrong message ID should throw assertThrows { @@ -118,5 +177,11 @@ internal class EventServiceTest { .build() ) } + assertThrows { + val wrongIdHeaders = headers.toBuilder().replace("webhook-id", listOf("wrong")).build() + eventService + .withOptions { it.webhookSecret(webhookSecret) } + .unwrap(UnwrapWebhookParams.builder().body(payload).headers(wrongIdHeaders).build()) + } } }