diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 01f6bba7..6e39864d 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "7.7.0" + ".": "7.8.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 0092e6cf..909df852 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 45 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch/finch-f17b0106d5004cf7339990dd9a9d60dc183ed38051a862db3855fb9d953fbbf8.yml +configured_endpoints: 48 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch/finch-5092370ef89959c46138a85f9d6d3c919682a5492a0f9f85ac4421de702f35a8.yml openapi_spec_hash: a4ca94b3405fc83934c949068943e16c -config_hash: ae896fec93ebd7c3bc1a6c4d6d9880ff +config_hash: a1c4b7d897cbf8ed42c5f474b3161d79 diff --git a/CHANGELOG.md b/CHANGELOG.md index 7831410d..8358e393 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 7.8.0 (2026-05-12) + +Full Changelog: [v7.7.0...v7.8.0](https://github.com/Finch-API/finch-api-java/compare/v7.7.0...v7.8.0) + +### Features + +* **api:** add register benefits method ([6e858e5](https://github.com/Finch-API/finch-api-java/commit/6e858e5cf21cc0a006e19444192ac43a2948f781)) +* **api:** manual updates ([ad2d05d](https://github.com/Finch-API/finch-api-java/commit/ad2d05dfca49f26443d904e242b7eea45a79fcb9)) + ## 7.7.0 (2026-05-12) Full Changelog: [v7.6.0...v7.7.0](https://github.com/Finch-API/finch-api-java/compare/v7.6.0...v7.7.0) diff --git a/README.md b/README.md index 12df0aa6..5bf309db 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/7.7.0) -[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-java/7.7.0/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.7.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/7.8.0) +[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-java/7.8.0/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.8.0) @@ -24,7 +24,7 @@ Use the Finch MCP Server to enable AI assistants to interact with this API, allo -The REST API documentation can be found on [developer.tryfinch.com](https://developer.tryfinch.com/). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.7.0). +The REST API documentation can be found on [developer.tryfinch.com](https://developer.tryfinch.com/). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.8.0). @@ -35,7 +35,7 @@ The REST API documentation can be found on [developer.tryfinch.com](https://deve ### Gradle ```kotlin -implementation("com.tryfinch.api:finch-java:7.7.0") +implementation("com.tryfinch.api:finch-java:7.8.0") ``` ### Maven @@ -44,7 +44,7 @@ implementation("com.tryfinch.api:finch-java:7.7.0") com.tryfinch.api finch-java - 7.7.0 + 7.8.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 83fd3d1c..e67a9fe5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.tryfinch.api" - version = "7.7.0" // x-release-please-version + version = "7.8.0" // x-release-please-version } subprojects { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountDisconnectEntityParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountDisconnectEntityParams.kt new file mode 100644 index 00000000..d3a77e94 --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountDisconnectEntityParams.kt @@ -0,0 +1,460 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +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.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.Params +import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.http.Headers +import com.tryfinch.api.core.http.QueryParams +import com.tryfinch.api.core.toImmutable +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** + * Disconnect entity(s) from a connection without affecting other entities associated with the same + * connection. + */ +class AccountDisconnectEntityParams +private constructor( + private val body: DisconnectEntityRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Array of entity UUIDs to disconnect. At least one entity ID must be provided. + * + * @throws FinchInvalidDataException 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 entityIds(): List = body.entityIds() + + /** + * Returns the raw JSON value of [entityIds]. + * + * Unlike [entityIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _entityIds(): JsonField> = body._entityIds() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AccountDisconnectEntityParams]. + * + * The following fields are required: + * ```java + * .entityIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountDisconnectEntityParams]. */ + class Builder internal constructor() { + + private var body: DisconnectEntityRequest.Builder = DisconnectEntityRequest.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(accountDisconnectEntityParams: AccountDisconnectEntityParams) = apply { + body = accountDisconnectEntityParams.body.toBuilder() + additionalHeaders = accountDisconnectEntityParams.additionalHeaders.toBuilder() + additionalQueryParams = accountDisconnectEntityParams.additionalQueryParams.toBuilder() + } + + /** + * 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: + * - [entityIds] + */ + fun body(body: DisconnectEntityRequest) = apply { this.body = body.toBuilder() } + + /** Array of entity UUIDs to disconnect. At least one entity ID must be provided. */ + fun entityIds(entityIds: List) = apply { body.entityIds(entityIds) } + + /** + * Sets [Builder.entityIds] to an arbitrary JSON value. + * + * You should usually call [Builder.entityIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun entityIds(entityIds: JsonField>) = apply { body.entityIds(entityIds) } + + /** + * Adds a single [String] to [entityIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEntityId(entityId: String) = apply { body.addEntityId(entityId) } + + 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 [AccountDisconnectEntityParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entityIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AccountDisconnectEntityParams = + AccountDisconnectEntityParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): DisconnectEntityRequest = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class DisconnectEntityRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val entityIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("entity_ids") + @ExcludeMissing + entityIds: JsonField> = JsonMissing.of() + ) : this(entityIds, mutableMapOf()) + + /** + * Array of entity UUIDs to disconnect. At least one entity ID must be provided. + * + * @throws FinchInvalidDataException 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 entityIds(): List = entityIds.getRequired("entity_ids") + + /** + * Returns the raw JSON value of [entityIds]. + * + * Unlike [entityIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entity_ids") + @ExcludeMissing + fun _entityIds(): JsonField> = entityIds + + @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 [DisconnectEntityRequest]. + * + * The following fields are required: + * ```java + * .entityIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DisconnectEntityRequest]. */ + class Builder internal constructor() { + + private var entityIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(disconnectEntityRequest: DisconnectEntityRequest) = apply { + entityIds = disconnectEntityRequest.entityIds.map { it.toMutableList() } + additionalProperties = disconnectEntityRequest.additionalProperties.toMutableMap() + } + + /** Array of entity UUIDs to disconnect. At least one entity ID must be provided. */ + fun entityIds(entityIds: List) = entityIds(JsonField.of(entityIds)) + + /** + * Sets [Builder.entityIds] to an arbitrary JSON value. + * + * You should usually call [Builder.entityIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun entityIds(entityIds: JsonField>) = apply { + this.entityIds = entityIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [entityIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEntityId(entityId: String) = apply { + entityIds = + (entityIds ?: JsonField.of(mutableListOf())).also { + checkKnown("entityIds", it).add(entityId) + } + } + + 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 [DisconnectEntityRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .entityIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DisconnectEntityRequest = + DisconnectEntityRequest( + checkRequired("entityIds", entityIds).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws FinchInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): DisconnectEntityRequest = apply { + if (validated) { + return@apply + } + + entityIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + 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 = (entityIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DisconnectEntityRequest && + entityIds == other.entityIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(entityIds, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DisconnectEntityRequest{entityIds=$entityIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccountDisconnectEntityParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AccountDisconnectEntityParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DisconnectEntityResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DisconnectEntityResponse.kt new file mode 100644 index 00000000..426f6dba --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DisconnectEntityResponse.kt @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +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.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects + +class DisconnectEntityResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of() + ) : this(status, mutableMapOf()) + + /** + * If the request is successful, Finch will return "success" (HTTP 200 status). + * + * @throws FinchInvalidDataException 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 status(): String = status.getRequired("status") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @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 [DisconnectEntityResponse]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DisconnectEntityResponse]. */ + class Builder internal constructor() { + + private var status: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(disconnectEntityResponse: DisconnectEntityResponse) = apply { + status = disconnectEntityResponse.status + additionalProperties = disconnectEntityResponse.additionalProperties.toMutableMap() + } + + /** If the request is successful, Finch will return "success" (HTTP 200 status). */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + 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 [DisconnectEntityResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DisconnectEntityResponse = + DisconnectEntityResponse( + checkRequired("status", status), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws FinchInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): DisconnectEntityResponse = apply { + if (validated) { + return@apply + } + + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + 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 (status.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DisconnectEntityResponse && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DisconnectEntityResponse{status=$status, additionalProperties=$additionalProperties}" +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualEnrollManyParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualEnrollManyParams.kt new file mode 100644 index 00000000..ecbfe45c --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualEnrollManyParams.kt @@ -0,0 +1,2022 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +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.tryfinch.api.core.Enum +import com.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.Params +import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.http.Headers +import com.tryfinch.api.core.http.QueryParams +import com.tryfinch.api.core.toImmutable +import com.tryfinch.api.errors.FinchInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Enroll an individual into a deduction or contribution. This is an overwrite operation. If the + * employee is already enrolled, the enrollment amounts will be adjusted. Making the same request + * multiple times will not create new enrollments, but will continue to set the state of the + * existing enrollment. + */ +class HrisBenefitIndividualEnrollManyParams +private constructor( + private val benefitId: String?, + private val entityIds: List?, + private val individuals: List?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun benefitId(): Optional = Optional.ofNullable(benefitId) + + /** The entity IDs to specify which entities' data to access. */ + fun entityIds(): Optional> = Optional.ofNullable(entityIds) + + /** Array of the individual_id to enroll and a configuration object. */ + fun individuals(): Optional> = Optional.ofNullable(individuals) + + /** 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(): HrisBenefitIndividualEnrollManyParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [HrisBenefitIndividualEnrollManyParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisBenefitIndividualEnrollManyParams]. */ + class Builder internal constructor() { + + private var benefitId: String? = null + private var entityIds: MutableList? = null + private var individuals: MutableList? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + hrisBenefitIndividualEnrollManyParams: HrisBenefitIndividualEnrollManyParams + ) = apply { + benefitId = hrisBenefitIndividualEnrollManyParams.benefitId + entityIds = hrisBenefitIndividualEnrollManyParams.entityIds?.toMutableList() + individuals = hrisBenefitIndividualEnrollManyParams.individuals?.toMutableList() + additionalHeaders = hrisBenefitIndividualEnrollManyParams.additionalHeaders.toBuilder() + additionalQueryParams = + hrisBenefitIndividualEnrollManyParams.additionalQueryParams.toBuilder() + } + + fun benefitId(benefitId: String?) = apply { this.benefitId = benefitId } + + /** Alias for calling [Builder.benefitId] with `benefitId.orElse(null)`. */ + fun benefitId(benefitId: Optional) = benefitId(benefitId.getOrNull()) + + /** The entity IDs to specify which entities' data to access. */ + fun entityIds(entityIds: List?) = apply { + this.entityIds = entityIds?.toMutableList() + } + + /** Alias for calling [Builder.entityIds] with `entityIds.orElse(null)`. */ + fun entityIds(entityIds: Optional>) = entityIds(entityIds.getOrNull()) + + /** + * Adds a single [String] to [entityIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEntityId(entityId: String) = apply { + entityIds = (entityIds ?: mutableListOf()).apply { add(entityId) } + } + + /** Array of the individual_id to enroll and a configuration object. */ + fun individuals(individuals: List?) = apply { + this.individuals = individuals?.toMutableList() + } + + /** Alias for calling [Builder.individuals] with `individuals.orElse(null)`. */ + fun individuals(individuals: Optional>) = + individuals(individuals.getOrNull()) + + /** + * Adds a single [Individual] to [individuals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIndividual(individual: Individual) = apply { + individuals = (individuals ?: mutableListOf()).apply { add(individual) } + } + + 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 [HrisBenefitIndividualEnrollManyParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): HrisBenefitIndividualEnrollManyParams = + HrisBenefitIndividualEnrollManyParams( + benefitId, + entityIds?.toImmutable(), + individuals?.toImmutable(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Optional> = Optional.ofNullable(individuals) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> benefitId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + entityIds?.forEach { put("entity_ids[]", it) } + putAll(additionalQueryParams) + } + .build() + + class Individual + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val configuration: JsonField, + private val individualId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("configuration") + @ExcludeMissing + configuration: JsonField = JsonMissing.of(), + @JsonProperty("individual_id") + @ExcludeMissing + individualId: JsonField = JsonMissing.of(), + ) : this(configuration, individualId, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun configuration(): Optional = configuration.getOptional("configuration") + + /** + * Finch id (uuidv4) for the individual to enroll + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun individualId(): Optional = individualId.getOptional("individual_id") + + /** + * Returns the raw JSON value of [configuration]. + * + * Unlike [configuration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("configuration") + @ExcludeMissing + fun _configuration(): JsonField = configuration + + /** + * Returns the raw JSON value of [individualId]. + * + * Unlike [individualId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Individual]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Individual]. */ + class Builder internal constructor() { + + private var configuration: JsonField = JsonMissing.of() + private var individualId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(individual: Individual) = apply { + configuration = individual.configuration + individualId = individual.individualId + additionalProperties = individual.additionalProperties.toMutableMap() + } + + fun configuration(configuration: Configuration) = + configuration(JsonField.of(configuration)) + + /** + * Sets [Builder.configuration] to an arbitrary JSON value. + * + * You should usually call [Builder.configuration] with a well-typed [Configuration] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun configuration(configuration: JsonField) = apply { + this.configuration = configuration + } + + /** Finch id (uuidv4) for the individual to enroll */ + fun individualId(individualId: String) = individualId(JsonField.of(individualId)) + + /** + * Sets [Builder.individualId] to an arbitrary JSON value. + * + * You should usually call [Builder.individualId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun individualId(individualId: JsonField) = apply { + this.individualId = individualId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Individual]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Individual = + Individual(configuration, individualId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws FinchInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Individual = apply { + if (validated) { + return@apply + } + + configuration().ifPresent { it.validate() } + individualId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + 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 = + (configuration.asKnown().getOrNull()?.validity() ?: 0) + + (if (individualId.asKnown().isPresent) 1 else 0) + + class Configuration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val annualContributionLimit: JsonField, + private val annualMaximum: JsonField, + private val catchUp: JsonField, + private val companyContribution: JsonField, + private val effectiveDate: JsonField, + private val employeeDeduction: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("annual_contribution_limit") + @ExcludeMissing + annualContributionLimit: JsonField = JsonMissing.of(), + @JsonProperty("annual_maximum") + @ExcludeMissing + annualMaximum: JsonField = JsonMissing.of(), + @JsonProperty("catch_up") + @ExcludeMissing + catchUp: JsonField = JsonMissing.of(), + @JsonProperty("company_contribution") + @ExcludeMissing + companyContribution: JsonField = JsonMissing.of(), + @JsonProperty("effective_date") + @ExcludeMissing + effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("employee_deduction") + @ExcludeMissing + employeeDeduction: JsonField = JsonMissing.of(), + ) : this( + annualContributionLimit, + annualMaximum, + catchUp, + companyContribution, + effectiveDate, + employeeDeduction, + mutableMapOf(), + ) + + /** + * For HSA benefits only - whether the contribution limit is for an individual or family + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun annualContributionLimit(): Optional = + annualContributionLimit.getOptional("annual_contribution_limit") + + /** + * Maximum annual amount in cents + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun annualMaximum(): Optional = annualMaximum.getOptional("annual_maximum") + + /** + * For retirement benefits only - whether catch up contributions are enabled + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun catchUp(): Optional = catchUp.getOptional("catch_up") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun companyContribution(): Optional = + companyContribution.getOptional("company_contribution") + + /** + * The date the enrollment will take effect + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun effectiveDate(): Optional = effectiveDate.getOptional("effective_date") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun employeeDeduction(): Optional = + employeeDeduction.getOptional("employee_deduction") + + /** + * Returns the raw JSON value of [annualContributionLimit]. + * + * Unlike [annualContributionLimit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("annual_contribution_limit") + @ExcludeMissing + fun _annualContributionLimit(): JsonField = + annualContributionLimit + + /** + * Returns the raw JSON value of [annualMaximum]. + * + * Unlike [annualMaximum], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("annual_maximum") + @ExcludeMissing + fun _annualMaximum(): JsonField = annualMaximum + + /** + * Returns the raw JSON value of [catchUp]. + * + * Unlike [catchUp], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("catch_up") @ExcludeMissing fun _catchUp(): JsonField = catchUp + + /** + * Returns the raw JSON value of [companyContribution]. + * + * Unlike [companyContribution], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("company_contribution") + @ExcludeMissing + fun _companyContribution(): JsonField = companyContribution + + /** + * Returns the raw JSON value of [effectiveDate]. + * + * Unlike [effectiveDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate + + /** + * Returns the raw JSON value of [employeeDeduction]. + * + * Unlike [employeeDeduction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("employee_deduction") + @ExcludeMissing + fun _employeeDeduction(): JsonField = employeeDeduction + + @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 [Configuration]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Configuration]. */ + class Builder internal constructor() { + + private var annualContributionLimit: JsonField = + JsonMissing.of() + private var annualMaximum: JsonField = JsonMissing.of() + private var catchUp: JsonField = JsonMissing.of() + private var companyContribution: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var employeeDeduction: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(configuration: Configuration) = apply { + annualContributionLimit = configuration.annualContributionLimit + annualMaximum = configuration.annualMaximum + catchUp = configuration.catchUp + companyContribution = configuration.companyContribution + effectiveDate = configuration.effectiveDate + employeeDeduction = configuration.employeeDeduction + additionalProperties = configuration.additionalProperties.toMutableMap() + } + + /** + * For HSA benefits only - whether the contribution limit is for an individual or + * family + */ + fun annualContributionLimit(annualContributionLimit: AnnualContributionLimit) = + annualContributionLimit(JsonField.of(annualContributionLimit)) + + /** + * Sets [Builder.annualContributionLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.annualContributionLimit] with a well-typed + * [AnnualContributionLimit] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun annualContributionLimit( + annualContributionLimit: JsonField + ) = apply { this.annualContributionLimit = annualContributionLimit } + + /** Maximum annual amount in cents */ + fun annualMaximum(annualMaximum: Long?) = + annualMaximum(JsonField.ofNullable(annualMaximum)) + + /** + * Alias for [Builder.annualMaximum]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun annualMaximum(annualMaximum: Long) = annualMaximum(annualMaximum as Long?) + + /** Alias for calling [Builder.annualMaximum] with `annualMaximum.orElse(null)`. */ + fun annualMaximum(annualMaximum: Optional) = + annualMaximum(annualMaximum.getOrNull()) + + /** + * Sets [Builder.annualMaximum] to an arbitrary JSON value. + * + * You should usually call [Builder.annualMaximum] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun annualMaximum(annualMaximum: JsonField) = apply { + this.annualMaximum = annualMaximum + } + + /** For retirement benefits only - whether catch up contributions are enabled */ + fun catchUp(catchUp: Boolean) = catchUp(JsonField.of(catchUp)) + + /** + * Sets [Builder.catchUp] to an arbitrary JSON value. + * + * You should usually call [Builder.catchUp] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun catchUp(catchUp: JsonField) = apply { this.catchUp = catchUp } + + fun companyContribution(companyContribution: CompanyContribution) = + companyContribution(JsonField.of(companyContribution)) + + /** + * Sets [Builder.companyContribution] to an arbitrary JSON value. + * + * You should usually call [Builder.companyContribution] with a well-typed + * [CompanyContribution] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun companyContribution(companyContribution: JsonField) = + apply { + this.companyContribution = companyContribution + } + + /** The date the enrollment will take effect */ + fun effectiveDate(effectiveDate: LocalDate) = + effectiveDate(JsonField.of(effectiveDate)) + + /** + * Sets [Builder.effectiveDate] to an arbitrary JSON value. + * + * You should usually call [Builder.effectiveDate] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + + fun employeeDeduction(employeeDeduction: EmployeeDeduction) = + employeeDeduction(JsonField.of(employeeDeduction)) + + /** + * Sets [Builder.employeeDeduction] to an arbitrary JSON value. + * + * You should usually call [Builder.employeeDeduction] with a well-typed + * [EmployeeDeduction] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun employeeDeduction(employeeDeduction: JsonField) = apply { + this.employeeDeduction = employeeDeduction + } + + 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 [Configuration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Configuration = + Configuration( + annualContributionLimit, + annualMaximum, + catchUp, + companyContribution, + effectiveDate, + employeeDeduction, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws FinchInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Configuration = apply { + if (validated) { + return@apply + } + + annualContributionLimit().ifPresent { it.validate() } + annualMaximum() + catchUp() + companyContribution().ifPresent { it.validate() } + effectiveDate() + employeeDeduction().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + 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 = + (annualContributionLimit.asKnown().getOrNull()?.validity() ?: 0) + + (if (annualMaximum.asKnown().isPresent) 1 else 0) + + (if (catchUp.asKnown().isPresent) 1 else 0) + + (companyContribution.asKnown().getOrNull()?.validity() ?: 0) + + (if (effectiveDate.asKnown().isPresent) 1 else 0) + + (employeeDeduction.asKnown().getOrNull()?.validity() ?: 0) + + /** + * For HSA benefits only - whether the contribution limit is for an individual or family + */ + class AnnualContributionLimit + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val INDIVIDUAL = of("individual") + + @JvmField val FAMILY = of("family") + + @JvmStatic fun of(value: String) = AnnualContributionLimit(JsonField.of(value)) + } + + /** An enum containing [AnnualContributionLimit]'s known values. */ + enum class Known { + INDIVIDUAL, + FAMILY, + } + + /** + * An enum containing [AnnualContributionLimit]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AnnualContributionLimit] 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 { + INDIVIDUAL, + FAMILY, + /** + * An enum member indicating that [AnnualContributionLimit] 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) { + INDIVIDUAL -> Value.INDIVIDUAL + FAMILY -> Value.FAMILY + 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 FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INDIVIDUAL -> Known.INDIVIDUAL + FAMILY -> Known.FAMILY + else -> + throw FinchInvalidDataException( + "Unknown AnnualContributionLimit: $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 FinchInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws FinchInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): AnnualContributionLimit = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + 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 AnnualContributionLimit && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class CompanyContribution + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val tiers: JsonField>, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("tiers") + @ExcludeMissing + tiers: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(amount, tiers, type, mutableMapOf()) + + /** + * Amount in cents for fixed type or basis points (1/100th of a percent) for percent + * type + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * Array of tier objects for tiered contribution matching (required when type is + * tiered) + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tiers(): Optional> = tiers.getOptional("tiers") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [tiers]. + * + * Unlike [tiers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CompanyContribution]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompanyContribution]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var tiers: JsonField>? = null + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(companyContribution: CompanyContribution) = apply { + amount = companyContribution.amount + tiers = companyContribution.tiers.map { it.toMutableList() } + type = companyContribution.type + additionalProperties = + companyContribution.additionalProperties.toMutableMap() + } + + /** + * Amount in cents for fixed type or basis points (1/100th of a percent) for + * percent type + */ + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** + * Array of tier objects for tiered contribution matching (required when type is + * tiered) + */ + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Sets [Builder.tiers] to an arbitrary JSON value. + * + * You should usually call [Builder.tiers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Adds a single [Tier] to [tiers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).also { + checkKnown("tiers", it).add(tier) + } + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CompanyContribution]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CompanyContribution = + CompanyContribution( + amount, + (tiers ?: JsonMissing.of()).map { it.toImmutable() }, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws FinchInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CompanyContribution = apply { + if (validated) { + return@apply + } + + amount() + tiers().ifPresent { it.forEach { it.validate() } } + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + 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 (amount.asKnown().isPresent) 1 else 0) + + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val match: JsonField, + private val threshold: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("match") + @ExcludeMissing + match: JsonField = JsonMissing.of(), + @JsonProperty("threshold") + @ExcludeMissing + threshold: JsonField = JsonMissing.of(), + ) : this(match, threshold, mutableMapOf()) + + /** + * The employer match percentage in basis points (0-10000 = 0-100%) + * + * @throws FinchInvalidDataException 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 match(): Long = match.getRequired("match") + + /** + * The employee contribution threshold in basis points (0-10000 = 0-100%) + * + * @throws FinchInvalidDataException 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 threshold(): Long = threshold.getRequired("threshold") + + /** + * Returns the raw JSON value of [match]. + * + * Unlike [match], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("match") @ExcludeMissing fun _match(): JsonField = match + + /** + * Returns the raw JSON value of [threshold]. + * + * Unlike [threshold], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("threshold") + @ExcludeMissing + fun _threshold(): JsonField = threshold + + @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 [Tier]. + * + * The following fields are required: + * ```java + * .match() + * .threshold() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var match: JsonField? = null + private var threshold: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + match = tier.match + threshold = tier.threshold + additionalProperties = tier.additionalProperties.toMutableMap() + } + + /** The employer match percentage in basis points (0-10000 = 0-100%) */ + fun match(match: Long) = match(JsonField.of(match)) + + /** + * Sets [Builder.match] to an arbitrary JSON value. + * + * You should usually call [Builder.match] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun match(match: JsonField) = apply { this.match = match } + + /** + * The employee contribution threshold in basis points (0-10000 = 0-100%) + */ + fun threshold(threshold: Long) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun threshold(threshold: JsonField) = apply { + this.threshold = threshold + } + + 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 [Tier]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .match() + * .threshold() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tier = + Tier( + checkRequired("match", match), + checkRequired("threshold", threshold), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws FinchInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Tier = apply { + if (validated) { + return@apply + } + + match() + threshold() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + 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 (match.asKnown().isPresent) 1 else 0) + + (if (threshold.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tier && + match == other.match && + threshold == other.threshold && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(match, threshold, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tier{match=$match, threshold=$threshold, additionalProperties=$additionalProperties}" + } + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val FIXED = of("fixed") + + @JvmField val PERCENT = of("percent") + + @JvmField val TIERED = of("tiered") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + FIXED, + PERCENT, + TIERED, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FIXED, + PERCENT, + TIERED, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FIXED -> Value.FIXED + PERCENT -> Value.PERCENT + TIERED -> Value.TIERED + 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 FinchInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + FIXED -> Known.FIXED + PERCENT -> Known.PERCENT + TIERED -> Known.TIERED + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws FinchInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompanyContribution && + amount == other.amount && + tiers == other.tiers && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, tiers, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompanyContribution{amount=$amount, tiers=$tiers, type=$type, additionalProperties=$additionalProperties}" + } + + class EmployeeDeduction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(amount, type, mutableMapOf()) + + /** + * Amount in cents for fixed type or basis points (1/100th of a percent) for percent + * type + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EmployeeDeduction]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmployeeDeduction]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(employeeDeduction: EmployeeDeduction) = apply { + amount = employeeDeduction.amount + type = employeeDeduction.type + additionalProperties = employeeDeduction.additionalProperties.toMutableMap() + } + + /** + * Amount in cents for fixed type or basis points (1/100th of a percent) for + * percent type + */ + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EmployeeDeduction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EmployeeDeduction = + EmployeeDeduction(amount, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws FinchInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): EmployeeDeduction = apply { + if (validated) { + return@apply + } + + amount() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + 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 (amount.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val FIXED = of("fixed") + + @JvmField val PERCENT = of("percent") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + FIXED, + PERCENT, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FIXED, + PERCENT, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FIXED -> Value.FIXED + PERCENT -> Value.PERCENT + 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 FinchInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + FIXED -> Known.FIXED + PERCENT -> Known.PERCENT + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws FinchInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EmployeeDeduction && + amount == other.amount && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EmployeeDeduction{amount=$amount, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Configuration && + annualContributionLimit == other.annualContributionLimit && + annualMaximum == other.annualMaximum && + catchUp == other.catchUp && + companyContribution == other.companyContribution && + effectiveDate == other.effectiveDate && + employeeDeduction == other.employeeDeduction && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + annualContributionLimit, + annualMaximum, + catchUp, + companyContribution, + effectiveDate, + employeeDeduction, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Configuration{annualContributionLimit=$annualContributionLimit, annualMaximum=$annualMaximum, catchUp=$catchUp, companyContribution=$companyContribution, effectiveDate=$effectiveDate, employeeDeduction=$employeeDeduction, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Individual && + configuration == other.configuration && + individualId == other.individualId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(configuration, individualId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Individual{configuration=$configuration, individualId=$individualId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is HrisBenefitIndividualEnrollManyParams && + benefitId == other.benefitId && + entityIds == other.entityIds && + individuals == other.individuals && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(benefitId, entityIds, individuals, additionalHeaders, additionalQueryParams) + + override fun toString() = + "HrisBenefitIndividualEnrollManyParams{benefitId=$benefitId, entityIds=$entityIds, individuals=$individuals, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitRegisterParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitRegisterParams.kt new file mode 100644 index 00000000..05501115 --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitRegisterParams.kt @@ -0,0 +1,584 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +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.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.Params +import com.tryfinch.api.core.http.Headers +import com.tryfinch.api.core.http.QueryParams +import com.tryfinch.api.core.toImmutable +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Register existing benefits from the customer on the provider, on Finch's end. Please use the + * `/provider` endpoint to view available types for each provider. + */ +class HrisBenefitRegisterParams +private constructor( + private val entityIds: List?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The entity IDs to specify which entities' data to access. */ + fun entityIds(): Optional> = Optional.ofNullable(entityIds) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = body.description() + + /** + * The frequency of the benefit deduction/contribution. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun frequency(): Optional = body.frequency() + + /** + * Type of benefit. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = body.type() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField = body._description() + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _frequency(): JsonField = body._frequency() + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _type(): JsonField = body._type() + + 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(): HrisBenefitRegisterParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [HrisBenefitRegisterParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisBenefitRegisterParams]. */ + class Builder internal constructor() { + + private var entityIds: MutableList? = 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(hrisBenefitRegisterParams: HrisBenefitRegisterParams) = apply { + entityIds = hrisBenefitRegisterParams.entityIds?.toMutableList() + body = hrisBenefitRegisterParams.body.toBuilder() + additionalHeaders = hrisBenefitRegisterParams.additionalHeaders.toBuilder() + additionalQueryParams = hrisBenefitRegisterParams.additionalQueryParams.toBuilder() + } + + /** The entity IDs to specify which entities' data to access. */ + fun entityIds(entityIds: List?) = apply { + this.entityIds = entityIds?.toMutableList() + } + + /** Alias for calling [Builder.entityIds] with `entityIds.orElse(null)`. */ + fun entityIds(entityIds: Optional>) = entityIds(entityIds.getOrNull()) + + /** + * Adds a single [String] to [entityIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEntityId(entityId: String) = apply { + entityIds = (entityIds ?: mutableListOf()).apply { add(entityId) } + } + + /** + * 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: + * - [description] + * - [frequency] + * - [type] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun description(description: String) = apply { body.description(description) } + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { body.description(description) } + + /** The frequency of the benefit deduction/contribution. */ + fun frequency(frequency: BenefitFrequency?) = apply { body.frequency(frequency) } + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [BenefitFrequency] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun frequency(frequency: JsonField) = apply { body.frequency(frequency) } + + /** Type of benefit. */ + fun type(type: BenefitType?) = apply { body.type(type) } + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [BenefitType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { body.type(type) } + + 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 [HrisBenefitRegisterParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): HrisBenefitRegisterParams = + HrisBenefitRegisterParams( + entityIds?.toImmutable(), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + entityIds?.forEach { put("entity_ids[]", it) } + putAll(additionalQueryParams) + } + .build() + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField, + private val frequency: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + frequency: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(description, frequency, type, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The frequency of the benefit deduction/contribution. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun frequency(): Optional = frequency.getOptional("frequency") + + /** + * Type of benefit. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [frequency]. + * + * Unlike [frequency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var description: JsonField = JsonMissing.of() + private var frequency: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + description = body.description + frequency = body.frequency + type = body.type + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** The frequency of the benefit deduction/contribution. */ + fun frequency(frequency: BenefitFrequency?) = frequency(JsonField.ofNullable(frequency)) + + /** Alias for calling [Builder.frequency] with `frequency.orElse(null)`. */ + fun frequency(frequency: Optional) = frequency(frequency.getOrNull()) + + /** + * Sets [Builder.frequency] to an arbitrary JSON value. + * + * You should usually call [Builder.frequency] with a well-typed [BenefitFrequency] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + + /** Type of benefit. */ + fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [BenefitType] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body(description, frequency, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws FinchInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + description() + frequency().ifPresent { it.validate() } + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + 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 (description.asKnown().isPresent) 1 else 0) + + (frequency.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + description == other.description && + frequency == other.frequency && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(description, frequency, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{description=$description, frequency=$frequency, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is HrisBenefitRegisterParams && + entityIds == other.entityIds && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(entityIds, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "HrisBenefitRegisterParams{entityIds=$entityIds, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RegisterCompanyBenefitResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RegisterCompanyBenefitResponse.kt new file mode 100644 index 00000000..d32273ff --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RegisterCompanyBenefitResponse.kt @@ -0,0 +1,218 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +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.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects + +class RegisterCompanyBenefitResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val benefitId: JsonField, + private val jobId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("benefit_id") @ExcludeMissing benefitId: JsonField = JsonMissing.of(), + @JsonProperty("job_id") @ExcludeMissing jobId: JsonField = JsonMissing.of(), + ) : this(benefitId, jobId, mutableMapOf()) + + /** + * The id of the benefit. + * + * @throws FinchInvalidDataException 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 benefitId(): String = benefitId.getRequired("benefit_id") + + /** + * @throws FinchInvalidDataException 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 jobId(): String = jobId.getRequired("job_id") + + /** + * Returns the raw JSON value of [benefitId]. + * + * Unlike [benefitId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("benefit_id") @ExcludeMissing fun _benefitId(): JsonField = benefitId + + /** + * Returns the raw JSON value of [jobId]. + * + * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("job_id") @ExcludeMissing fun _jobId(): JsonField = jobId + + @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 + * [RegisterCompanyBenefitResponse]. + * + * The following fields are required: + * ```java + * .benefitId() + * .jobId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RegisterCompanyBenefitResponse]. */ + class Builder internal constructor() { + + private var benefitId: JsonField? = null + private var jobId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(registerCompanyBenefitResponse: RegisterCompanyBenefitResponse) = apply { + benefitId = registerCompanyBenefitResponse.benefitId + jobId = registerCompanyBenefitResponse.jobId + additionalProperties = + registerCompanyBenefitResponse.additionalProperties.toMutableMap() + } + + /** The id of the benefit. */ + fun benefitId(benefitId: String) = benefitId(JsonField.of(benefitId)) + + /** + * Sets [Builder.benefitId] to an arbitrary JSON value. + * + * You should usually call [Builder.benefitId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun benefitId(benefitId: JsonField) = apply { this.benefitId = benefitId } + + fun jobId(jobId: String) = jobId(JsonField.of(jobId)) + + /** + * Sets [Builder.jobId] to an arbitrary JSON value. + * + * You should usually call [Builder.jobId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun jobId(jobId: JsonField) = apply { this.jobId = jobId } + + 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 [RegisterCompanyBenefitResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .benefitId() + * .jobId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RegisterCompanyBenefitResponse = + RegisterCompanyBenefitResponse( + checkRequired("benefitId", benefitId), + checkRequired("jobId", jobId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws FinchInvalidDataException if any value type in this object doesn't match its expected + * type. + */ + fun validate(): RegisterCompanyBenefitResponse = apply { + if (validated) { + return@apply + } + + benefitId() + jobId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + 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 (benefitId.asKnown().isPresent) 1 else 0) + (if (jobId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RegisterCompanyBenefitResponse && + benefitId == other.benefitId && + jobId == other.jobId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(benefitId, jobId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RegisterCompanyBenefitResponse{benefitId=$benefitId, jobId=$jobId, additionalProperties=$additionalProperties}" +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt index 3e48b3b2..099ae49d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt @@ -5,8 +5,10 @@ package com.tryfinch.api.services.async import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor +import com.tryfinch.api.models.AccountDisconnectEntityParams import com.tryfinch.api.models.AccountDisconnectParams import com.tryfinch.api.models.AccountIntrospectParams +import com.tryfinch.api.models.DisconnectEntityResponse import com.tryfinch.api.models.DisconnectResponse import com.tryfinch.api.models.Introspection import java.util.concurrent.CompletableFuture @@ -45,6 +47,20 @@ interface AccountServiceAsync { fun disconnect(requestOptions: RequestOptions): CompletableFuture = disconnect(AccountDisconnectParams.none(), requestOptions) + /** + * Disconnect entity(s) from a connection without affecting other entities associated with the + * same connection. + */ + fun disconnectEntity( + params: AccountDisconnectEntityParams + ): CompletableFuture = disconnectEntity(params, RequestOptions.none()) + + /** @see disconnectEntity */ + fun disconnectEntity( + params: AccountDisconnectEntityParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + /** Read account information associated with an `access_token` */ fun introspect(): CompletableFuture = introspect(AccountIntrospectParams.none()) @@ -102,6 +118,21 @@ interface AccountServiceAsync { ): CompletableFuture> = disconnect(AccountDisconnectParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /disconnect-entity`, but is otherwise the same as + * [AccountServiceAsync.disconnectEntity]. + */ + fun disconnectEntity( + params: AccountDisconnectEntityParams + ): CompletableFuture> = + disconnectEntity(params, RequestOptions.none()) + + /** @see disconnectEntity */ + fun disconnectEntity( + params: AccountDisconnectEntityParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + /** * Returns a raw HTTP response for `get /introspect`, but is otherwise the same as * [AccountServiceAsync.introspect]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt index 3bd8097c..838ff8d7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt @@ -16,8 +16,10 @@ import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.json import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepareAsync +import com.tryfinch.api.models.AccountDisconnectEntityParams import com.tryfinch.api.models.AccountDisconnectParams import com.tryfinch.api.models.AccountIntrospectParams +import com.tryfinch.api.models.DisconnectEntityResponse import com.tryfinch.api.models.DisconnectResponse import com.tryfinch.api.models.Introspection import java.util.concurrent.CompletableFuture @@ -42,6 +44,13 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl // post /disconnect withRawResponse().disconnect(params, requestOptions).thenApply { it.parse() } + override fun disconnectEntity( + params: AccountDisconnectEntityParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /disconnect-entity + withRawResponse().disconnectEntity(params, requestOptions).thenApply { it.parse() } + override fun introspect( params: AccountIntrospectParams, requestOptions: RequestOptions, @@ -97,6 +106,41 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl } } + private val disconnectEntityHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun disconnectEntity( + params: AccountDisconnectEntityParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("disconnect-entity") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().bearerAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { disconnectEntityHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val introspectHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt index 08dcd9ab..24b5a7cf 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt @@ -12,8 +12,10 @@ import com.tryfinch.api.models.HrisBenefitListPageAsync import com.tryfinch.api.models.HrisBenefitListParams import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsPageAsync import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsParams +import com.tryfinch.api.models.HrisBenefitRegisterParams import com.tryfinch.api.models.HrisBenefitRetrieveParams import com.tryfinch.api.models.HrisBenefitUpdateParams +import com.tryfinch.api.models.RegisterCompanyBenefitResponse import com.tryfinch.api.models.UpdateCompanyBenefitResponse import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsync import java.util.concurrent.CompletableFuture @@ -170,6 +172,30 @@ interface BenefitServiceAsync { ): CompletableFuture = listSupportedBenefits(HrisBenefitListSupportedBenefitsParams.none(), requestOptions) + /** + * Register existing benefits from the customer on the provider, on Finch's end. Please use the + * `/provider` endpoint to view available types for each provider. + */ + fun register(): CompletableFuture = + register(HrisBenefitRegisterParams.none()) + + /** @see register */ + fun register( + params: HrisBenefitRegisterParams = HrisBenefitRegisterParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see register */ + fun register( + params: HrisBenefitRegisterParams = HrisBenefitRegisterParams.none() + ): CompletableFuture = register(params, RequestOptions.none()) + + /** @see register */ + fun register( + requestOptions: RequestOptions + ): CompletableFuture = + register(HrisBenefitRegisterParams.none(), requestOptions) + /** * A view of [BenefitServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -347,5 +373,30 @@ interface BenefitServiceAsync { requestOptions: RequestOptions ): CompletableFuture> = listSupportedBenefits(HrisBenefitListSupportedBenefitsParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /employer/benefits/register`, but is otherwise the + * same as [BenefitServiceAsync.register]. + */ + fun register(): CompletableFuture> = + register(HrisBenefitRegisterParams.none()) + + /** @see register */ + fun register( + params: HrisBenefitRegisterParams = HrisBenefitRegisterParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see register */ + fun register( + params: HrisBenefitRegisterParams = HrisBenefitRegisterParams.none() + ): CompletableFuture> = + register(params, RequestOptions.none()) + + /** @see register */ + fun register( + requestOptions: RequestOptions + ): CompletableFuture> = + register(HrisBenefitRegisterParams.none(), requestOptions) } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt index 9cf3cc6b..3be18f42 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt @@ -24,8 +24,10 @@ import com.tryfinch.api.models.HrisBenefitListPageAsync import com.tryfinch.api.models.HrisBenefitListParams import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsPageAsync import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsParams +import com.tryfinch.api.models.HrisBenefitRegisterParams import com.tryfinch.api.models.HrisBenefitRetrieveParams import com.tryfinch.api.models.HrisBenefitUpdateParams +import com.tryfinch.api.models.RegisterCompanyBenefitResponse import com.tryfinch.api.models.SupportedBenefit import com.tryfinch.api.models.UpdateCompanyBenefitResponse import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsync @@ -88,6 +90,13 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl // get /employer/benefits/meta withRawResponse().listSupportedBenefits(params, requestOptions).thenApply { it.parse() } + override fun register( + params: HrisBenefitRegisterParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /employer/benefits/register + withRawResponse().register(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BenefitServiceAsync.WithRawResponse { @@ -300,5 +309,40 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl } } } + + private val registerHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun register( + params: HrisBenefitRegisterParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("employer", "benefits", "register") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().bearerAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { registerHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt index a4f89b5f..7a7d4042 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt @@ -5,6 +5,8 @@ package com.tryfinch.api.services.async.hris.benefits import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor +import com.tryfinch.api.models.EnrolledIndividualBenefitResponse +import com.tryfinch.api.models.HrisBenefitIndividualEnrollManyParams import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsPageAsync import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsParams @@ -28,6 +30,50 @@ interface IndividualServiceAsync { */ fun withOptions(modifier: Consumer): IndividualServiceAsync + /** + * Enroll an individual into a deduction or contribution. This is an overwrite operation. If the + * employee is already enrolled, the enrollment amounts will be adjusted. Making the same + * request multiple times will not create new enrollments, but will continue to set the state of + * the existing enrollment. + */ + fun enrollMany(benefitId: String): CompletableFuture = + enrollMany(benefitId, HrisBenefitIndividualEnrollManyParams.none()) + + /** @see enrollMany */ + fun enrollMany( + benefitId: String, + params: HrisBenefitIndividualEnrollManyParams = + HrisBenefitIndividualEnrollManyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + enrollMany(params.toBuilder().benefitId(benefitId).build(), requestOptions) + + /** @see enrollMany */ + fun enrollMany( + benefitId: String, + params: HrisBenefitIndividualEnrollManyParams = HrisBenefitIndividualEnrollManyParams.none(), + ): CompletableFuture = + enrollMany(benefitId, params, RequestOptions.none()) + + /** @see enrollMany */ + fun enrollMany( + params: HrisBenefitIndividualEnrollManyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see enrollMany */ + fun enrollMany( + params: HrisBenefitIndividualEnrollManyParams + ): CompletableFuture = + enrollMany(params, RequestOptions.none()) + + /** @see enrollMany */ + fun enrollMany( + benefitId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + enrollMany(benefitId, HrisBenefitIndividualEnrollManyParams.none(), requestOptions) + /** Lists individuals currently enrolled in a given deduction. */ fun enrolledIds(benefitId: String): CompletableFuture = enrolledIds(benefitId, HrisBenefitIndividualEnrolledIdsParams.none()) @@ -168,6 +214,51 @@ interface IndividualServiceAsync { modifier: Consumer ): IndividualServiceAsync.WithRawResponse + /** + * Returns a raw HTTP response for `post /employer/benefits/{benefit_id}/individuals`, but + * is otherwise the same as [IndividualServiceAsync.enrollMany]. + */ + fun enrollMany( + benefitId: String + ): CompletableFuture> = + enrollMany(benefitId, HrisBenefitIndividualEnrollManyParams.none()) + + /** @see enrollMany */ + fun enrollMany( + benefitId: String, + params: HrisBenefitIndividualEnrollManyParams = + HrisBenefitIndividualEnrollManyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + enrollMany(params.toBuilder().benefitId(benefitId).build(), requestOptions) + + /** @see enrollMany */ + fun enrollMany( + benefitId: String, + params: HrisBenefitIndividualEnrollManyParams = + HrisBenefitIndividualEnrollManyParams.none(), + ): CompletableFuture> = + enrollMany(benefitId, params, RequestOptions.none()) + + /** @see enrollMany */ + fun enrollMany( + params: HrisBenefitIndividualEnrollManyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see enrollMany */ + fun enrollMany( + params: HrisBenefitIndividualEnrollManyParams + ): CompletableFuture> = + enrollMany(params, RequestOptions.none()) + + /** @see enrollMany */ + fun enrollMany( + benefitId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + enrollMany(benefitId, HrisBenefitIndividualEnrollManyParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /employer/benefits/{benefit_id}/enrolled`, but is * otherwise the same as [IndividualServiceAsync.enrolledIds]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncImpl.kt index a53af4c3..343abda5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncImpl.kt @@ -17,6 +17,8 @@ import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.json import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepareAsync +import com.tryfinch.api.models.EnrolledIndividualBenefitResponse +import com.tryfinch.api.models.HrisBenefitIndividualEnrollManyParams import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsPageAsync import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsParams @@ -40,6 +42,13 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: override fun withOptions(modifier: Consumer): IndividualServiceAsync = IndividualServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun enrollMany( + params: HrisBenefitIndividualEnrollManyParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /employer/benefits/{benefit_id}/individuals + withRawResponse().enrollMany(params, requestOptions).thenApply { it.parse() } + override fun enrolledIds( params: HrisBenefitIndividualEnrolledIdsParams, requestOptions: RequestOptions, @@ -74,6 +83,44 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: clientOptions.toBuilder().apply(modifier::accept).build() ) + private val enrollManyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun enrollMany( + params: HrisBenefitIndividualEnrollManyParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("benefitId", params.benefitId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("employer", "benefits", params._pathParam(0), "individuals") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().bearerAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { enrollManyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val enrolledIdsHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountService.kt index fc92f131..bcee4ca8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountService.kt @@ -6,8 +6,10 @@ import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor +import com.tryfinch.api.models.AccountDisconnectEntityParams import com.tryfinch.api.models.AccountDisconnectParams import com.tryfinch.api.models.AccountIntrospectParams +import com.tryfinch.api.models.DisconnectEntityResponse import com.tryfinch.api.models.DisconnectResponse import com.tryfinch.api.models.Introspection import java.util.function.Consumer @@ -44,6 +46,19 @@ interface AccountService { fun disconnect(requestOptions: RequestOptions): DisconnectResponse = disconnect(AccountDisconnectParams.none(), requestOptions) + /** + * Disconnect entity(s) from a connection without affecting other entities associated with the + * same connection. + */ + fun disconnectEntity(params: AccountDisconnectEntityParams): DisconnectEntityResponse = + disconnectEntity(params, RequestOptions.none()) + + /** @see disconnectEntity */ + fun disconnectEntity( + params: AccountDisconnectEntityParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DisconnectEntityResponse + /** Read account information associated with an `access_token` */ fun introspect(): Introspection = introspect(AccountIntrospectParams.none()) @@ -98,6 +113,23 @@ interface AccountService { fun disconnect(requestOptions: RequestOptions): HttpResponseFor = disconnect(AccountDisconnectParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /disconnect-entity`, but is otherwise the same as + * [AccountService.disconnectEntity]. + */ + @MustBeClosed + fun disconnectEntity( + params: AccountDisconnectEntityParams + ): HttpResponseFor = + disconnectEntity(params, RequestOptions.none()) + + /** @see disconnectEntity */ + @MustBeClosed + fun disconnectEntity( + params: AccountDisconnectEntityParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + /** * Returns a raw HTTP response for `get /introspect`, but is otherwise the same as * [AccountService.introspect]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt index 966aaa07..184bd6a8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt @@ -16,8 +16,10 @@ import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.json import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare +import com.tryfinch.api.models.AccountDisconnectEntityParams import com.tryfinch.api.models.AccountDisconnectParams import com.tryfinch.api.models.AccountIntrospectParams +import com.tryfinch.api.models.DisconnectEntityResponse import com.tryfinch.api.models.DisconnectResponse import com.tryfinch.api.models.Introspection import java.util.function.Consumer @@ -41,6 +43,13 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO // post /disconnect withRawResponse().disconnect(params, requestOptions).parse() + override fun disconnectEntity( + params: AccountDisconnectEntityParams, + requestOptions: RequestOptions, + ): DisconnectEntityResponse = + // post /disconnect-entity + withRawResponse().disconnectEntity(params, requestOptions).parse() + override fun introspect( params: AccountIntrospectParams, requestOptions: RequestOptions, @@ -93,6 +102,38 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO } } + private val disconnectEntityHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun disconnectEntity( + params: AccountDisconnectEntityParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("disconnect-entity") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare( + clientOptions, + params, + SecurityOptions.builder().bearerAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { disconnectEntityHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val introspectHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitService.kt index a7c53e69..9699d34c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitService.kt @@ -13,8 +13,10 @@ import com.tryfinch.api.models.HrisBenefitListPage import com.tryfinch.api.models.HrisBenefitListParams import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsPage import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsParams +import com.tryfinch.api.models.HrisBenefitRegisterParams import com.tryfinch.api.models.HrisBenefitRetrieveParams import com.tryfinch.api.models.HrisBenefitUpdateParams +import com.tryfinch.api.models.RegisterCompanyBenefitResponse import com.tryfinch.api.models.UpdateCompanyBenefitResponse import com.tryfinch.api.services.blocking.hris.benefits.IndividualService import java.util.function.Consumer @@ -159,6 +161,27 @@ interface BenefitService { ): HrisBenefitListSupportedBenefitsPage = listSupportedBenefits(HrisBenefitListSupportedBenefitsParams.none(), requestOptions) + /** + * Register existing benefits from the customer on the provider, on Finch's end. Please use the + * `/provider` endpoint to view available types for each provider. + */ + fun register(): RegisterCompanyBenefitResponse = register(HrisBenefitRegisterParams.none()) + + /** @see register */ + fun register( + params: HrisBenefitRegisterParams = HrisBenefitRegisterParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RegisterCompanyBenefitResponse + + /** @see register */ + fun register( + params: HrisBenefitRegisterParams = HrisBenefitRegisterParams.none() + ): RegisterCompanyBenefitResponse = register(params, RequestOptions.none()) + + /** @see register */ + fun register(requestOptions: RequestOptions): RegisterCompanyBenefitResponse = + register(HrisBenefitRegisterParams.none(), requestOptions) + /** A view of [BenefitService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -341,5 +364,33 @@ interface BenefitService { requestOptions: RequestOptions ): HttpResponseFor = listSupportedBenefits(HrisBenefitListSupportedBenefitsParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /employer/benefits/register`, but is otherwise the + * same as [BenefitService.register]. + */ + @MustBeClosed + fun register(): HttpResponseFor = + register(HrisBenefitRegisterParams.none()) + + /** @see register */ + @MustBeClosed + fun register( + params: HrisBenefitRegisterParams = HrisBenefitRegisterParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see register */ + @MustBeClosed + fun register( + params: HrisBenefitRegisterParams = HrisBenefitRegisterParams.none() + ): HttpResponseFor = register(params, RequestOptions.none()) + + /** @see register */ + @MustBeClosed + fun register( + requestOptions: RequestOptions + ): HttpResponseFor = + register(HrisBenefitRegisterParams.none(), requestOptions) } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt index a4f4e4d7..4bfc8227 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt @@ -24,8 +24,10 @@ import com.tryfinch.api.models.HrisBenefitListPage import com.tryfinch.api.models.HrisBenefitListParams import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsPage import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsParams +import com.tryfinch.api.models.HrisBenefitRegisterParams import com.tryfinch.api.models.HrisBenefitRetrieveParams import com.tryfinch.api.models.HrisBenefitUpdateParams +import com.tryfinch.api.models.RegisterCompanyBenefitResponse import com.tryfinch.api.models.SupportedBenefit import com.tryfinch.api.models.UpdateCompanyBenefitResponse import com.tryfinch.api.services.blocking.hris.benefits.IndividualService @@ -85,6 +87,13 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO // get /employer/benefits/meta withRawResponse().listSupportedBenefits(params, requestOptions).parse() + override fun register( + params: HrisBenefitRegisterParams, + requestOptions: RequestOptions, + ): RegisterCompanyBenefitResponse = + // post /employer/benefits/register + withRawResponse().register(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : BenefitService.WithRawResponse { @@ -280,5 +289,37 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO } } } + + private val registerHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun register( + params: HrisBenefitRegisterParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("employer", "benefits", "register") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare( + clientOptions, + params, + SecurityOptions.builder().bearerAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { registerHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualService.kt index 60e8f7c9..441eed80 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualService.kt @@ -6,6 +6,8 @@ import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor +import com.tryfinch.api.models.EnrolledIndividualBenefitResponse +import com.tryfinch.api.models.HrisBenefitIndividualEnrollManyParams import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsPage import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsParams @@ -28,6 +30,48 @@ interface IndividualService { */ fun withOptions(modifier: Consumer): IndividualService + /** + * Enroll an individual into a deduction or contribution. This is an overwrite operation. If the + * employee is already enrolled, the enrollment amounts will be adjusted. Making the same + * request multiple times will not create new enrollments, but will continue to set the state of + * the existing enrollment. + */ + fun enrollMany(benefitId: String): EnrolledIndividualBenefitResponse = + enrollMany(benefitId, HrisBenefitIndividualEnrollManyParams.none()) + + /** @see enrollMany */ + fun enrollMany( + benefitId: String, + params: HrisBenefitIndividualEnrollManyParams = + HrisBenefitIndividualEnrollManyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): EnrolledIndividualBenefitResponse = + enrollMany(params.toBuilder().benefitId(benefitId).build(), requestOptions) + + /** @see enrollMany */ + fun enrollMany( + benefitId: String, + params: HrisBenefitIndividualEnrollManyParams = HrisBenefitIndividualEnrollManyParams.none(), + ): EnrolledIndividualBenefitResponse = enrollMany(benefitId, params, RequestOptions.none()) + + /** @see enrollMany */ + fun enrollMany( + params: HrisBenefitIndividualEnrollManyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): EnrolledIndividualBenefitResponse + + /** @see enrollMany */ + fun enrollMany( + params: HrisBenefitIndividualEnrollManyParams + ): EnrolledIndividualBenefitResponse = enrollMany(params, RequestOptions.none()) + + /** @see enrollMany */ + fun enrollMany( + benefitId: String, + requestOptions: RequestOptions, + ): EnrolledIndividualBenefitResponse = + enrollMany(benefitId, HrisBenefitIndividualEnrollManyParams.none(), requestOptions) + /** Lists individuals currently enrolled in a given deduction. */ fun enrolledIds(benefitId: String): IndividualEnrolledIdsResponse = enrolledIds(benefitId, HrisBenefitIndividualEnrolledIdsParams.none()) @@ -159,6 +203,55 @@ interface IndividualService { modifier: Consumer ): IndividualService.WithRawResponse + /** + * Returns a raw HTTP response for `post /employer/benefits/{benefit_id}/individuals`, but + * is otherwise the same as [IndividualService.enrollMany]. + */ + @MustBeClosed + fun enrollMany(benefitId: String): HttpResponseFor = + enrollMany(benefitId, HrisBenefitIndividualEnrollManyParams.none()) + + /** @see enrollMany */ + @MustBeClosed + fun enrollMany( + benefitId: String, + params: HrisBenefitIndividualEnrollManyParams = + HrisBenefitIndividualEnrollManyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + enrollMany(params.toBuilder().benefitId(benefitId).build(), requestOptions) + + /** @see enrollMany */ + @MustBeClosed + fun enrollMany( + benefitId: String, + params: HrisBenefitIndividualEnrollManyParams = + HrisBenefitIndividualEnrollManyParams.none(), + ): HttpResponseFor = + enrollMany(benefitId, params, RequestOptions.none()) + + /** @see enrollMany */ + @MustBeClosed + fun enrollMany( + params: HrisBenefitIndividualEnrollManyParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see enrollMany */ + @MustBeClosed + fun enrollMany( + params: HrisBenefitIndividualEnrollManyParams + ): HttpResponseFor = + enrollMany(params, RequestOptions.none()) + + /** @see enrollMany */ + @MustBeClosed + fun enrollMany( + benefitId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + enrollMany(benefitId, HrisBenefitIndividualEnrollManyParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /employer/benefits/{benefit_id}/enrolled`, but is * otherwise the same as [IndividualService.enrolledIds]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt index 467c2949..b0f22a53 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt @@ -17,6 +17,8 @@ import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.json import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare +import com.tryfinch.api.models.EnrolledIndividualBenefitResponse +import com.tryfinch.api.models.HrisBenefitIndividualEnrollManyParams import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsPage import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsParams @@ -39,6 +41,13 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie override fun withOptions(modifier: Consumer): IndividualService = IndividualServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun enrollMany( + params: HrisBenefitIndividualEnrollManyParams, + requestOptions: RequestOptions, + ): EnrolledIndividualBenefitResponse = + // post /employer/benefits/{benefit_id}/individuals + withRawResponse().enrollMany(params, requestOptions).parse() + override fun enrolledIds( params: HrisBenefitIndividualEnrolledIdsParams, requestOptions: RequestOptions, @@ -73,6 +82,41 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie clientOptions.toBuilder().apply(modifier::accept).build() ) + private val enrollManyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun enrollMany( + params: HrisBenefitIndividualEnrollManyParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("benefitId", params.benefitId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("employer", "benefits", params._pathParam(0), "individuals") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare( + clientOptions, + params, + SecurityOptions.builder().bearerAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { enrollManyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val enrolledIdsHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountDisconnectEntityParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountDisconnectEntityParamsTest.kt new file mode 100644 index 00000000..6f18fe42 --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountDisconnectEntityParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccountDisconnectEntityParamsTest { + + @Test + fun create() { + AccountDisconnectEntityParams.builder() + .addEntityId("3c90c3cc-0d44-4b50-8888-8dd25736052a") + .addEntityId("5e6f7a8b-9c10-4d11-a12b-c13d14e15f16") + .build() + } + + @Test + fun body() { + val params = + AccountDisconnectEntityParams.builder() + .addEntityId("3c90c3cc-0d44-4b50-8888-8dd25736052a") + .addEntityId("5e6f7a8b-9c10-4d11-a12b-c13d14e15f16") + .build() + + val body = params._body() + + assertThat(body.entityIds()) + .containsExactly( + "3c90c3cc-0d44-4b50-8888-8dd25736052a", + "5e6f7a8b-9c10-4d11-a12b-c13d14e15f16", + ) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DisconnectEntityResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DisconnectEntityResponseTest.kt new file mode 100644 index 00000000..e455ff01 --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DisconnectEntityResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DisconnectEntityResponseTest { + + @Test + fun create() { + val disconnectEntityResponse = DisconnectEntityResponse.builder().status("status").build() + + assertThat(disconnectEntityResponse.status()).isEqualTo("status") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val disconnectEntityResponse = DisconnectEntityResponse.builder().status("status").build() + + val roundtrippedDisconnectEntityResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(disconnectEntityResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDisconnectEntityResponse).isEqualTo(disconnectEntityResponse) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualEnrollManyParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualEnrollManyParamsTest.kt new file mode 100644 index 00000000..c542b354 --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualEnrollManyParamsTest.kt @@ -0,0 +1,296 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.tryfinch.api.core.http.QueryParams +import java.time.LocalDate +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class HrisBenefitIndividualEnrollManyParamsTest { + + @Test + fun create() { + HrisBenefitIndividualEnrollManyParams.builder() + .benefitId("benefit_id") + .addEntityId("550e8400-e29b-41d4-a716-446655440000") + .addIndividual( + HrisBenefitIndividualEnrollManyParams.Individual.builder() + .configuration( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration.builder() + .annualContributionLimit( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration + .AnnualContributionLimit + .INDIVIDUAL + ) + .annualMaximum(null) + .catchUp(true) + .companyContribution( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration + .CompanyContribution + .builder() + .amount(0L) + .addTier( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .CompanyContribution + .Tier + .builder() + .match(0L) + .threshold(0L) + .build() + ) + .type( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .CompanyContribution + .Type + .FIXED + ) + .build() + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .employeeDeduction( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration + .EmployeeDeduction + .builder() + .amount(10000L) + .type( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .EmployeeDeduction + .Type + .FIXED + ) + .build() + ) + .build() + ) + .individualId("d02a6346-1f08-4312-a064-49ff3cafaa7a") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = HrisBenefitIndividualEnrollManyParams.builder().benefitId("benefit_id").build() + + assertThat(params._pathParam(0)).isEqualTo("benefit_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + HrisBenefitIndividualEnrollManyParams.builder() + .benefitId("benefit_id") + .addEntityId("550e8400-e29b-41d4-a716-446655440000") + .addIndividual( + HrisBenefitIndividualEnrollManyParams.Individual.builder() + .configuration( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration.builder() + .annualContributionLimit( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration + .AnnualContributionLimit + .INDIVIDUAL + ) + .annualMaximum(null) + .catchUp(true) + .companyContribution( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration + .CompanyContribution + .builder() + .amount(0L) + .addTier( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .CompanyContribution + .Tier + .builder() + .match(0L) + .threshold(0L) + .build() + ) + .type( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .CompanyContribution + .Type + .FIXED + ) + .build() + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .employeeDeduction( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration + .EmployeeDeduction + .builder() + .amount(10000L) + .type( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .EmployeeDeduction + .Type + .FIXED + ) + .build() + ) + .build() + ) + .individualId("d02a6346-1f08-4312-a064-49ff3cafaa7a") + .build() + ) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("entity_ids[]", "550e8400-e29b-41d4-a716-446655440000") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = HrisBenefitIndividualEnrollManyParams.builder().benefitId("benefit_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } + + @Test + fun body() { + val params = + HrisBenefitIndividualEnrollManyParams.builder() + .benefitId("benefit_id") + .addEntityId("550e8400-e29b-41d4-a716-446655440000") + .addIndividual( + HrisBenefitIndividualEnrollManyParams.Individual.builder() + .configuration( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration.builder() + .annualContributionLimit( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration + .AnnualContributionLimit + .INDIVIDUAL + ) + .annualMaximum(null) + .catchUp(true) + .companyContribution( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration + .CompanyContribution + .builder() + .amount(0L) + .addTier( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .CompanyContribution + .Tier + .builder() + .match(0L) + .threshold(0L) + .build() + ) + .type( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .CompanyContribution + .Type + .FIXED + ) + .build() + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .employeeDeduction( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration + .EmployeeDeduction + .builder() + .amount(10000L) + .type( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .EmployeeDeduction + .Type + .FIXED + ) + .build() + ) + .build() + ) + .individualId("d02a6346-1f08-4312-a064-49ff3cafaa7a") + .build() + ) + .build() + + val body = params._body().getOrNull() + + assertThat(body) + .containsExactly( + HrisBenefitIndividualEnrollManyParams.Individual.builder() + .configuration( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration.builder() + .annualContributionLimit( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration + .AnnualContributionLimit + .INDIVIDUAL + ) + .annualMaximum(null) + .catchUp(true) + .companyContribution( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration + .CompanyContribution + .builder() + .amount(0L) + .addTier( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .CompanyContribution + .Tier + .builder() + .match(0L) + .threshold(0L) + .build() + ) + .type( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .CompanyContribution + .Type + .FIXED + ) + .build() + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .employeeDeduction( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration + .EmployeeDeduction + .builder() + .amount(10000L) + .type( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .EmployeeDeduction + .Type + .FIXED + ) + .build() + ) + .build() + ) + .individualId("d02a6346-1f08-4312-a064-49ff3cafaa7a") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = HrisBenefitIndividualEnrollManyParams.builder().benefitId("benefit_id").build() + + val body = params._body().getOrNull() + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitRegisterParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitRegisterParamsTest.kt new file mode 100644 index 00000000..c1e81f7f --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitRegisterParamsTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.tryfinch.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class HrisBenefitRegisterParamsTest { + + @Test + fun create() { + HrisBenefitRegisterParams.builder() + .addEntityId("550e8400-e29b-41d4-a716-446655440000") + .description("description") + .frequency(BenefitFrequency.EVERY_PAYCHECK) + .type(BenefitType._457) + .build() + } + + @Test + fun queryParams() { + val params = + HrisBenefitRegisterParams.builder() + .addEntityId("550e8400-e29b-41d4-a716-446655440000") + .description("description") + .frequency(BenefitFrequency.EVERY_PAYCHECK) + .type(BenefitType._457) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("entity_ids[]", "550e8400-e29b-41d4-a716-446655440000") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = HrisBenefitRegisterParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } + + @Test + fun body() { + val params = + HrisBenefitRegisterParams.builder() + .addEntityId("550e8400-e29b-41d4-a716-446655440000") + .description("description") + .frequency(BenefitFrequency.EVERY_PAYCHECK) + .type(BenefitType._457) + .build() + + val body = params._body() + + assertThat(body.description()).contains("description") + assertThat(body.frequency()).contains(BenefitFrequency.EVERY_PAYCHECK) + assertThat(body.type()).contains(BenefitType._457) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = HrisBenefitRegisterParams.builder().build() + + val body = params._body() + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RegisterCompanyBenefitResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RegisterCompanyBenefitResponseTest.kt new file mode 100644 index 00000000..faeda8b9 --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RegisterCompanyBenefitResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RegisterCompanyBenefitResponseTest { + + @Test + fun create() { + val registerCompanyBenefitResponse = + RegisterCompanyBenefitResponse.builder() + .benefitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(registerCompanyBenefitResponse.benefitId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(registerCompanyBenefitResponse.jobId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val registerCompanyBenefitResponse = + RegisterCompanyBenefitResponse.builder() + .benefitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedRegisterCompanyBenefitResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(registerCompanyBenefitResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRegisterCompanyBenefitResponse) + .isEqualTo(registerCompanyBenefitResponse) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncTest.kt index 486debf9..8f23c518 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncTest.kt @@ -4,6 +4,7 @@ package com.tryfinch.api.services.async import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync +import com.tryfinch.api.models.AccountDisconnectEntityParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -25,6 +26,27 @@ internal class AccountServiceAsyncTest { disconnectResponse.validate() } + @Test + fun disconnectEntity() { + val client = + FinchOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .accessToken("My Access Token") + .build() + val accountServiceAsync = client.account() + + val disconnectEntityResponseFuture = + accountServiceAsync.disconnectEntity( + AccountDisconnectEntityParams.builder() + .addEntityId("3c90c3cc-0d44-4b50-8888-8dd25736052a") + .addEntityId("5e6f7a8b-9c10-4d11-a12b-c13d14e15f16") + .build() + ) + + val disconnectEntityResponse = disconnectEntityResponseFuture.get() + disconnectEntityResponse.validate() + } + @Test fun introspect() { val client = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncTest.kt index b1f0fa30..8ace0122 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncTest.kt @@ -7,6 +7,7 @@ import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync import com.tryfinch.api.models.BenefitFrequency import com.tryfinch.api.models.BenefitType import com.tryfinch.api.models.HrisBenefitCreateParams +import com.tryfinch.api.models.HrisBenefitRegisterParams import com.tryfinch.api.models.HrisBenefitRetrieveParams import com.tryfinch.api.models.HrisBenefitUpdateParams import org.junit.jupiter.api.Test @@ -124,4 +125,27 @@ internal class BenefitServiceAsyncTest { val page = pageFuture.get() page.items().forEach { it.validate() } } + + @Test + fun register() { + val client = + FinchOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .accessToken("My Access Token") + .build() + val benefitServiceAsync = client.hris().benefits() + + val registerCompanyBenefitResponseFuture = + benefitServiceAsync.register( + HrisBenefitRegisterParams.builder() + .addEntityId("550e8400-e29b-41d4-a716-446655440000") + .description("description") + .frequency(BenefitFrequency.EVERY_PAYCHECK) + .type(BenefitType._457) + .build() + ) + + val registerCompanyBenefitResponse = registerCompanyBenefitResponseFuture.get() + registerCompanyBenefitResponse.validate() + } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncTest.kt index fd7f380c..017398b6 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncTest.kt @@ -4,14 +4,96 @@ package com.tryfinch.api.services.async.hris.benefits import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync +import com.tryfinch.api.models.HrisBenefitIndividualEnrollManyParams import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class IndividualServiceAsyncTest { + @Test + fun enrollMany() { + val client = + FinchOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .accessToken("My Access Token") + .build() + val individualServiceAsync = client.hris().benefits().individuals() + + val enrolledIndividualBenefitResponseFuture = + individualServiceAsync.enrollMany( + HrisBenefitIndividualEnrollManyParams.builder() + .benefitId("benefit_id") + .addEntityId("550e8400-e29b-41d4-a716-446655440000") + .addIndividual( + HrisBenefitIndividualEnrollManyParams.Individual.builder() + .configuration( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration + .builder() + .annualContributionLimit( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .AnnualContributionLimit + .INDIVIDUAL + ) + .annualMaximum(null) + .catchUp(true) + .companyContribution( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .CompanyContribution + .builder() + .amount(0L) + .addTier( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .CompanyContribution + .Tier + .builder() + .match(0L) + .threshold(0L) + .build() + ) + .type( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .CompanyContribution + .Type + .FIXED + ) + .build() + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .employeeDeduction( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .EmployeeDeduction + .builder() + .amount(10000L) + .type( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .EmployeeDeduction + .Type + .FIXED + ) + .build() + ) + .build() + ) + .individualId("d02a6346-1f08-4312-a064-49ff3cafaa7a") + .build() + ) + .build() + ) + + val enrolledIndividualBenefitResponse = enrolledIndividualBenefitResponseFuture.get() + enrolledIndividualBenefitResponse.validate() + } + @Test fun enrolledIds() { val client = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/AccountServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/AccountServiceTest.kt index adb69330..29a7742b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/AccountServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/AccountServiceTest.kt @@ -4,6 +4,7 @@ package com.tryfinch.api.services.blocking import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClient +import com.tryfinch.api.models.AccountDisconnectEntityParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -24,6 +25,26 @@ internal class AccountServiceTest { disconnectResponse.validate() } + @Test + fun disconnectEntity() { + val client = + FinchOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .accessToken("My Access Token") + .build() + val accountService = client.account() + + val disconnectEntityResponse = + accountService.disconnectEntity( + AccountDisconnectEntityParams.builder() + .addEntityId("3c90c3cc-0d44-4b50-8888-8dd25736052a") + .addEntityId("5e6f7a8b-9c10-4d11-a12b-c13d14e15f16") + .build() + ) + + disconnectEntityResponse.validate() + } + @Test fun introspect() { val client = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceTest.kt index 03efb9c3..f9ec1635 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceTest.kt @@ -7,6 +7,7 @@ import com.tryfinch.api.client.okhttp.FinchOkHttpClient import com.tryfinch.api.models.BenefitFrequency import com.tryfinch.api.models.BenefitType import com.tryfinch.api.models.HrisBenefitCreateParams +import com.tryfinch.api.models.HrisBenefitRegisterParams import com.tryfinch.api.models.HrisBenefitRetrieveParams import com.tryfinch.api.models.HrisBenefitUpdateParams import org.junit.jupiter.api.Test @@ -119,4 +120,26 @@ internal class BenefitServiceTest { page.items().forEach { it.validate() } } + + @Test + fun register() { + val client = + FinchOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .accessToken("My Access Token") + .build() + val benefitService = client.hris().benefits() + + val registerCompanyBenefitResponse = + benefitService.register( + HrisBenefitRegisterParams.builder() + .addEntityId("550e8400-e29b-41d4-a716-446655440000") + .description("description") + .frequency(BenefitFrequency.EVERY_PAYCHECK) + .type(BenefitType._457) + .build() + ) + + registerCompanyBenefitResponse.validate() + } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceTest.kt index 9963f3f7..273481b8 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceTest.kt @@ -4,14 +4,95 @@ package com.tryfinch.api.services.blocking.hris.benefits import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClient +import com.tryfinch.api.models.HrisBenefitIndividualEnrollManyParams import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class IndividualServiceTest { + @Test + fun enrollMany() { + val client = + FinchOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .accessToken("My Access Token") + .build() + val individualService = client.hris().benefits().individuals() + + val enrolledIndividualBenefitResponse = + individualService.enrollMany( + HrisBenefitIndividualEnrollManyParams.builder() + .benefitId("benefit_id") + .addEntityId("550e8400-e29b-41d4-a716-446655440000") + .addIndividual( + HrisBenefitIndividualEnrollManyParams.Individual.builder() + .configuration( + HrisBenefitIndividualEnrollManyParams.Individual.Configuration + .builder() + .annualContributionLimit( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .AnnualContributionLimit + .INDIVIDUAL + ) + .annualMaximum(null) + .catchUp(true) + .companyContribution( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .CompanyContribution + .builder() + .amount(0L) + .addTier( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .CompanyContribution + .Tier + .builder() + .match(0L) + .threshold(0L) + .build() + ) + .type( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .CompanyContribution + .Type + .FIXED + ) + .build() + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .employeeDeduction( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .EmployeeDeduction + .builder() + .amount(10000L) + .type( + HrisBenefitIndividualEnrollManyParams.Individual + .Configuration + .EmployeeDeduction + .Type + .FIXED + ) + .build() + ) + .build() + ) + .individualId("d02a6346-1f08-4312-a064-49ff3cafaa7a") + .build() + ) + .build() + ) + + enrolledIndividualBenefitResponse.validate() + } + @Test fun enrolledIds() { val client =