diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 422745047..d1b100d62 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.312.0" + ".": "0.313.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 4046227bc..7002ed35c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 216 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-fbdfb5721d0c46a176ee6d81936d2710556c39cc486c5de246cc17b0503ee408.yml -openapi_spec_hash: 66c900a94b458e5b796ac1d2a5fceb13 -config_hash: 632b628b59d8f0b717153b3d8133f6cb +configured_endpoints: 217 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-166f5a60acb9f1b94415e641215f0988dc14a8bce6a0e1a95e521fdbb0b91243.yml +openapi_spec_hash: adbd71ae90ad4559759517a17c4fec08 +config_hash: 2a4a1945e6eefa24fa5b0590cf580fb4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 16f101cd2..56034046b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.313.0 (2025-09-04) + +Full Changelog: [v0.312.0...v0.313.0](https://github.com/Increase/increase-java/compare/v0.312.0...v0.313.0) + +### Features + +* **api:** api update ([1f10bd1](https://github.com/Increase/increase-java/commit/1f10bd1512faf9bd465c08f709b4cb1e6e5e1330)) + ## 0.312.0 (2025-09-04) Full Changelog: [v0.311.1...v0.312.0](https://github.com/Increase/increase-java/compare/v0.311.1...v0.312.0) diff --git a/README.md b/README.md index 2c7f6b16d..1cfbd7633 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.312.0) -[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.312.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.312.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.313.0) +[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.313.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.313.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.312.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.313.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.312.0") +implementation("com.increase.api:increase-java:0.313.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.increase.api:increase-java:0.312.0") com.increase.api increase-java - 0.312.0 + 0.313.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 5f61c0a2c..ff0dfab1f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.increase.api" - version = "0.312.0" // x-release-please-version + version = "0.313.0" // x-release-please-version } subprojects { diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/entities/Entity.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/entities/Entity.kt index 92cf33073..51919dc59 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/entities/Entity.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/entities/Entity.kt @@ -38,6 +38,7 @@ private constructor( private val idempotencyKey: JsonField, private val joint: JsonField, private val naturalPerson: JsonField, + private val riskRating: JsonField, private val status: JsonField, private val structure: JsonField, private val supplementalDocuments: JsonField>, @@ -72,6 +73,9 @@ private constructor( @JsonProperty("natural_person") @ExcludeMissing naturalPerson: JsonField = JsonMissing.of(), + @JsonProperty("risk_rating") + @ExcludeMissing + riskRating: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), @JsonProperty("structure") @ExcludeMissing @@ -94,6 +98,7 @@ private constructor( idempotencyKey, joint, naturalPerson, + riskRating, status, structure, supplementalDocuments, @@ -182,6 +187,15 @@ private constructor( */ fun naturalPerson(): Optional = naturalPerson.getOptional("natural_person") + /** + * An assessment of the entity’s potential risk of involvement in financial crimes, such as + * money laundering. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun riskRating(): Optional = riskRating.getOptional("risk_rating") + /** * The status of the entity. * @@ -312,6 +326,15 @@ private constructor( @ExcludeMissing fun _naturalPerson(): JsonField = naturalPerson + /** + * Returns the raw JSON value of [riskRating]. + * + * Unlike [riskRating], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("risk_rating") + @ExcludeMissing + fun _riskRating(): JsonField = riskRating + /** * Returns the raw JSON value of [status]. * @@ -389,6 +412,7 @@ private constructor( * .idempotencyKey() * .joint() * .naturalPerson() + * .riskRating() * .status() * .structure() * .supplementalDocuments() @@ -412,6 +436,7 @@ private constructor( private var idempotencyKey: JsonField? = null private var joint: JsonField? = null private var naturalPerson: JsonField? = null + private var riskRating: JsonField? = null private var status: JsonField? = null private var structure: JsonField? = null private var supplementalDocuments: JsonField>? = @@ -432,6 +457,7 @@ private constructor( idempotencyKey = entity.idempotencyKey joint = entity.joint naturalPerson = entity.naturalPerson + riskRating = entity.riskRating status = entity.status structure = entity.structure supplementalDocuments = entity.supplementalDocuments.map { it.toMutableList() } @@ -609,6 +635,24 @@ private constructor( this.naturalPerson = naturalPerson } + /** + * An assessment of the entity’s potential risk of involvement in financial crimes, such as + * money laundering. + */ + fun riskRating(riskRating: RiskRating?) = riskRating(JsonField.ofNullable(riskRating)) + + /** Alias for calling [Builder.riskRating] with `riskRating.orElse(null)`. */ + fun riskRating(riskRating: Optional) = riskRating(riskRating.getOrNull()) + + /** + * Sets [Builder.riskRating] to an arbitrary JSON value. + * + * You should usually call [Builder.riskRating] with a well-typed [RiskRating] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun riskRating(riskRating: JsonField) = apply { this.riskRating = riskRating } + /** The status of the entity. */ fun status(status: Status) = status(JsonField.of(status)) @@ -751,6 +795,7 @@ private constructor( * .idempotencyKey() * .joint() * .naturalPerson() + * .riskRating() * .status() * .structure() * .supplementalDocuments() @@ -772,6 +817,7 @@ private constructor( checkRequired("idempotencyKey", idempotencyKey), checkRequired("joint", joint), checkRequired("naturalPerson", naturalPerson), + checkRequired("riskRating", riskRating), checkRequired("status", status), checkRequired("structure", structure), checkRequired("supplementalDocuments", supplementalDocuments).map { @@ -800,6 +846,7 @@ private constructor( idempotencyKey() joint().ifPresent { it.validate() } naturalPerson().ifPresent { it.validate() } + riskRating().ifPresent { it.validate() } status().validate() structure().validate() supplementalDocuments().forEach { it.validate() } @@ -833,6 +880,7 @@ private constructor( (if (idempotencyKey.asKnown().isPresent) 1 else 0) + (joint.asKnown().getOrNull()?.validity() ?: 0) + (naturalPerson.asKnown().getOrNull()?.validity() ?: 0) + + (riskRating.asKnown().getOrNull()?.validity() ?: 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + (structure.asKnown().getOrNull()?.validity() ?: 0) + (supplementalDocuments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -6522,6 +6570,360 @@ private constructor( "NaturalPerson{address=$address, dateOfBirth=$dateOfBirth, identification=$identification, name=$name, additionalProperties=$additionalProperties}" } + /** + * An assessment of the entity’s potential risk of involvement in financial crimes, such as + * money laundering. + */ + class RiskRating + private constructor( + private val ratedAt: JsonField, + private val rating: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("rated_at") + @ExcludeMissing + ratedAt: JsonField = JsonMissing.of(), + @JsonProperty("rating") @ExcludeMissing rating: JsonField = JsonMissing.of(), + ) : this(ratedAt, rating, mutableMapOf()) + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the risk rating was + * performed. + * + * @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 ratedAt(): OffsetDateTime = ratedAt.getRequired("rated_at") + + /** + * The rating given to this entity. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun rating(): Rating = rating.getRequired("rating") + + /** + * Returns the raw JSON value of [ratedAt]. + * + * Unlike [ratedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rated_at") + @ExcludeMissing + fun _ratedAt(): JsonField = ratedAt + + /** + * Returns the raw JSON value of [rating]. + * + * Unlike [rating], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rating") @ExcludeMissing fun _rating(): JsonField = rating + + @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 [RiskRating]. + * + * The following fields are required: + * ```java + * .ratedAt() + * .rating() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RiskRating]. */ + class Builder internal constructor() { + + private var ratedAt: JsonField? = null + private var rating: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(riskRating: RiskRating) = apply { + ratedAt = riskRating.ratedAt + rating = riskRating.rating + additionalProperties = riskRating.additionalProperties.toMutableMap() + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the risk rating + * was performed. + */ + fun ratedAt(ratedAt: OffsetDateTime) = ratedAt(JsonField.of(ratedAt)) + + /** + * Sets [Builder.ratedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.ratedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ratedAt(ratedAt: JsonField) = apply { this.ratedAt = ratedAt } + + /** The rating given to this entity. */ + fun rating(rating: Rating) = rating(JsonField.of(rating)) + + /** + * Sets [Builder.rating] to an arbitrary JSON value. + * + * You should usually call [Builder.rating] with a well-typed [Rating] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rating(rating: JsonField) = apply { this.rating = rating } + + 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 [RiskRating]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .ratedAt() + * .rating() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RiskRating = + RiskRating( + checkRequired("ratedAt", ratedAt), + checkRequired("rating", rating), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RiskRating = apply { + if (validated) { + return@apply + } + + ratedAt() + rating().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (ratedAt.asKnown().isPresent) 1 else 0) + + (rating.asKnown().getOrNull()?.validity() ?: 0) + + /** The rating given to this entity. */ + class Rating @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + /** Low */ + @JvmField val LOW = of("low") + + /** Medium */ + @JvmField val MEDIUM = of("medium") + + /** High */ + @JvmField val HIGH = of("high") + + @JvmStatic fun of(value: String) = Rating(JsonField.of(value)) + } + + /** An enum containing [Rating]'s known values. */ + enum class Known { + /** Low */ + LOW, + /** Medium */ + MEDIUM, + /** High */ + HIGH, + } + + /** + * An enum containing [Rating]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Rating] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Low */ + LOW, + /** Medium */ + MEDIUM, + /** High */ + HIGH, + /** + * An enum member indicating that [Rating] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LOW -> Value.LOW + MEDIUM -> Value.MEDIUM + HIGH -> Value.HIGH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LOW -> Known.LOW + MEDIUM -> Known.MEDIUM + HIGH -> Known.HIGH + else -> throw IncreaseInvalidDataException("Unknown Rating: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Rating = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Rating && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RiskRating && + ratedAt == other.ratedAt && + rating == other.rating && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(ratedAt, rating, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RiskRating{ratedAt=$ratedAt, rating=$rating, additionalProperties=$additionalProperties}" + } + /** The status of the entity. */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -10710,6 +11112,7 @@ private constructor( idempotencyKey == other.idempotencyKey && joint == other.joint && naturalPerson == other.naturalPerson && + riskRating == other.riskRating && status == other.status && structure == other.structure && supplementalDocuments == other.supplementalDocuments && @@ -10730,6 +11133,7 @@ private constructor( idempotencyKey, joint, naturalPerson, + riskRating, status, structure, supplementalDocuments, @@ -10743,5 +11147,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Entity{id=$id, corporation=$corporation, createdAt=$createdAt, description=$description, detailsConfirmedAt=$detailsConfirmedAt, governmentAuthority=$governmentAuthority, idempotencyKey=$idempotencyKey, joint=$joint, naturalPerson=$naturalPerson, status=$status, structure=$structure, supplementalDocuments=$supplementalDocuments, thirdPartyVerification=$thirdPartyVerification, trust=$trust, type=$type, additionalProperties=$additionalProperties}" + "Entity{id=$id, corporation=$corporation, createdAt=$createdAt, description=$description, detailsConfirmedAt=$detailsConfirmedAt, governmentAuthority=$governmentAuthority, idempotencyKey=$idempotencyKey, joint=$joint, naturalPerson=$naturalPerson, riskRating=$riskRating, status=$status, structure=$structure, supplementalDocuments=$supplementalDocuments, thirdPartyVerification=$thirdPartyVerification, trust=$trust, type=$type, additionalProperties=$additionalProperties}" } diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityCreateParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityCreateParams.kt index 9171eb6c9..cdd9ae0de 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityCreateParams.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityCreateParams.kt @@ -19,6 +19,7 @@ import com.increase.api.core.http.QueryParams import com.increase.api.core.toImmutable import com.increase.api.errors.IncreaseInvalidDataException import java.time.LocalDate +import java.time.OffsetDateTime import java.util.Collections import java.util.Objects import java.util.Optional @@ -84,6 +85,15 @@ private constructor( */ fun naturalPerson(): Optional = body.naturalPerson() + /** + * An assessment of the entity’s potential risk of involvement in financial crimes, such as + * money laundering. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun riskRating(): Optional = body.riskRating() + /** * Additional documentation associated with the entity. * @@ -152,6 +162,13 @@ private constructor( */ fun _naturalPerson(): JsonField = body._naturalPerson() + /** + * Returns the raw JSON value of [riskRating]. + * + * Unlike [riskRating], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _riskRating(): JsonField = body._riskRating() + /** * Returns the raw JSON value of [supplementalDocuments]. * @@ -320,6 +337,21 @@ private constructor( body.naturalPerson(naturalPerson) } + /** + * An assessment of the entity’s potential risk of involvement in financial crimes, such as + * money laundering. + */ + fun riskRating(riskRating: RiskRating) = apply { body.riskRating(riskRating) } + + /** + * Sets [Builder.riskRating] to an arbitrary JSON value. + * + * You should usually call [Builder.riskRating] with a well-typed [RiskRating] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun riskRating(riskRating: JsonField) = apply { body.riskRating(riskRating) } + /** Additional documentation associated with the entity. */ fun supplementalDocuments(supplementalDocuments: List) = apply { body.supplementalDocuments(supplementalDocuments) @@ -528,6 +560,7 @@ private constructor( private val governmentAuthority: JsonField, private val joint: JsonField, private val naturalPerson: JsonField, + private val riskRating: JsonField, private val supplementalDocuments: JsonField>, private val thirdPartyVerification: JsonField, private val trust: JsonField, @@ -552,6 +585,9 @@ private constructor( @JsonProperty("natural_person") @ExcludeMissing naturalPerson: JsonField = JsonMissing.of(), + @JsonProperty("risk_rating") + @ExcludeMissing + riskRating: JsonField = JsonMissing.of(), @JsonProperty("supplemental_documents") @ExcludeMissing supplementalDocuments: JsonField> = JsonMissing.of(), @@ -566,6 +602,7 @@ private constructor( governmentAuthority, joint, naturalPerson, + riskRating, supplementalDocuments, thirdPartyVerification, trust, @@ -626,6 +663,15 @@ private constructor( */ fun naturalPerson(): Optional = naturalPerson.getOptional("natural_person") + /** + * An assessment of the entity’s potential risk of involvement in financial crimes, such as + * money laundering. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun riskRating(): Optional = riskRating.getOptional("risk_rating") + /** * Additional documentation associated with the entity. * @@ -707,6 +753,15 @@ private constructor( @ExcludeMissing fun _naturalPerson(): JsonField = naturalPerson + /** + * Returns the raw JSON value of [riskRating]. + * + * Unlike [riskRating], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("risk_rating") + @ExcludeMissing + fun _riskRating(): JsonField = riskRating + /** * Returns the raw JSON value of [supplementalDocuments]. * @@ -768,6 +823,7 @@ private constructor( private var governmentAuthority: JsonField = JsonMissing.of() private var joint: JsonField = JsonMissing.of() private var naturalPerson: JsonField = JsonMissing.of() + private var riskRating: JsonField = JsonMissing.of() private var supplementalDocuments: JsonField>? = null private var thirdPartyVerification: JsonField = JsonMissing.of() private var trust: JsonField = JsonMissing.of() @@ -781,6 +837,7 @@ private constructor( governmentAuthority = body.governmentAuthority joint = body.joint naturalPerson = body.naturalPerson + riskRating = body.riskRating supplementalDocuments = body.supplementalDocuments.map { it.toMutableList() } thirdPartyVerification = body.thirdPartyVerification trust = body.trust @@ -882,6 +939,23 @@ private constructor( this.naturalPerson = naturalPerson } + /** + * An assessment of the entity’s potential risk of involvement in financial crimes, such + * as money laundering. + */ + fun riskRating(riskRating: RiskRating) = riskRating(JsonField.of(riskRating)) + + /** + * Sets [Builder.riskRating] to an arbitrary JSON value. + * + * You should usually call [Builder.riskRating] with a well-typed [RiskRating] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun riskRating(riskRating: JsonField) = apply { + this.riskRating = riskRating + } + /** Additional documentation associated with the entity. */ fun supplementalDocuments(supplementalDocuments: List) = supplementalDocuments(JsonField.of(supplementalDocuments)) @@ -983,6 +1057,7 @@ private constructor( governmentAuthority, joint, naturalPerson, + riskRating, (supplementalDocuments ?: JsonMissing.of()).map { it.toImmutable() }, thirdPartyVerification, trust, @@ -1003,6 +1078,7 @@ private constructor( governmentAuthority().ifPresent { it.validate() } joint().ifPresent { it.validate() } naturalPerson().ifPresent { it.validate() } + riskRating().ifPresent { it.validate() } supplementalDocuments().ifPresent { it.forEach { it.validate() } } thirdPartyVerification().ifPresent { it.validate() } trust().ifPresent { it.validate() } @@ -1031,6 +1107,7 @@ private constructor( (governmentAuthority.asKnown().getOrNull()?.validity() ?: 0) + (joint.asKnown().getOrNull()?.validity() ?: 0) + (naturalPerson.asKnown().getOrNull()?.validity() ?: 0) + + (riskRating.asKnown().getOrNull()?.validity() ?: 0) + (supplementalDocuments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (thirdPartyVerification.asKnown().getOrNull()?.validity() ?: 0) + @@ -1048,6 +1125,7 @@ private constructor( governmentAuthority == other.governmentAuthority && joint == other.joint && naturalPerson == other.naturalPerson && + riskRating == other.riskRating && supplementalDocuments == other.supplementalDocuments && thirdPartyVerification == other.thirdPartyVerification && trust == other.trust && @@ -1062,6 +1140,7 @@ private constructor( governmentAuthority, joint, naturalPerson, + riskRating, supplementalDocuments, thirdPartyVerification, trust, @@ -1072,7 +1151,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{structure=$structure, corporation=$corporation, description=$description, governmentAuthority=$governmentAuthority, joint=$joint, naturalPerson=$naturalPerson, supplementalDocuments=$supplementalDocuments, thirdPartyVerification=$thirdPartyVerification, trust=$trust, additionalProperties=$additionalProperties}" + "Body{structure=$structure, corporation=$corporation, description=$description, governmentAuthority=$governmentAuthority, joint=$joint, naturalPerson=$naturalPerson, riskRating=$riskRating, supplementalDocuments=$supplementalDocuments, thirdPartyVerification=$thirdPartyVerification, trust=$trust, additionalProperties=$additionalProperties}" } /** The type of Entity to create. */ @@ -10437,6 +10516,360 @@ private constructor( "NaturalPerson{address=$address, dateOfBirth=$dateOfBirth, identification=$identification, name=$name, confirmedNoUsTaxId=$confirmedNoUsTaxId, additionalProperties=$additionalProperties}" } + /** + * An assessment of the entity’s potential risk of involvement in financial crimes, such as + * money laundering. + */ + class RiskRating + private constructor( + private val ratedAt: JsonField, + private val rating: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("rated_at") + @ExcludeMissing + ratedAt: JsonField = JsonMissing.of(), + @JsonProperty("rating") @ExcludeMissing rating: JsonField = JsonMissing.of(), + ) : this(ratedAt, rating, mutableMapOf()) + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the risk rating was + * performed. + * + * @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 ratedAt(): OffsetDateTime = ratedAt.getRequired("rated_at") + + /** + * The rating given to this entity. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun rating(): Rating = rating.getRequired("rating") + + /** + * Returns the raw JSON value of [ratedAt]. + * + * Unlike [ratedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rated_at") + @ExcludeMissing + fun _ratedAt(): JsonField = ratedAt + + /** + * Returns the raw JSON value of [rating]. + * + * Unlike [rating], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rating") @ExcludeMissing fun _rating(): JsonField = rating + + @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 [RiskRating]. + * + * The following fields are required: + * ```java + * .ratedAt() + * .rating() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RiskRating]. */ + class Builder internal constructor() { + + private var ratedAt: JsonField? = null + private var rating: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(riskRating: RiskRating) = apply { + ratedAt = riskRating.ratedAt + rating = riskRating.rating + additionalProperties = riskRating.additionalProperties.toMutableMap() + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the risk rating + * was performed. + */ + fun ratedAt(ratedAt: OffsetDateTime) = ratedAt(JsonField.of(ratedAt)) + + /** + * Sets [Builder.ratedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.ratedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ratedAt(ratedAt: JsonField) = apply { this.ratedAt = ratedAt } + + /** The rating given to this entity. */ + fun rating(rating: Rating) = rating(JsonField.of(rating)) + + /** + * Sets [Builder.rating] to an arbitrary JSON value. + * + * You should usually call [Builder.rating] with a well-typed [Rating] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rating(rating: JsonField) = apply { this.rating = rating } + + 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 [RiskRating]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .ratedAt() + * .rating() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RiskRating = + RiskRating( + checkRequired("ratedAt", ratedAt), + checkRequired("rating", rating), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RiskRating = apply { + if (validated) { + return@apply + } + + ratedAt() + rating().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (ratedAt.asKnown().isPresent) 1 else 0) + + (rating.asKnown().getOrNull()?.validity() ?: 0) + + /** The rating given to this entity. */ + class Rating @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + /** Low */ + @JvmField val LOW = of("low") + + /** Medium */ + @JvmField val MEDIUM = of("medium") + + /** High */ + @JvmField val HIGH = of("high") + + @JvmStatic fun of(value: String) = Rating(JsonField.of(value)) + } + + /** An enum containing [Rating]'s known values. */ + enum class Known { + /** Low */ + LOW, + /** Medium */ + MEDIUM, + /** High */ + HIGH, + } + + /** + * An enum containing [Rating]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Rating] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Low */ + LOW, + /** Medium */ + MEDIUM, + /** High */ + HIGH, + /** + * An enum member indicating that [Rating] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LOW -> Value.LOW + MEDIUM -> Value.MEDIUM + HIGH -> Value.HIGH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LOW -> Known.LOW + MEDIUM -> Known.MEDIUM + HIGH -> Known.HIGH + else -> throw IncreaseInvalidDataException("Unknown Rating: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Rating = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Rating && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RiskRating && + ratedAt == other.ratedAt && + rating == other.rating && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(ratedAt, rating, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RiskRating{ratedAt=$ratedAt, rating=$rating, additionalProperties=$additionalProperties}" + } + class SupplementalDocument private constructor( private val fileId: JsonField, diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityUpdateParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityUpdateParams.kt new file mode 100644 index 000000000..7de1270c9 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/entities/EntityUpdateParams.kt @@ -0,0 +1,1221 @@ +// 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.Enum +import com.increase.api.core.ExcludeMissing +import com.increase.api.core.JsonField +import com.increase.api.core.JsonMissing +import com.increase.api.core.JsonValue +import com.increase.api.core.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.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update an Entity */ +class EntityUpdateParams +private constructor( + private val entityId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The entity identifier. */ + fun entityId(): Optional = Optional.ofNullable(entityId) + + /** + * An assessment of the entity’s potential risk of involvement in financial crimes, such as + * money laundering. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun riskRating(): Optional = body.riskRating() + + /** + * A reference to data stored in a third-party verification service. Your integration may or may + * not use this field. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun thirdPartyVerification(): Optional = body.thirdPartyVerification() + + /** + * Returns the raw JSON value of [riskRating]. + * + * Unlike [riskRating], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _riskRating(): JsonField = body._riskRating() + + /** + * Returns the raw JSON value of [thirdPartyVerification]. + * + * Unlike [thirdPartyVerification], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _thirdPartyVerification(): JsonField = + body._thirdPartyVerification() + + 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(): EntityUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [EntityUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EntityUpdateParams]. */ + 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(entityUpdateParams: EntityUpdateParams) = apply { + entityId = entityUpdateParams.entityId + body = entityUpdateParams.body.toBuilder() + additionalHeaders = entityUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = entityUpdateParams.additionalQueryParams.toBuilder() + } + + /** The entity identifier. */ + 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: + * - [riskRating] + * - [thirdPartyVerification] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * An assessment of the entity’s potential risk of involvement in financial crimes, such as + * money laundering. + */ + fun riskRating(riskRating: RiskRating) = apply { body.riskRating(riskRating) } + + /** + * Sets [Builder.riskRating] to an arbitrary JSON value. + * + * You should usually call [Builder.riskRating] with a well-typed [RiskRating] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun riskRating(riskRating: JsonField) = apply { body.riskRating(riskRating) } + + /** + * A reference to data stored in a third-party verification service. Your integration may or + * may not use this field. + */ + fun thirdPartyVerification(thirdPartyVerification: ThirdPartyVerification) = apply { + body.thirdPartyVerification(thirdPartyVerification) + } + + /** + * Sets [Builder.thirdPartyVerification] to an arbitrary JSON value. + * + * You should usually call [Builder.thirdPartyVerification] with a well-typed + * [ThirdPartyVerification] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun thirdPartyVerification(thirdPartyVerification: JsonField) = + apply { + body.thirdPartyVerification(thirdPartyVerification) + } + + 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 [EntityUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EntityUpdateParams = + EntityUpdateParams( + 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 + private constructor( + private val riskRating: JsonField, + private val thirdPartyVerification: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("risk_rating") + @ExcludeMissing + riskRating: JsonField = JsonMissing.of(), + @JsonProperty("third_party_verification") + @ExcludeMissing + thirdPartyVerification: JsonField = JsonMissing.of(), + ) : this(riskRating, thirdPartyVerification, mutableMapOf()) + + /** + * An assessment of the entity’s potential risk of involvement in financial crimes, such as + * money laundering. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun riskRating(): Optional = riskRating.getOptional("risk_rating") + + /** + * A reference to data stored in a third-party verification service. Your integration may or + * may not use this field. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun thirdPartyVerification(): Optional = + thirdPartyVerification.getOptional("third_party_verification") + + /** + * Returns the raw JSON value of [riskRating]. + * + * Unlike [riskRating], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("risk_rating") + @ExcludeMissing + fun _riskRating(): JsonField = riskRating + + /** + * Returns the raw JSON value of [thirdPartyVerification]. + * + * Unlike [thirdPartyVerification], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("third_party_verification") + @ExcludeMissing + fun _thirdPartyVerification(): JsonField = thirdPartyVerification + + @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 riskRating: JsonField = JsonMissing.of() + private var thirdPartyVerification: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + riskRating = body.riskRating + thirdPartyVerification = body.thirdPartyVerification + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * An assessment of the entity’s potential risk of involvement in financial crimes, such + * as money laundering. + */ + fun riskRating(riskRating: RiskRating) = riskRating(JsonField.of(riskRating)) + + /** + * Sets [Builder.riskRating] to an arbitrary JSON value. + * + * You should usually call [Builder.riskRating] with a well-typed [RiskRating] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun riskRating(riskRating: JsonField) = apply { + this.riskRating = riskRating + } + + /** + * A reference to data stored in a third-party verification service. Your integration + * may or may not use this field. + */ + fun thirdPartyVerification(thirdPartyVerification: ThirdPartyVerification) = + thirdPartyVerification(JsonField.of(thirdPartyVerification)) + + /** + * Sets [Builder.thirdPartyVerification] to an arbitrary JSON value. + * + * You should usually call [Builder.thirdPartyVerification] with a well-typed + * [ThirdPartyVerification] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun thirdPartyVerification(thirdPartyVerification: JsonField) = + apply { + this.thirdPartyVerification = thirdPartyVerification + } + + 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(riskRating, thirdPartyVerification, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + riskRating().ifPresent { it.validate() } + thirdPartyVerification().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (riskRating.asKnown().getOrNull()?.validity() ?: 0) + + (thirdPartyVerification.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + riskRating == other.riskRating && + thirdPartyVerification == other.thirdPartyVerification && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(riskRating, thirdPartyVerification, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{riskRating=$riskRating, thirdPartyVerification=$thirdPartyVerification, additionalProperties=$additionalProperties}" + } + + /** + * An assessment of the entity’s potential risk of involvement in financial crimes, such as + * money laundering. + */ + class RiskRating + private constructor( + private val ratedAt: JsonField, + private val rating: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("rated_at") + @ExcludeMissing + ratedAt: JsonField = JsonMissing.of(), + @JsonProperty("rating") @ExcludeMissing rating: JsonField = JsonMissing.of(), + ) : this(ratedAt, rating, mutableMapOf()) + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the risk rating was + * performed. + * + * @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 ratedAt(): OffsetDateTime = ratedAt.getRequired("rated_at") + + /** + * The rating given to this entity. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun rating(): Rating = rating.getRequired("rating") + + /** + * Returns the raw JSON value of [ratedAt]. + * + * Unlike [ratedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rated_at") + @ExcludeMissing + fun _ratedAt(): JsonField = ratedAt + + /** + * Returns the raw JSON value of [rating]. + * + * Unlike [rating], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rating") @ExcludeMissing fun _rating(): JsonField = rating + + @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 [RiskRating]. + * + * The following fields are required: + * ```java + * .ratedAt() + * .rating() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RiskRating]. */ + class Builder internal constructor() { + + private var ratedAt: JsonField? = null + private var rating: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(riskRating: RiskRating) = apply { + ratedAt = riskRating.ratedAt + rating = riskRating.rating + additionalProperties = riskRating.additionalProperties.toMutableMap() + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the risk rating + * was performed. + */ + fun ratedAt(ratedAt: OffsetDateTime) = ratedAt(JsonField.of(ratedAt)) + + /** + * Sets [Builder.ratedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.ratedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ratedAt(ratedAt: JsonField) = apply { this.ratedAt = ratedAt } + + /** The rating given to this entity. */ + fun rating(rating: Rating) = rating(JsonField.of(rating)) + + /** + * Sets [Builder.rating] to an arbitrary JSON value. + * + * You should usually call [Builder.rating] with a well-typed [Rating] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rating(rating: JsonField) = apply { this.rating = rating } + + 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 [RiskRating]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .ratedAt() + * .rating() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RiskRating = + RiskRating( + checkRequired("ratedAt", ratedAt), + checkRequired("rating", rating), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RiskRating = apply { + if (validated) { + return@apply + } + + ratedAt() + rating().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (ratedAt.asKnown().isPresent) 1 else 0) + + (rating.asKnown().getOrNull()?.validity() ?: 0) + + /** The rating given to this entity. */ + class Rating @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + /** Low */ + @JvmField val LOW = of("low") + + /** Medium */ + @JvmField val MEDIUM = of("medium") + + /** High */ + @JvmField val HIGH = of("high") + + @JvmStatic fun of(value: String) = Rating(JsonField.of(value)) + } + + /** An enum containing [Rating]'s known values. */ + enum class Known { + /** Low */ + LOW, + /** Medium */ + MEDIUM, + /** High */ + HIGH, + } + + /** + * An enum containing [Rating]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Rating] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Low */ + LOW, + /** Medium */ + MEDIUM, + /** High */ + HIGH, + /** + * An enum member indicating that [Rating] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LOW -> Value.LOW + MEDIUM -> Value.MEDIUM + HIGH -> Value.HIGH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LOW -> Known.LOW + MEDIUM -> Known.MEDIUM + HIGH -> Known.HIGH + else -> throw IncreaseInvalidDataException("Unknown Rating: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Rating = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Rating && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RiskRating && + ratedAt == other.ratedAt && + rating == other.rating && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(ratedAt, rating, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RiskRating{ratedAt=$ratedAt, rating=$rating, additionalProperties=$additionalProperties}" + } + + /** + * A reference to data stored in a third-party verification service. Your integration may or may + * not use this field. + */ + class ThirdPartyVerification + private constructor( + private val reference: JsonField, + private val vendor: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("reference") + @ExcludeMissing + reference: JsonField = JsonMissing.of(), + @JsonProperty("vendor") @ExcludeMissing vendor: JsonField = JsonMissing.of(), + ) : this(reference, vendor, mutableMapOf()) + + /** + * The reference identifier for the third party verification. + * + * @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 reference(): String = reference.getRequired("reference") + + /** + * The vendor that was used to perform the verification. + * + * @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 vendor(): Vendor = vendor.getRequired("vendor") + + /** + * Returns the raw JSON value of [reference]. + * + * Unlike [reference], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reference") @ExcludeMissing fun _reference(): JsonField = reference + + /** + * Returns the raw JSON value of [vendor]. + * + * Unlike [vendor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vendor") @ExcludeMissing fun _vendor(): JsonField = vendor + + @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 [ThirdPartyVerification]. + * + * The following fields are required: + * ```java + * .reference() + * .vendor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThirdPartyVerification]. */ + class Builder internal constructor() { + + private var reference: JsonField? = null + private var vendor: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(thirdPartyVerification: ThirdPartyVerification) = apply { + reference = thirdPartyVerification.reference + vendor = thirdPartyVerification.vendor + additionalProperties = thirdPartyVerification.additionalProperties.toMutableMap() + } + + /** The reference identifier for the third party verification. */ + fun reference(reference: String) = reference(JsonField.of(reference)) + + /** + * Sets [Builder.reference] to an arbitrary JSON value. + * + * You should usually call [Builder.reference] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reference(reference: JsonField) = apply { this.reference = reference } + + /** The vendor that was used to perform the verification. */ + fun vendor(vendor: Vendor) = vendor(JsonField.of(vendor)) + + /** + * Sets [Builder.vendor] to an arbitrary JSON value. + * + * You should usually call [Builder.vendor] with a well-typed [Vendor] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vendor(vendor: JsonField) = apply { this.vendor = vendor } + + 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 [ThirdPartyVerification]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .reference() + * .vendor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThirdPartyVerification = + ThirdPartyVerification( + checkRequired("reference", reference), + checkRequired("vendor", vendor), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThirdPartyVerification = apply { + if (validated) { + return@apply + } + + reference() + vendor().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (reference.asKnown().isPresent) 1 else 0) + + (vendor.asKnown().getOrNull()?.validity() ?: 0) + + /** The vendor that was used to perform the verification. */ + class Vendor @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + /** Alloy. See https://alloy.com for more information. */ + @JvmField val ALLOY = of("alloy") + + /** Middesk. See https://middesk.com for more information. */ + @JvmField val MIDDESK = of("middesk") + + /** Oscilar. See https://oscilar.com for more information. */ + @JvmField val OSCILAR = of("oscilar") + + @JvmStatic fun of(value: String) = Vendor(JsonField.of(value)) + } + + /** An enum containing [Vendor]'s known values. */ + enum class Known { + /** Alloy. See https://alloy.com for more information. */ + ALLOY, + /** Middesk. See https://middesk.com for more information. */ + MIDDESK, + /** Oscilar. See https://oscilar.com for more information. */ + OSCILAR, + } + + /** + * An enum containing [Vendor]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Vendor] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Alloy. See https://alloy.com for more information. */ + ALLOY, + /** Middesk. See https://middesk.com for more information. */ + MIDDESK, + /** Oscilar. See https://oscilar.com for more information. */ + OSCILAR, + /** + * An enum member indicating that [Vendor] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ALLOY -> Value.ALLOY + MIDDESK -> Value.MIDDESK + OSCILAR -> Value.OSCILAR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALLOY -> Known.ALLOY + MIDDESK -> Known.MIDDESK + OSCILAR -> Known.OSCILAR + else -> throw IncreaseInvalidDataException("Unknown Vendor: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Vendor = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Vendor && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ThirdPartyVerification && + reference == other.reference && + vendor == other.vendor && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(reference, vendor, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThirdPartyVerification{reference=$reference, vendor=$vendor, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EntityUpdateParams && + 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() = + "EntityUpdateParams{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 5152ad677..8c250e1c0 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 @@ -17,6 +17,7 @@ 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 @@ -76,6 +77,38 @@ interface EntityServiceAsync { fun retrieve(entityId: String, requestOptions: RequestOptions): CompletableFuture = retrieve(entityId, EntityRetrieveParams.none(), requestOptions) + /** Update an Entity */ + fun update(entityId: String): CompletableFuture = + update(entityId, EntityUpdateParams.none()) + + /** @see update */ + fun update( + entityId: String, + params: EntityUpdateParams = EntityUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().entityId(entityId).build(), requestOptions) + + /** @see update */ + fun update( + entityId: String, + params: EntityUpdateParams = EntityUpdateParams.none(), + ): CompletableFuture = update(entityId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: EntityUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see update */ + fun update(params: EntityUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(entityId: String, requestOptions: RequestOptions): CompletableFuture = + update(entityId, EntityUpdateParams.none(), requestOptions) + /** List Entities */ fun list(): CompletableFuture = list(EntityListParams.none()) @@ -352,6 +385,45 @@ interface EntityServiceAsync { ): CompletableFuture> = retrieve(entityId, EntityRetrieveParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `patch /entities/{entity_id}`, but is otherwise the same + * as [EntityServiceAsync.update]. + */ + fun update(entityId: String): CompletableFuture> = + update(entityId, EntityUpdateParams.none()) + + /** @see update */ + fun update( + entityId: String, + params: EntityUpdateParams = EntityUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().entityId(entityId).build(), requestOptions) + + /** @see update */ + fun update( + entityId: String, + params: EntityUpdateParams = EntityUpdateParams.none(), + ): CompletableFuture> = + update(entityId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: EntityUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see update */ + fun update(params: EntityUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + entityId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(entityId, EntityUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /entities`, but is otherwise the same as * [EntityServiceAsync.list]. 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 fb805d0c6..3f0ad0bdf 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 @@ -29,6 +29,7 @@ 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 import kotlin.jvm.optionals.getOrNull @@ -59,6 +60,13 @@ class EntityServiceAsyncImpl internal constructor(private val clientOptions: Cli // get /entities/{entity_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + override fun update( + params: EntityUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /entities/{entity_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + override fun list( params: EntityListParams, requestOptions: RequestOptions, @@ -192,6 +200,39 @@ class EntityServiceAsyncImpl internal constructor(private val clientOptions: Cli } } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: EntityUpdateParams, + 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.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("entities", params._pathParam(0)) + .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 { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) 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 97edaf070..30a409ceb 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 @@ -18,6 +18,7 @@ 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 interface EntityService { @@ -72,6 +73,33 @@ interface EntityService { fun retrieve(entityId: String, requestOptions: RequestOptions): Entity = retrieve(entityId, EntityRetrieveParams.none(), requestOptions) + /** Update an Entity */ + fun update(entityId: String): Entity = update(entityId, EntityUpdateParams.none()) + + /** @see update */ + fun update( + entityId: String, + params: EntityUpdateParams = EntityUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Entity = update(params.toBuilder().entityId(entityId).build(), requestOptions) + + /** @see update */ + fun update(entityId: String, params: EntityUpdateParams = EntityUpdateParams.none()): Entity = + update(entityId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: EntityUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Entity + + /** @see update */ + fun update(params: EntityUpdateParams): Entity = update(params, RequestOptions.none()) + + /** @see update */ + fun update(entityId: String, requestOptions: RequestOptions): Entity = + update(entityId, EntityUpdateParams.none(), requestOptions) + /** List Entities */ fun list(): EntityListPage = list(EntityListParams.none()) @@ -328,6 +356,47 @@ interface EntityService { fun retrieve(entityId: String, requestOptions: RequestOptions): HttpResponseFor = retrieve(entityId, EntityRetrieveParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `patch /entities/{entity_id}`, but is otherwise the same + * as [EntityService.update]. + */ + @MustBeClosed + fun update(entityId: String): HttpResponseFor = + update(entityId, EntityUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + entityId: String, + params: EntityUpdateParams = EntityUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().entityId(entityId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + entityId: String, + params: EntityUpdateParams = EntityUpdateParams.none(), + ): HttpResponseFor = update(entityId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: EntityUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see update */ + @MustBeClosed + fun update(params: EntityUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update(entityId: String, requestOptions: RequestOptions): HttpResponseFor = + update(entityId, EntityUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /entities`, but is otherwise the same as * [EntityService.list]. 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 1c61e05ab..efb424b7f 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 @@ -29,6 +29,7 @@ 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 @@ -52,6 +53,10 @@ class EntityServiceImpl internal constructor(private val clientOptions: ClientOp // get /entities/{entity_id} withRawResponse().retrieve(params, requestOptions).parse() + override fun update(params: EntityUpdateParams, requestOptions: RequestOptions): Entity = + // patch /entities/{entity_id} + withRawResponse().update(params, requestOptions).parse() + override fun list(params: EntityListParams, requestOptions: RequestOptions): EntityListPage = // get /entities withRawResponse().list(params, requestOptions).parse() @@ -168,6 +173,36 @@ class EntityServiceImpl internal constructor(private val clientOptions: ClientOp } } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: EntityUpdateParams, + 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.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("entities", params._pathParam(0)) + .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 { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityCreateParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityCreateParamsTest.kt index add6e3334..90ea9c425 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityCreateParamsTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityCreateParamsTest.kt @@ -3,6 +3,7 @@ package com.increase.api.models.entities import java.time.LocalDate +import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -240,6 +241,12 @@ internal class EntityCreateParamsTest { .confirmedNoUsTaxId(true) .build() ) + .riskRating( + EntityCreateParams.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .rating(EntityCreateParams.RiskRating.Rating.LOW) + .build() + ) .addSupplementalDocument( EntityCreateParams.SupplementalDocument.builder() .fileId("file_makxrc67oh9l6sg7w9yc") @@ -638,6 +645,12 @@ internal class EntityCreateParamsTest { .confirmedNoUsTaxId(true) .build() ) + .riskRating( + EntityCreateParams.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .rating(EntityCreateParams.RiskRating.Rating.LOW) + .build() + ) .addSupplementalDocument( EntityCreateParams.SupplementalDocument.builder() .fileId("file_makxrc67oh9l6sg7w9yc") @@ -1030,6 +1043,13 @@ internal class EntityCreateParamsTest { .confirmedNoUsTaxId(true) .build() ) + assertThat(body.riskRating()) + .contains( + EntityCreateParams.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .rating(EntityCreateParams.RiskRating.Rating.LOW) + .build() + ) assertThat(body.supplementalDocuments().getOrNull()) .containsExactly( EntityCreateParams.SupplementalDocument.builder() diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityListPageResponseTest.kt index 084ccebae..7694837e5 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityListPageResponseTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityListPageResponseTest.kt @@ -158,6 +158,12 @@ internal class EntityListPageResponseTest { .name("name") .build() ) + .riskRating( + Entity.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .rating(Entity.RiskRating.Rating.LOW) + .build() + ) .status(Entity.Status.ACTIVE) .structure(Entity.Structure.CORPORATION) .addSupplementalDocument( @@ -399,6 +405,12 @@ internal class EntityListPageResponseTest { .name("name") .build() ) + .riskRating( + Entity.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .rating(Entity.RiskRating.Rating.LOW) + .build() + ) .status(Entity.Status.ACTIVE) .structure(Entity.Structure.CORPORATION) .addSupplementalDocument( @@ -643,6 +655,12 @@ internal class EntityListPageResponseTest { .name("name") .build() ) + .riskRating( + Entity.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .rating(Entity.RiskRating.Rating.LOW) + .build() + ) .status(Entity.Status.ACTIVE) .structure(Entity.Structure.CORPORATION) .addSupplementalDocument( diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityTest.kt index a8a079432..98a84f465 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityTest.kt @@ -154,6 +154,12 @@ internal class EntityTest { .name("name") .build() ) + .riskRating( + Entity.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .rating(Entity.RiskRating.Rating.LOW) + .build() + ) .status(Entity.Status.ACTIVE) .structure(Entity.Structure.CORPORATION) .addSupplementalDocument( @@ -386,6 +392,13 @@ internal class EntityTest { .name("name") .build() ) + assertThat(entity.riskRating()) + .contains( + Entity.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .rating(Entity.RiskRating.Rating.LOW) + .build() + ) assertThat(entity.status()).isEqualTo(Entity.Status.ACTIVE) assertThat(entity.structure()).isEqualTo(Entity.Structure.CORPORATION) assertThat(entity.supplementalDocuments()) @@ -624,6 +637,12 @@ internal class EntityTest { .name("name") .build() ) + .riskRating( + Entity.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .rating(Entity.RiskRating.Rating.LOW) + .build() + ) .status(Entity.Status.ACTIVE) .structure(Entity.Structure.CORPORATION) .addSupplementalDocument( diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityUpdateParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityUpdateParamsTest.kt new file mode 100644 index 000000000..6073d8e72 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/entities/EntityUpdateParamsTest.kt @@ -0,0 +1,82 @@ +// 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 EntityUpdateParamsTest { + + @Test + fun create() { + EntityUpdateParams.builder() + .entityId("entity_n8y8tnk2p9339ti393yi") + .riskRating( + EntityUpdateParams.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .rating(EntityUpdateParams.RiskRating.Rating.LOW) + .build() + ) + .thirdPartyVerification( + EntityUpdateParams.ThirdPartyVerification.builder() + .reference("x") + .vendor(EntityUpdateParams.ThirdPartyVerification.Vendor.ALLOY) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = EntityUpdateParams.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 = + EntityUpdateParams.builder() + .entityId("entity_n8y8tnk2p9339ti393yi") + .riskRating( + EntityUpdateParams.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .rating(EntityUpdateParams.RiskRating.Rating.LOW) + .build() + ) + .thirdPartyVerification( + EntityUpdateParams.ThirdPartyVerification.builder() + .reference("x") + .vendor(EntityUpdateParams.ThirdPartyVerification.Vendor.ALLOY) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.riskRating()) + .contains( + EntityUpdateParams.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .rating(EntityUpdateParams.RiskRating.Rating.LOW) + .build() + ) + assertThat(body.thirdPartyVerification()) + .contains( + EntityUpdateParams.ThirdPartyVerification.builder() + .reference("x") + .vendor(EntityUpdateParams.ThirdPartyVerification.Vendor.ALLOY) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = EntityUpdateParams.builder().entityId("entity_n8y8tnk2p9339ti393yi").build() + + val body = params._body() + } +} 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 d4deaa104..9654830af 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 @@ -11,6 +11,7 @@ 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 import org.junit.jupiter.api.Test @@ -280,6 +281,12 @@ internal class EntityServiceAsyncTest { .confirmedNoUsTaxId(true) .build() ) + .riskRating( + EntityCreateParams.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .rating(EntityCreateParams.RiskRating.Rating.LOW) + .build() + ) .addSupplementalDocument( EntityCreateParams.SupplementalDocument.builder() .fileId("file_makxrc67oh9l6sg7w9yc") @@ -463,6 +470,38 @@ internal class EntityServiceAsyncTest { entity.validate() } + @Test + fun update() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val entityServiceAsync = client.entities() + + val entityFuture = + entityServiceAsync.update( + EntityUpdateParams.builder() + .entityId("entity_n8y8tnk2p9339ti393yi") + .riskRating( + EntityUpdateParams.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .rating(EntityUpdateParams.RiskRating.Rating.LOW) + .build() + ) + .thirdPartyVerification( + EntityUpdateParams.ThirdPartyVerification.builder() + .reference("x") + .vendor(EntityUpdateParams.ThirdPartyVerification.Vendor.ALLOY) + .build() + ) + .build() + ) + + val entity = entityFuture.get() + entity.validate() + } + @Test fun list() { val client = 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 b7858c6ad..466488677 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 @@ -11,6 +11,7 @@ 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 import org.junit.jupiter.api.Test @@ -280,6 +281,12 @@ internal class EntityServiceTest { .confirmedNoUsTaxId(true) .build() ) + .riskRating( + EntityCreateParams.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .rating(EntityCreateParams.RiskRating.Rating.LOW) + .build() + ) .addSupplementalDocument( EntityCreateParams.SupplementalDocument.builder() .fileId("file_makxrc67oh9l6sg7w9yc") @@ -461,6 +468,37 @@ internal class EntityServiceTest { entity.validate() } + @Test + fun update() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val entityService = client.entities() + + val entity = + entityService.update( + EntityUpdateParams.builder() + .entityId("entity_n8y8tnk2p9339ti393yi") + .riskRating( + EntityUpdateParams.RiskRating.builder() + .ratedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .rating(EntityUpdateParams.RiskRating.Rating.LOW) + .build() + ) + .thirdPartyVerification( + EntityUpdateParams.ThirdPartyVerification.builder() + .reference("x") + .vendor(EntityUpdateParams.ThirdPartyVerification.Vendor.ALLOY) + .build() + ) + .build() + ) + + entity.validate() + } + @Test fun list() { val client =