From ff25e9af9a8e91700c617edf396644ccccf6cefb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 22 Apr 2025 21:22:31 +0000 Subject: [PATCH 01/27] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index d5a64be4..2b822ed4 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%2Ffinch-a9dc15ba77c4c6e40c8f2429b1d614e7fe6888910579b54002fb90d418682d09.yml -openapi_spec_hash: be98b11d320aa0a1f3443650ce1b5b90 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-18b03a9c4c43831116acdf6b551d1c469efb6f645b16f406ad8647e4aee2ff39.yml +openapi_spec_hash: 8ef2bb08a7710a32a4fe509af458e7ac config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 From 7b51741d5e2a11407a206c923ec7df17f384c4a8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 16:57:23 +0000 Subject: [PATCH 02/27] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2b822ed4..9f0c7c9d 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%2Ffinch-18b03a9c4c43831116acdf6b551d1c469efb6f645b16f406ad8647e4aee2ff39.yml -openapi_spec_hash: 8ef2bb08a7710a32a4fe509af458e7ac +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-e33325fb830bdd979e9067a492968e5318a5b520572308a5331acb91274735ac.yml +openapi_spec_hash: 0b203de65d7fd1c68f2d81f02849a803 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 From 876a6f9fb669c659dda8a349ba676545c5b78568 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 18:00:17 +0000 Subject: [PATCH 03/27] chore(ci): run on more branches and use depot runners --- .github/workflows/ci.yml | 17 +++++++++-------- .github/workflows/publish-sonatype.yml | 2 +- .github/workflows/release-doctor.yml | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9051fdd2..145d33ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,18 +1,19 @@ name: CI on: push: - branches: - - main - pull_request: - branches: - - main - - next + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: lint: timeout-minutes: 10 name: lint - runs-on: ubuntu-latest + runs-on: depot-ubuntu-24.04 + steps: - uses: actions/checkout@v4 @@ -33,7 +34,7 @@ jobs: test: timeout-minutes: 10 name: test - runs-on: ubuntu-latest + runs-on: depot-ubuntu-24.04 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index a180cc9d..57c970a2 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -11,7 +11,7 @@ on: jobs: publish: name: publish - runs-on: ubuntu-latest + runs-on: depot-ubuntu-24.04 steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index d4b7eca7..ed6e3d0b 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -8,7 +8,7 @@ on: jobs: release_doctor: name: release doctor - runs-on: ubuntu-latest + runs-on: depot-ubuntu-24.04 if: github.repository == 'Finch-API/finch-api-java' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: From 415d708c3acfe3ab0b718e89178632d5952e261a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 20:02:57 +0000 Subject: [PATCH 04/27] chore(ci): only use depot for staging repos --- .github/workflows/ci.yml | 4 ++-- .github/workflows/publish-sonatype.yml | 2 +- .github/workflows/release-doctor.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 145d33ab..35de2d67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: lint: timeout-minutes: 10 name: lint - runs-on: depot-ubuntu-24.04 + runs-on: ${{ github.repository == 'stainless-sdks/finch-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4 @@ -34,7 +34,7 @@ jobs: test: timeout-minutes: 10 name: test - runs-on: depot-ubuntu-24.04 + runs-on: ${{ github.repository == 'stainless-sdks/finch-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 57c970a2..a180cc9d 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -11,7 +11,7 @@ on: jobs: publish: name: publish - runs-on: depot-ubuntu-24.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index ed6e3d0b..d4b7eca7 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -8,7 +8,7 @@ on: jobs: release_doctor: name: release doctor - runs-on: depot-ubuntu-24.04 + runs-on: ubuntu-latest if: github.repository == 'Finch-API/finch-api-java' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: From 5982e367891992a817ad418309b575ba207a04b5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 22:05:58 +0000 Subject: [PATCH 05/27] chore(internal): java 17 -> 21 on ci --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35de2d67..480eb784 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: distribution: temurin java-version: | 8 - 17 + 21 cache: gradle - name: Set up Gradle @@ -44,7 +44,7 @@ jobs: distribution: temurin java-version: | 8 - 17 + 21 cache: gradle - name: Set up Gradle From 8cdf256b5b9e96b4162b8baa3fc068cb510613e2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 23:48:42 +0000 Subject: [PATCH 06/27] feat(api): api update --- .stats.yml | 4 +- .../models/PayStatementItemListResponse.kt | 145 +++++++++++++++++- ...anyPayStatementItemListPageResponseTest.kt | 18 ++- .../PayStatementItemListResponseTest.kt | 18 ++- 4 files changed, 172 insertions(+), 13 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9f0c7c9d..1629f07d 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%2Ffinch-e33325fb830bdd979e9067a492968e5318a5b520572308a5331acb91274735ac.yml -openapi_spec_hash: 0b203de65d7fd1c68f2d81f02849a803 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-05a1c7485ea6dd75ad2fb1a0628570d88a3e7c4f1e1ecad433711c78deae50e6.yml +openapi_spec_hash: 6d6014d50e18c98219b496bb2a5dab1d config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementItemListResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementItemListResponse.kt index 2e8a895b..846be3c3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementItemListResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementItemListResponse.kt @@ -11,6 +11,7 @@ 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.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects @@ -221,7 +222,7 @@ private constructor( class Attributes private constructor( private val employer: JsonField, - private val metadata: JsonValue, + private val metadata: JsonField, private val preTax: JsonField, private val type: JsonField, private val additionalProperties: MutableMap, @@ -232,7 +233,9 @@ private constructor( @JsonProperty("employer") @ExcludeMissing employer: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), @JsonProperty("pre_tax") @ExcludeMissing preTax: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), ) : this(employer, metadata, preTax, type, mutableMapOf()) @@ -248,8 +251,11 @@ private constructor( /** * The metadata of the pay statement item derived by the rules engine if available. Each * attribute will be a key-value pair defined by a rule. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + fun metadata(): Optional = metadata.getOptional("metadata") /** * `true` if the pay statement item is pre-tax. This field is only available for employee @@ -275,6 +281,13 @@ private constructor( */ @JsonProperty("employer") @ExcludeMissing fun _employer(): JsonField = employer + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** * Returns the raw JSON value of [preTax]. * @@ -311,7 +324,7 @@ private constructor( class Builder internal constructor() { private var employer: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var preTax: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -354,7 +367,19 @@ private constructor( * The metadata of the pay statement item derived by the rules engine if available. Each * attribute will be a key-value pair defined by a rule. */ - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** * `true` if the pay statement item is pre-tax. This field is only available for @@ -432,6 +457,7 @@ private constructor( } employer() + metadata().ifPresent { it.validate() } preTax() type() validated = true @@ -454,9 +480,118 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (employer.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (preTax.asKnown().isPresent) 1 else 0) + (if (type.asKnown().isPresent) 1 else 0) + /** + * The metadata of the pay statement item derived by the rules engine if available. Each + * attribute will be a key-value pair defined by a rule. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + 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 [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponseTest.kt index 96aa8b83..73041054 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponseTest.kt @@ -19,7 +19,11 @@ internal class HrisCompanyPayStatementItemListPageResponseTest { .attributes( PayStatementItemListResponse.Attributes.builder() .employer(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + PayStatementItemListResponse.Attributes.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .preTax(true) .type("type") .build() @@ -36,7 +40,11 @@ internal class HrisCompanyPayStatementItemListPageResponseTest { .attributes( PayStatementItemListResponse.Attributes.builder() .employer(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + PayStatementItemListResponse.Attributes.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .preTax(true) .type("type") .build() @@ -57,7 +65,11 @@ internal class HrisCompanyPayStatementItemListPageResponseTest { .attributes( PayStatementItemListResponse.Attributes.builder() .employer(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + PayStatementItemListResponse.Attributes.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .preTax(true) .type("type") .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementItemListResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementItemListResponseTest.kt index 060f17e7..56558e40 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementItemListResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementItemListResponseTest.kt @@ -17,7 +17,11 @@ internal class PayStatementItemListResponseTest { .attributes( PayStatementItemListResponse.Attributes.builder() .employer(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + PayStatementItemListResponse.Attributes.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .preTax(true) .type("type") .build() @@ -30,7 +34,11 @@ internal class PayStatementItemListResponseTest { .contains( PayStatementItemListResponse.Attributes.builder() .employer(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + PayStatementItemListResponse.Attributes.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .preTax(true) .type("type") .build() @@ -48,7 +56,11 @@ internal class PayStatementItemListResponseTest { .attributes( PayStatementItemListResponse.Attributes.builder() .employer(true) - .metadata(JsonValue.from(mapOf())) + .metadata( + PayStatementItemListResponse.Attributes.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .preTax(true) .type("type") .build() From 79e067e9790c16095a9a81cea65fb500c6f4aea6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 25 Apr 2025 19:13:18 +0000 Subject: [PATCH 07/27] feat(api): api update --- .stats.yml | 4 +- .../kotlin/com/tryfinch/api/models/Company.kt | 123 ++++++++++--- .../com/tryfinch/api/models/Location.kt | 171 ++++++++++-------- .../com/tryfinch/api/models/CompanyTest.kt | 12 +- .../api/models/CompanyUpdateResponseTest.kt | 12 +- .../api/models/EmploymentDataResponseTest.kt | 12 +- .../tryfinch/api/models/EmploymentDataTest.kt | 12 +- .../models/EmploymentUpdateResponseTest.kt | 12 +- ...sEmploymentRetrieveManyPageResponseTest.kt | 12 +- ...sIndividualRetrieveManyPageResponseTest.kt | 12 +- .../api/models/IndividualResponseTest.kt | 12 +- .../com/tryfinch/api/models/IndividualTest.kt | 12 +- .../models/IndividualUpdateResponseTest.kt | 12 +- .../com/tryfinch/api/models/LocationTest.kt | 12 +- .../models/SandboxCompanyUpdateParamsTest.kt | 35 +++- .../SandboxDirectoryCreateParamsTest.kt | 24 +-- .../SandboxEmploymentUpdateParamsTest.kt | 12 +- .../SandboxIndividualUpdateParamsTest.kt | 12 +- .../async/sandbox/CompanyServiceAsyncTest.kt | 4 +- .../sandbox/DirectoryServiceAsyncTest.kt | 8 +- .../sandbox/EmploymentServiceAsyncTest.kt | 4 +- .../sandbox/IndividualServiceAsyncTest.kt | 4 +- .../blocking/sandbox/CompanyServiceTest.kt | 4 +- .../blocking/sandbox/DirectoryServiceTest.kt | 8 +- .../blocking/sandbox/EmploymentServiceTest.kt | 4 +- .../blocking/sandbox/IndividualServiceTest.kt | 4 +- 26 files changed, 338 insertions(+), 215 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1629f07d..b4eb952a 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%2Ffinch-05a1c7485ea6dd75ad2fb1a0628570d88a3e7c4f1e1ecad433711c78deae50e6.yml -openapi_spec_hash: 6d6014d50e18c98219b496bb2a5dab1d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-3003136d45e38172828b1eb62bf9d3c876140355b4b1271559108f3df2c87208.yml +openapi_spec_hash: 29a85aba1eec35434ba1db898ea18b0b config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Company.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Company.kt index 19928fb7..647a3af3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Company.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Company.kt @@ -692,18 +692,29 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Account]. */ + /** + * Returns a mutable builder for constructing an instance of [Account]. + * + * The following fields are required: + * ```java + * .accountName() + * .accountNumber() + * .accountType() + * .institutionName() + * .routingNumber() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Account]. */ class Builder internal constructor() { - private var accountName: JsonField = JsonMissing.of() - private var accountNumber: JsonField = JsonMissing.of() - private var accountType: JsonField = JsonMissing.of() - private var institutionName: JsonField = JsonMissing.of() - private var routingNumber: JsonField = JsonMissing.of() + private var accountName: JsonField? = null + private var accountNumber: JsonField? = null + private var accountType: JsonField? = null + private var institutionName: JsonField? = null + private var routingNumber: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -835,14 +846,25 @@ private constructor( * Returns an immutable instance of [Account]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountName() + * .accountNumber() + * .accountType() + * .institutionName() + * .routingNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Account = Account( - accountName, - accountNumber, - accountType, - institutionName, - routingNumber, + checkRequired("accountName", accountName), + checkRequired("accountNumber", accountNumber), + checkRequired("accountType", accountType), + checkRequired("institutionName", institutionName), + checkRequired("routingNumber", routingNumber), additionalProperties.toMutableMap(), ) } @@ -1091,15 +1113,23 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Department]. */ + /** + * Returns a mutable builder for constructing an instance of [Department]. + * + * The following fields are required: + * ```java + * .name() + * .parent() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Department]. */ class Builder internal constructor() { - private var name: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() + private var name: JsonField? = null + private var parent: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1162,8 +1192,21 @@ private constructor( * Returns an immutable instance of [Department]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .parent() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Department = Department(name, parent, additionalProperties.toMutableMap()) + fun build(): Department = + Department( + checkRequired("name", name), + checkRequired("parent", parent), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1238,14 +1281,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Parent]. */ + /** + * Returns a mutable builder for constructing an instance of [Parent]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Parent]. */ class Builder internal constructor() { - private var name: JsonField = JsonMissing.of() + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1295,8 +1345,16 @@ private constructor( * Returns an immutable instance of [Parent]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Parent = Parent(name, additionalProperties.toMutableMap()) + fun build(): Parent = + Parent(checkRequired("name", name), additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -1420,15 +1478,23 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Entity]. */ + /** + * Returns a mutable builder for constructing an instance of [Entity]. + * + * The following fields are required: + * ```java + * .subtype() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Entity]. */ class Builder internal constructor() { - private var subtype: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var subtype: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1491,8 +1557,21 @@ private constructor( * Returns an immutable instance of [Entity]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .subtype() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Entity = Entity(subtype, type, additionalProperties.toMutableMap()) + fun build(): Entity = + Entity( + checkRequired("subtype", subtype), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Location.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Location.kt index 5af14dcb..e2c3a920 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Location.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Location.kt @@ -10,6 +10,7 @@ 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 @@ -22,10 +23,10 @@ private constructor( private val country: JsonField, private val line1: JsonField, private val line2: JsonField, - private val name: JsonField, private val postalCode: JsonField, - private val sourceId: JsonField, private val state: JsonField, + private val name: JsonField, + private val sourceId: JsonField, private val additionalProperties: MutableMap, ) { @@ -35,13 +36,13 @@ private constructor( @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), @JsonProperty("line1") @ExcludeMissing line1: JsonField = JsonMissing.of(), @JsonProperty("line2") @ExcludeMissing line2: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("postal_code") @ExcludeMissing postalCode: JsonField = JsonMissing.of(), - @JsonProperty("source_id") @ExcludeMissing sourceId: JsonField = JsonMissing.of(), @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), - ) : this(city, country, line1, line2, name, postalCode, sourceId, state, mutableMapOf()) + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("source_id") @ExcludeMissing sourceId: JsonField = JsonMissing.of(), + ) : this(city, country, line1, line2, postalCode, state, name, sourceId, mutableMapOf()) /** * City, district, suburb, town, or village. @@ -76,32 +77,32 @@ private constructor( fun line2(): Optional = line2.getOptional("line2") /** + * The postal code or zip code. + * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun name(): Optional = name.getOptional("name") + fun postalCode(): Optional = postalCode.getOptional("postal_code") /** - * The postal code or zip code. + * The state code. * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun postalCode(): Optional = postalCode.getOptional("postal_code") + fun state(): Optional = state.getOptional("state") /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun sourceId(): Optional = sourceId.getOptional("source_id") + fun name(): Optional = name.getOptional("name") /** - * The state code. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun state(): Optional = state.getOptional("state") + fun sourceId(): Optional = sourceId.getOptional("source_id") /** * Returns the raw JSON value of [city]. @@ -132,32 +133,32 @@ private constructor( @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [postalCode]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [postalCode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("postal_code") @ExcludeMissing fun _postalCode(): JsonField = postalCode /** - * Returns the raw JSON value of [postalCode]. + * Returns the raw JSON value of [state]. * - * Unlike [postalCode], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode(): JsonField = postalCode + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state /** - * Returns the raw JSON value of [sourceId]. + * Returns the raw JSON value of [name]. * - * Unlike [sourceId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("source_id") @ExcludeMissing fun _sourceId(): JsonField = sourceId + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [state]. + * Returns the raw JSON value of [sourceId]. * - * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [sourceId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + @JsonProperty("source_id") @ExcludeMissing fun _sourceId(): JsonField = sourceId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -173,21 +174,33 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Location]. */ + /** + * Returns a mutable builder for constructing an instance of [Location]. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * .line2() + * .postalCode() + * .state() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Location]. */ class Builder internal constructor() { - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var line1: JsonField = JsonMissing.of() - private var line2: JsonField = JsonMissing.of() + private var city: JsonField? = null + private var country: JsonField? = null + private var line1: JsonField? = null + private var line2: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null private var name: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() private var sourceId: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -196,10 +209,10 @@ private constructor( country = location.country line1 = location.line1 line2 = location.line2 - name = location.name postalCode = location.postalCode - sourceId = location.sourceId state = location.state + name = location.name + sourceId = location.sourceId additionalProperties = location.additionalProperties.toMutableMap() } @@ -259,19 +272,6 @@ private constructor( */ fun line2(line2: JsonField) = apply { this.line2 = line2 } - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - /** The postal code or zip code. */ fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) @@ -287,19 +287,6 @@ private constructor( */ fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - fun sourceId(sourceId: String?) = sourceId(JsonField.ofNullable(sourceId)) - - /** Alias for calling [Builder.sourceId] with `sourceId.orElse(null)`. */ - fun sourceId(sourceId: Optional) = sourceId(sourceId.getOrNull()) - - /** - * Sets [Builder.sourceId] to an arbitrary JSON value. - * - * You should usually call [Builder.sourceId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun sourceId(sourceId: JsonField) = apply { this.sourceId = sourceId } - /** The state code. */ fun state(state: String?) = state(JsonField.ofNullable(state)) @@ -314,6 +301,32 @@ private constructor( */ fun state(state: JsonField) = apply { this.state = state } + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun sourceId(sourceId: String?) = sourceId(JsonField.ofNullable(sourceId)) + + /** Alias for calling [Builder.sourceId] with `sourceId.orElse(null)`. */ + fun sourceId(sourceId: Optional) = sourceId(sourceId.getOrNull()) + + /** + * Sets [Builder.sourceId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun sourceId(sourceId: JsonField) = apply { this.sourceId = sourceId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -337,17 +350,29 @@ private constructor( * Returns an immutable instance of [Location]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .city() + * .country() + * .line1() + * .line2() + * .postalCode() + * .state() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Location = Location( - city, - country, - line1, - line2, + checkRequired("city", city), + checkRequired("country", country), + checkRequired("line1", line1), + checkRequired("line2", line2), + checkRequired("postalCode", postalCode), + checkRequired("state", state), name, - postalCode, sourceId, - state, additionalProperties.toMutableMap(), ) } @@ -363,10 +388,10 @@ private constructor( country() line1() line2() - name() postalCode() - sourceId() state() + name() + sourceId() validated = true } @@ -389,25 +414,25 @@ private constructor( (if (country.asKnown().isPresent) 1 else 0) + (if (line1.asKnown().isPresent) 1 else 0) + (if (line2.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + (if (postalCode.asKnown().isPresent) 1 else 0) + - (if (sourceId.asKnown().isPresent) 1 else 0) + - (if (state.asKnown().isPresent) 1 else 0) + (if (state.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (sourceId.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Location && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && name == other.name && postalCode == other.postalCode && sourceId == other.sourceId && state == other.state && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Location && city == other.city && country == other.country && line1 == other.line1 && line2 == other.line2 && postalCode == other.postalCode && state == other.state && name == other.name && sourceId == other.sourceId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, name, postalCode, sourceId, state, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(city, country, line1, line2, postalCode, state, name, sourceId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Location{city=$city, country=$country, line1=$line1, line2=$line2, name=$name, postalCode=$postalCode, sourceId=$sourceId, state=$state, additionalProperties=$additionalProperties}" + "Location{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, name=$name, sourceId=$sourceId, additionalProperties=$additionalProperties}" } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyTest.kt index ec22941d..90087323 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyTest.kt @@ -44,10 +44,10 @@ internal class CompanyTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .primaryEmail("dev@stainless.com") @@ -88,10 +88,10 @@ internal class CompanyTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) assertThat(company.primaryEmail()).contains("dev@stainless.com") @@ -133,10 +133,10 @@ internal class CompanyTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .primaryEmail("dev@stainless.com") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyUpdateResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyUpdateResponseTest.kt index 40d8cb6b..3b710600 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyUpdateResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyUpdateResponseTest.kt @@ -45,10 +45,10 @@ internal class CompanyUpdateResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .primaryEmail("dev@stainless.com") @@ -88,10 +88,10 @@ internal class CompanyUpdateResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) assertThat(companyUpdateResponse.primaryEmail()).contains("dev@stainless.com") @@ -134,10 +134,10 @@ internal class CompanyUpdateResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .primaryEmail("dev@stainless.com") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt index eb681174..29114677 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt @@ -59,10 +59,10 @@ internal class EmploymentDataResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( @@ -127,10 +127,10 @@ internal class EmploymentDataResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( @@ -200,10 +200,10 @@ internal class EmploymentDataResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt index 1cd072e8..8b2e1a52 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt @@ -58,10 +58,10 @@ internal class EmploymentDataTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( @@ -126,10 +126,10 @@ internal class EmploymentDataTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) assertThat(employmentData.manager()) @@ -191,10 +191,10 @@ internal class EmploymentDataTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentUpdateResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentUpdateResponseTest.kt index 36d22b27..2b9c3056 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentUpdateResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentUpdateResponseTest.kt @@ -58,10 +58,10 @@ internal class EmploymentUpdateResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( @@ -125,10 +125,10 @@ internal class EmploymentUpdateResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) assertThat(employmentUpdateResponse.manager()) @@ -191,10 +191,10 @@ internal class EmploymentUpdateResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt index 21c2d616..4feb1dbc 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt @@ -63,10 +63,10 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( @@ -135,10 +135,10 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( @@ -213,10 +213,10 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt index 4b16d20c..8306ddf1 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt @@ -44,10 +44,10 @@ internal class HrisIndividualRetrieveManyPageResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .ssn("ssn") @@ -91,10 +91,10 @@ internal class HrisIndividualRetrieveManyPageResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .ssn("ssn") @@ -142,10 +142,10 @@ internal class HrisIndividualRetrieveManyPageResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .ssn("ssn") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt index 1f022127..438aca92 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt @@ -42,10 +42,10 @@ internal class IndividualResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .ssn("ssn") @@ -85,10 +85,10 @@ internal class IndividualResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .ssn("ssn") @@ -132,10 +132,10 @@ internal class IndividualResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .ssn("ssn") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt index e8760c8f..5f90333c 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt @@ -38,10 +38,10 @@ internal class IndividualTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .ssn("ssn") @@ -74,10 +74,10 @@ internal class IndividualTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) assertThat(individual.ssn()).contains("ssn") @@ -112,10 +112,10 @@ internal class IndividualTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .ssn("ssn") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUpdateResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUpdateResponseTest.kt index d61dcf48..94683bcd 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUpdateResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUpdateResponseTest.kt @@ -41,10 +41,10 @@ internal class IndividualUpdateResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .ssn("ssn") @@ -82,10 +82,10 @@ internal class IndividualUpdateResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) assertThat(individualUpdateResponse.ssn()).contains("ssn") @@ -123,10 +123,10 @@ internal class IndividualUpdateResponseTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .ssn("ssn") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/LocationTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/LocationTest.kt index 8dc6ed3d..7bdf33e7 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/LocationTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/LocationTest.kt @@ -17,20 +17,20 @@ internal class LocationTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() assertThat(location.city()).contains("city") assertThat(location.country()).contains("country") assertThat(location.line1()).contains("line1") assertThat(location.line2()).contains("line2") - assertThat(location.name()).contains("name") assertThat(location.postalCode()).contains("postal_code") - assertThat(location.sourceId()).contains("source_id") assertThat(location.state()).contains("state") + assertThat(location.name()).contains("name") + assertThat(location.sourceId()).contains("source_id") } @Test @@ -42,10 +42,10 @@ internal class LocationTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() val roundtrippedLocation = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParamsTest.kt index 149dc4c6..317789e9 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParamsTest.kt @@ -42,10 +42,10 @@ internal class SandboxCompanyUpdateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .primaryEmail("dev@stainless.com") @@ -90,10 +90,10 @@ internal class SandboxCompanyUpdateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .primaryEmail("dev@stainless.com") @@ -137,10 +137,10 @@ internal class SandboxCompanyUpdateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) assertThat(body.primaryEmail()).contains("dev@stainless.com") @@ -156,7 +156,16 @@ internal class SandboxCompanyUpdateParamsTest { .ein("ein") .entity(SandboxCompanyUpdateParams.Entity.builder().build()) .legalName("legal_name") - .addLocation(Location.builder().build()) + .addLocation( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) .primaryEmail("dev@stainless.com") .primaryPhoneNumber("primary_phone_number") .build() @@ -170,7 +179,17 @@ internal class SandboxCompanyUpdateParamsTest { assertThat(body.ein()).contains("ein") assertThat(body.entity()).contains(SandboxCompanyUpdateParams.Entity.builder().build()) assertThat(body.legalName()).contains("legal_name") - assertThat(body.locations().getOrNull()).containsExactly(Location.builder().build()) + assertThat(body.locations().getOrNull()) + .containsExactly( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .build() + ) assertThat(body.primaryEmail()).contains("dev@stainless.com") assertThat(body.primaryPhoneNumber()).contains("primary_phone_number") } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParamsTest.kt index b054e2fd..2cabe240 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParamsTest.kt @@ -81,10 +81,10 @@ internal class SandboxDirectoryCreateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( @@ -109,10 +109,10 @@ internal class SandboxDirectoryCreateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .sourceId("source_id") @@ -203,10 +203,10 @@ internal class SandboxDirectoryCreateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( @@ -233,10 +233,10 @@ internal class SandboxDirectoryCreateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .sourceId("source_id") @@ -319,10 +319,10 @@ internal class SandboxDirectoryCreateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( @@ -347,10 +347,10 @@ internal class SandboxDirectoryCreateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .sourceId("source_id") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParamsTest.kt index fbe2b905..5a5f9fab 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParamsTest.kt @@ -55,10 +55,10 @@ internal class SandboxEmploymentUpdateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( @@ -129,10 +129,10 @@ internal class SandboxEmploymentUpdateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( @@ -197,10 +197,10 @@ internal class SandboxEmploymentUpdateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) assertThat(body.manager()) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParamsTest.kt index 65df3b36..f1846ca4 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParamsTest.kt @@ -38,10 +38,10 @@ internal class SandboxIndividualUpdateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .ssn("ssn") @@ -88,10 +88,10 @@ internal class SandboxIndividualUpdateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .ssn("ssn") @@ -128,10 +128,10 @@ internal class SandboxIndividualUpdateParamsTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) assertThat(body.ssn()).contains("ssn") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncTest.kt index 644fb0d1..91075126 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncTest.kt @@ -57,10 +57,10 @@ internal class CompanyServiceAsyncTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .primaryEmail("dev@stainless.com") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncTest.kt index 5572fa2d..ce338d43 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncTest.kt @@ -108,10 +108,10 @@ internal class DirectoryServiceAsyncTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( @@ -140,10 +140,10 @@ internal class DirectoryServiceAsyncTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .sourceId("source_id") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncTest.kt index e85386fd..8db4951b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncTest.kt @@ -71,10 +71,10 @@ internal class EmploymentServiceAsyncTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncTest.kt index 7f489dbe..5ae62990 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncTest.kt @@ -51,10 +51,10 @@ internal class IndividualServiceAsyncTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .ssn("ssn") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceTest.kt index 092485b9..8212b1f9 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceTest.kt @@ -57,10 +57,10 @@ internal class CompanyServiceTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .primaryEmail("dev@stainless.com") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceTest.kt index dc3d0a26..2e1068ba 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceTest.kt @@ -108,10 +108,10 @@ internal class DirectoryServiceTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( @@ -140,10 +140,10 @@ internal class DirectoryServiceTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .sourceId("source_id") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceTest.kt index a14004ae..c372d897 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceTest.kt @@ -71,10 +71,10 @@ internal class EmploymentServiceTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .manager( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceTest.kt index d4138d0c..2c097a2e 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceTest.kt @@ -51,10 +51,10 @@ internal class IndividualServiceTest { .country("country") .line1("line1") .line2("line2") - .name("name") .postalCode("postal_code") - .sourceId("source_id") .state("state") + .name("name") + .sourceId("source_id") .build() ) .ssn("ssn") From 30df955523928c30ef0e29f1154ff5fee88d80d1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 25 Apr 2025 20:38:52 +0000 Subject: [PATCH 08/27] feat(api): api update --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index b4eb952a..c789a7ed 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%2Ffinch-3003136d45e38172828b1eb62bf9d3c876140355b4b1271559108f3df2c87208.yml -openapi_spec_hash: 29a85aba1eec35434ba1db898ea18b0b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-d31af54a2b29a3535df6342584c2511b59a10a7c11c9c983f1cf209199c6ed0e.yml +openapi_spec_hash: 6643320491f28a8bca49846e1b718c70 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 From 53c31470ca6f0cf5985f8ebd60446f8f08e84913 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 28 Apr 2025 16:02:10 +0000 Subject: [PATCH 09/27] feat(api): api update --- .stats.yml | 4 +- .../api/models/IndividualInDirectory.kt | 90 ++++++++++++++----- .../kotlin/com/tryfinch/api/models/Paging.kt | 82 ++++++++++------- .../api/models/DocumentListResponseTest.kt | 6 +- ...irectoryListIndividualsPageResponseTest.kt | 6 +- .../HrisDirectoryListPageResponseTest.kt | 6 +- ...ayStatementRetrieveManyPageResponseTest.kt | 6 +- .../api/models/IndividualInDirectoryTest.kt | 2 +- .../com/tryfinch/api/models/PagingTest.kt | 6 +- .../models/PayStatementResponseBodyTest.kt | 6 +- .../api/models/PayStatementResponseTest.kt | 6 +- 11 files changed, 139 insertions(+), 81 deletions(-) diff --git a/.stats.yml b/.stats.yml index c789a7ed..b446e8d7 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%2Ffinch-d31af54a2b29a3535df6342584c2511b59a10a7c11c9c983f1cf209199c6ed0e.yml -openapi_spec_hash: 6643320491f28a8bca49846e1b718c70 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-47c01c819b97af4a1a342357c958d7072f88f43bfdc5885462f9330dcf99773c.yml +openapi_spec_hash: 15b236a1f536d8fb2e4356ea57de0836 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualInDirectory.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualInDirectory.kt index fad446f4..7a2f70b6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualInDirectory.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualInDirectory.kt @@ -10,6 +10,7 @@ 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 @@ -46,10 +47,10 @@ private constructor( /** * A stable Finch `id` (UUID v4) for an individual in the company. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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 id(): Optional = id.getOptional("id") + fun id(): String = id.getRequired("id") /** * The department object. @@ -164,20 +165,33 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [IndividualInDirectory]. */ + /** + * Returns a mutable builder for constructing an instance of [IndividualInDirectory]. + * + * The following fields are required: + * ```java + * .id() + * .department() + * .firstName() + * .isActive() + * .lastName() + * .manager() + * .middleName() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [IndividualInDirectory]. */ class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var department: JsonField = JsonMissing.of() - private var firstName: JsonField = JsonMissing.of() - private var isActive: JsonField = JsonMissing.of() - private var lastName: JsonField = JsonMissing.of() - private var manager: JsonField = JsonMissing.of() - private var middleName: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var department: JsonField? = null + private var firstName: JsonField? = null + private var isActive: JsonField? = null + private var lastName: JsonField? = null + private var manager: JsonField? = null + private var middleName: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -321,16 +335,29 @@ private constructor( * Returns an immutable instance of [IndividualInDirectory]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .department() + * .firstName() + * .isActive() + * .lastName() + * .manager() + * .middleName() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): IndividualInDirectory = IndividualInDirectory( - id, - department, - firstName, - isActive, - lastName, - manager, - middleName, + checkRequired("id", id), + checkRequired("department", department), + checkRequired("firstName", firstName), + checkRequired("isActive", isActive), + checkRequired("lastName", lastName), + checkRequired("manager", manager), + checkRequired("middleName", middleName), additionalProperties.toMutableMap(), ) } @@ -534,10 +561,10 @@ private constructor( /** * A stable Finch `id` (UUID v4) for an individual in the company. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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 id(): Optional = id.getOptional("id") + fun id(): String = id.getRequired("id") /** * Returns the raw JSON value of [id]. @@ -560,14 +587,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Manager]. */ + /** + * Returns a mutable builder for constructing an instance of [Manager]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Manager]. */ class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -611,8 +645,16 @@ private constructor( * Returns an immutable instance of [Manager]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Manager = Manager(id, additionalProperties.toMutableMap()) + fun build(): Manager = + Manager(checkRequired("id", id), additionalProperties.toMutableMap()) } private var validated: Boolean = false diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Paging.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Paging.kt index c7cc6fb4..afaf3a26 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Paging.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Paging.kt @@ -10,6 +10,7 @@ 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 @@ -17,16 +18,24 @@ import java.util.Optional class Paging private constructor( - private val count: JsonField, private val offset: JsonField, + private val count: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("count") @ExcludeMissing count: JsonField = JsonMissing.of(), @JsonProperty("offset") @ExcludeMissing offset: JsonField = JsonMissing.of(), - ) : this(count, offset, mutableMapOf()) + @JsonProperty("count") @ExcludeMissing count: JsonField = JsonMissing.of(), + ) : this(offset, count, mutableMapOf()) + + /** + * The current start index of the returned list of elements + * + * @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 offset(): Long = offset.getRequired("offset") /** * The total number of elements for the entire query (not just the given page) @@ -37,12 +46,11 @@ private constructor( fun count(): Optional = count.getOptional("count") /** - * The current start index of the returned list of elements + * Returns the raw JSON value of [offset]. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. */ - fun offset(): Optional = offset.getOptional("offset") + @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField = offset /** * Returns the raw JSON value of [count]. @@ -51,13 +59,6 @@ private constructor( */ @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count - /** - * Returns the raw JSON value of [offset]. - * - * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField = offset - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -72,45 +73,52 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Paging]. */ + /** + * Returns a mutable builder for constructing an instance of [Paging]. + * + * The following fields are required: + * ```java + * .offset() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Paging]. */ class Builder internal constructor() { + private var offset: JsonField? = null private var count: JsonField = JsonMissing.of() - private var offset: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(paging: Paging) = apply { - count = paging.count offset = paging.offset + count = paging.count additionalProperties = paging.additionalProperties.toMutableMap() } - /** The total number of elements for the entire query (not just the given page) */ - fun count(count: Long) = count(JsonField.of(count)) + /** The current start index of the returned list of elements */ + fun offset(offset: Long) = offset(JsonField.of(offset)) /** - * Sets [Builder.count] to an arbitrary JSON value. + * Sets [Builder.offset] to an arbitrary JSON value. * - * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * You should usually call [Builder.offset] with a well-typed [Long] value instead. This * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun count(count: JsonField) = apply { this.count = count } + fun offset(offset: JsonField) = apply { this.offset = offset } - /** The current start index of the returned list of elements */ - fun offset(offset: Long) = offset(JsonField.of(offset)) + /** The total number of elements for the entire query (not just the given page) */ + fun count(count: Long) = count(JsonField.of(count)) /** - * Sets [Builder.offset] to an arbitrary JSON value. + * Sets [Builder.count] to an arbitrary JSON value. * - * You should usually call [Builder.offset] with a well-typed [Long] value instead. This + * You should usually call [Builder.count] with a well-typed [Long] value instead. This * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun offset(offset: JsonField) = apply { this.offset = offset } + fun count(count: JsonField) = apply { this.count = count } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -135,8 +143,16 @@ private constructor( * Returns an immutable instance of [Paging]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .offset() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Paging = Paging(count, offset, additionalProperties.toMutableMap()) + fun build(): Paging = + Paging(checkRequired("offset", offset), count, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -146,8 +162,8 @@ private constructor( return@apply } - count() offset() + count() validated = true } @@ -166,22 +182,22 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (count.asKnown().isPresent) 1 else 0) + (if (offset.asKnown().isPresent) 1 else 0) + (if (offset.asKnown().isPresent) 1 else 0) + (if (count.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Paging && count == other.count && offset == other.offset && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Paging && offset == other.offset && count == other.count && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(count, offset, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(offset, count, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Paging{count=$count, offset=$offset, additionalProperties=$additionalProperties}" + "Paging{offset=$offset, count=$count, additionalProperties=$additionalProperties}" } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DocumentListResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DocumentListResponseTest.kt index a92d7839..3656298e 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DocumentListResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DocumentListResponseTest.kt @@ -22,7 +22,7 @@ internal class DocumentListResponseTest { .year(0.0) .build() ) - .paging(Paging.builder().count(0L).offset(0L).build()) + .paging(Paging.builder().offset(0L).count(0L).build()) .build() assertThat(documentListResponse.documents()) @@ -36,7 +36,7 @@ internal class DocumentListResponseTest { .build() ) assertThat(documentListResponse.paging()) - .isEqualTo(Paging.builder().count(0L).offset(0L).build()) + .isEqualTo(Paging.builder().offset(0L).count(0L).build()) } @Test @@ -53,7 +53,7 @@ internal class DocumentListResponseTest { .year(0.0) .build() ) - .paging(Paging.builder().count(0L).offset(0L).build()) + .paging(Paging.builder().offset(0L).count(0L).build()) .build() val roundtrippedDocumentListResponse = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponseTest.kt index 6c4a338d..ba984c74 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponseTest.kt @@ -28,7 +28,7 @@ internal class HrisDirectoryListIndividualsPageResponseTest { .middleName("middle_name") .build() ) - .paging(Paging.builder().count(0L).offset(0L).build()) + .paging(Paging.builder().offset(0L).count(0L).build()) .build() assertThat(hrisDirectoryListIndividualsPageResponse.individuals()) @@ -48,7 +48,7 @@ internal class HrisDirectoryListIndividualsPageResponseTest { .build() ) assertThat(hrisDirectoryListIndividualsPageResponse.paging()) - .isEqualTo(Paging.builder().count(0L).offset(0L).build()) + .isEqualTo(Paging.builder().offset(0L).count(0L).build()) } @Test @@ -71,7 +71,7 @@ internal class HrisDirectoryListIndividualsPageResponseTest { .middleName("middle_name") .build() ) - .paging(Paging.builder().count(0L).offset(0L).build()) + .paging(Paging.builder().offset(0L).count(0L).build()) .build() val roundtrippedHrisDirectoryListIndividualsPageResponse = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponseTest.kt index 5149910b..81d6003e 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponseTest.kt @@ -28,7 +28,7 @@ internal class HrisDirectoryListPageResponseTest { .middleName("middle_name") .build() ) - .paging(Paging.builder().count(0L).offset(0L).build()) + .paging(Paging.builder().offset(0L).count(0L).build()) .build() assertThat(hrisDirectoryListPageResponse.individuals()) @@ -48,7 +48,7 @@ internal class HrisDirectoryListPageResponseTest { .build() ) assertThat(hrisDirectoryListPageResponse.paging()) - .isEqualTo(Paging.builder().count(0L).offset(0L).build()) + .isEqualTo(Paging.builder().offset(0L).count(0L).build()) } @Test @@ -71,7 +71,7 @@ internal class HrisDirectoryListPageResponseTest { .middleName("middle_name") .build() ) - .paging(Paging.builder().count(0L).offset(0L).build()) + .paging(Paging.builder().offset(0L).count(0L).build()) .build() val roundtrippedHrisDirectoryListPageResponse = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt index 0ce7087a..d9eb5615 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt @@ -18,7 +18,7 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { PayStatementResponse.builder() .body( PayStatementResponseBody.builder() - .paging(Paging.builder().count(0L).offset(0L).build()) + .paging(Paging.builder().offset(0L).count(0L).build()) .addPayStatement( PayStatement.builder() .addEarning( @@ -170,7 +170,7 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { PayStatementResponse.builder() .body( PayStatementResponseBody.builder() - .paging(Paging.builder().count(0L).offset(0L).build()) + .paging(Paging.builder().offset(0L).count(0L).build()) .addPayStatement( PayStatement.builder() .addEarning( @@ -319,7 +319,7 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { PayStatementResponse.builder() .body( PayStatementResponseBody.builder() - .paging(Paging.builder().count(0L).offset(0L).build()) + .paging(Paging.builder().offset(0L).count(0L).build()) .addPayStatement( PayStatement.builder() .addEarning( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualInDirectoryTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualInDirectoryTest.kt index dc8f18ea..c8509609 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualInDirectoryTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualInDirectoryTest.kt @@ -26,7 +26,7 @@ internal class IndividualInDirectoryTest { .middleName("middle_name") .build() - assertThat(individualInDirectory.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(individualInDirectory.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(individualInDirectory.department()) .contains(IndividualInDirectory.Department.builder().name("name").build()) assertThat(individualInDirectory.firstName()).contains("first_name") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PagingTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PagingTest.kt index 0e455120..05e2b6ab 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PagingTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PagingTest.kt @@ -11,16 +11,16 @@ internal class PagingTest { @Test fun create() { - val paging = Paging.builder().count(0L).offset(0L).build() + val paging = Paging.builder().offset(0L).count(0L).build() + assertThat(paging.offset()).isEqualTo(0L) assertThat(paging.count()).contains(0L) - assertThat(paging.offset()).contains(0L) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val paging = Paging.builder().count(0L).offset(0L).build() + val paging = Paging.builder().offset(0L).count(0L).build() val roundtrippedPaging = jsonMapper.readValue(jsonMapper.writeValueAsString(paging), jacksonTypeRef()) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt index 1d1cb6f1..637118d4 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt @@ -15,7 +15,7 @@ internal class PayStatementResponseBodyTest { fun create() { val payStatementResponseBody = PayStatementResponseBody.builder() - .paging(Paging.builder().count(0L).offset(0L).build()) + .paging(Paging.builder().offset(0L).count(0L).build()) .addPayStatement( PayStatement.builder() .addEarning( @@ -140,7 +140,7 @@ internal class PayStatementResponseBodyTest { .build() assertThat(payStatementResponseBody.paging()) - .contains(Paging.builder().count(0L).offset(0L).build()) + .contains(Paging.builder().offset(0L).count(0L).build()) assertThat(payStatementResponseBody.payStatements().getOrNull()) .containsExactly( PayStatement.builder() @@ -267,7 +267,7 @@ internal class PayStatementResponseBodyTest { val jsonMapper = jsonMapper() val payStatementResponseBody = PayStatementResponseBody.builder() - .paging(Paging.builder().count(0L).offset(0L).build()) + .paging(Paging.builder().offset(0L).count(0L).build()) .addPayStatement( PayStatement.builder() .addEarning( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt index 7eaf287b..217970d6 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt @@ -16,7 +16,7 @@ internal class PayStatementResponseTest { PayStatementResponse.builder() .body( PayStatementResponseBody.builder() - .paging(Paging.builder().count(0L).offset(0L).build()) + .paging(Paging.builder().offset(0L).count(0L).build()) .addPayStatement( PayStatement.builder() .addEarning( @@ -152,7 +152,7 @@ internal class PayStatementResponseTest { assertThat(payStatementResponse.body()) .contains( PayStatementResponseBody.builder() - .paging(Paging.builder().count(0L).offset(0L).build()) + .paging(Paging.builder().offset(0L).count(0L).build()) .addPayStatement( PayStatement.builder() .addEarning( @@ -288,7 +288,7 @@ internal class PayStatementResponseTest { PayStatementResponse.builder() .body( PayStatementResponseBody.builder() - .paging(Paging.builder().count(0L).offset(0L).build()) + .paging(Paging.builder().offset(0L).count(0L).build()) .addPayStatement( PayStatement.builder() .addEarning( From f8988d7fc959241b683da19b068c95a8ac023e24 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 28 Apr 2025 17:35:24 +0000 Subject: [PATCH 10/27] feat(api): api update --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index b446e8d7..55913df9 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%2Ffinch-47c01c819b97af4a1a342357c958d7072f88f43bfdc5885462f9330dcf99773c.yml -openapi_spec_hash: 15b236a1f536d8fb2e4356ea57de0836 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-18aa62b45276cc7202c0dd786f514671b30e3d5bfc761986c4ca6b587436f935.yml +openapi_spec_hash: c0722ad9e1e066d79b661f5e955dbf64 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 From 70708d78bc704b34f936e835b614e54c87c2db03 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 28 Apr 2025 19:34:54 +0000 Subject: [PATCH 11/27] feat(api): api update --- .stats.yml | 4 +- .../com/tryfinch/api/models/Individual.kt | 1111 +++++++++-------- .../tryfinch/api/models/IndividualResponse.kt | 55 +- ...sIndividualRetrieveManyPageResponseTest.kt | 42 +- .../api/models/IndividualResponseTest.kt | 48 +- .../com/tryfinch/api/models/IndividualTest.kt | 28 +- 6 files changed, 693 insertions(+), 595 deletions(-) diff --git a/.stats.yml b/.stats.yml index 55913df9..4804d0f2 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%2Ffinch-18aa62b45276cc7202c0dd786f514671b30e3d5bfc761986c4ca6b587436f935.yml -openapi_spec_hash: c0722ad9e1e066d79b661f5e955dbf64 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-ebcacef9e289357a2688343001fd928ada6811c88b841cd738a9a09178b1991c.yml +openapi_spec_hash: 2d9c296dca75299fd6565aafc4875f19 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt index bffd234c..475f3a6e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections @@ -23,8 +24,6 @@ class Individual private constructor( private val id: JsonField, private val dob: JsonField, - private val emails: JsonField>, - private val encryptedSsn: JsonField, private val ethnicity: JsonField, private val firstName: JsonField, private val gender: JsonField, @@ -33,6 +32,8 @@ private constructor( private val phoneNumbers: JsonField>, private val preferredName: JsonField, private val residence: JsonField, + private val emails: JsonField>, + private val encryptedSsn: JsonField, private val ssn: JsonField, private val additionalProperties: MutableMap, ) { @@ -41,10 +42,6 @@ private constructor( private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("dob") @ExcludeMissing dob: JsonField = JsonMissing.of(), - @JsonProperty("emails") @ExcludeMissing emails: JsonField> = JsonMissing.of(), - @JsonProperty("encrypted_ssn") - @ExcludeMissing - encryptedSsn: JsonField = JsonMissing.of(), @JsonProperty("ethnicity") @ExcludeMissing ethnicity: JsonField = JsonMissing.of(), @@ -63,12 +60,14 @@ private constructor( @JsonProperty("residence") @ExcludeMissing residence: JsonField = JsonMissing.of(), + @JsonProperty("emails") @ExcludeMissing emails: JsonField> = JsonMissing.of(), + @JsonProperty("encrypted_ssn") + @ExcludeMissing + encryptedSsn: JsonField = JsonMissing.of(), @JsonProperty("ssn") @ExcludeMissing ssn: JsonField = JsonMissing.of(), ) : this( id, dob, - emails, - encryptedSsn, ethnicity, firstName, gender, @@ -77,6 +76,8 @@ private constructor( phoneNumbers, preferredName, residence, + emails, + encryptedSsn, ssn, mutableMapOf(), ) @@ -84,10 +85,10 @@ private constructor( /** * A stable Finch `id` (UUID v4) for an individual in the company. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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 id(): Optional = id.getOptional("id") + fun id(): String = id.getRequired("id") /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -95,22 +96,6 @@ private constructor( */ fun dob(): Optional = dob.getOptional("dob") - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun emails(): Optional> = emails.getOptional("emails") - - /** - * Social Security Number of the individual in **encrypted** format. This field is only - * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set in - * the body. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun encryptedSsn(): Optional = encryptedSsn.getOptional("encrypted_ssn") - /** * The EEOC-defined ethnicity of the individual. * @@ -171,6 +156,22 @@ private constructor( */ fun residence(): Optional = residence.getOptional("residence") + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun emails(): Optional> = emails.getOptional("emails") + + /** + * Social Security Number of the individual in **encrypted** format. This field is only + * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set in + * the body. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun encryptedSsn(): Optional = encryptedSsn.getOptional("encrypted_ssn") + /** * Social Security Number of the individual. This field is only available with the `ssn` scope * enabled and the `options: { include: ['ssn'] }` param set in the body. @@ -195,22 +196,6 @@ private constructor( */ @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob - /** - * Returns the raw JSON value of [emails]. - * - * Unlike [emails], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails - - /** - * Returns the raw JSON value of [encryptedSsn]. - * - * Unlike [encryptedSsn], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("encrypted_ssn") - @ExcludeMissing - fun _encryptedSsn(): JsonField = encryptedSsn - /** * Returns the raw JSON value of [ethnicity]. * @@ -271,6 +256,22 @@ private constructor( */ @JsonProperty("residence") @ExcludeMissing fun _residence(): JsonField = residence + /** + * Returns the raw JSON value of [emails]. + * + * Unlike [emails], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails + + /** + * Returns the raw JSON value of [encryptedSsn]. + * + * Unlike [encryptedSsn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("encrypted_ssn") + @ExcludeMissing + fun _encryptedSsn(): JsonField = encryptedSsn + /** * Returns the raw JSON value of [ssn]. * @@ -292,25 +293,41 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Individual]. */ + /** + * Returns a mutable builder for constructing an instance of [Individual]. + * + * The following fields are required: + * ```java + * .id() + * .dob() + * .ethnicity() + * .firstName() + * .gender() + * .lastName() + * .middleName() + * .phoneNumbers() + * .preferredName() + * .residence() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Individual]. */ class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var dob: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var dob: JsonField? = null + private var ethnicity: JsonField? = null + private var firstName: JsonField? = null + private var gender: JsonField? = null + private var lastName: JsonField? = null + private var middleName: JsonField? = null + private var phoneNumbers: JsonField>? = null + private var preferredName: JsonField? = null + private var residence: JsonField? = null private var emails: JsonField>? = null private var encryptedSsn: JsonField = JsonMissing.of() - private var ethnicity: JsonField = JsonMissing.of() - private var firstName: JsonField = JsonMissing.of() - private var gender: JsonField = JsonMissing.of() - private var lastName: JsonField = JsonMissing.of() - private var middleName: JsonField = JsonMissing.of() - private var phoneNumbers: JsonField>? = null - private var preferredName: JsonField = JsonMissing.of() - private var residence: JsonField = JsonMissing.of() private var ssn: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -318,8 +335,6 @@ private constructor( internal fun from(individual: Individual) = apply { id = individual.id dob = individual.dob - emails = individual.emails.map { it.toMutableList() } - encryptedSsn = individual.encryptedSsn ethnicity = individual.ethnicity firstName = individual.firstName gender = individual.gender @@ -328,6 +343,8 @@ private constructor( phoneNumbers = individual.phoneNumbers.map { it.toMutableList() } preferredName = individual.preferredName residence = individual.residence + emails = individual.emails.map { it.toMutableList() } + encryptedSsn = individual.encryptedSsn ssn = individual.ssn additionalProperties = individual.additionalProperties.toMutableMap() } @@ -356,55 +373,6 @@ private constructor( */ fun dob(dob: JsonField) = apply { this.dob = dob } - fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) - - /** Alias for calling [Builder.emails] with `emails.orElse(null)`. */ - fun emails(emails: Optional>) = emails(emails.getOrNull()) - - /** - * Sets [Builder.emails] to an arbitrary JSON value. - * - * You should usually call [Builder.emails] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun emails(emails: JsonField>) = apply { - this.emails = emails.map { it.toMutableList() } - } - - /** - * Adds a single [Email] to [emails]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEmail(email: Email) = apply { - emails = - (emails ?: JsonField.of(mutableListOf())).also { - checkKnown("emails", it).add(email) - } - } - - /** - * Social Security Number of the individual in **encrypted** format. This field is only - * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set - * in the body. - */ - fun encryptedSsn(encryptedSsn: String?) = encryptedSsn(JsonField.ofNullable(encryptedSsn)) - - /** Alias for calling [Builder.encryptedSsn] with `encryptedSsn.orElse(null)`. */ - fun encryptedSsn(encryptedSsn: Optional) = encryptedSsn(encryptedSsn.getOrNull()) - - /** - * Sets [Builder.encryptedSsn] to an arbitrary JSON value. - * - * You should usually call [Builder.encryptedSsn] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun encryptedSsn(encryptedSsn: JsonField) = apply { - this.encryptedSsn = encryptedSsn - } - /** The EEOC-defined ethnicity of the individual. */ fun ethnicity(ethnicity: Ethnicity?) = ethnicity(JsonField.ofNullable(ethnicity)) @@ -541,6 +509,55 @@ private constructor( */ fun residence(residence: JsonField) = apply { this.residence = residence } + fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) + + /** Alias for calling [Builder.emails] with `emails.orElse(null)`. */ + fun emails(emails: Optional>) = emails(emails.getOrNull()) + + /** + * Sets [Builder.emails] to an arbitrary JSON value. + * + * You should usually call [Builder.emails] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun emails(emails: JsonField>) = apply { + this.emails = emails.map { it.toMutableList() } + } + + /** + * Adds a single [Email] to [emails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEmail(email: Email) = apply { + emails = + (emails ?: JsonField.of(mutableListOf())).also { + checkKnown("emails", it).add(email) + } + } + + /** + * Social Security Number of the individual in **encrypted** format. This field is only + * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set + * in the body. + */ + fun encryptedSsn(encryptedSsn: String?) = encryptedSsn(JsonField.ofNullable(encryptedSsn)) + + /** Alias for calling [Builder.encryptedSsn] with `encryptedSsn.orElse(null)`. */ + fun encryptedSsn(encryptedSsn: Optional) = encryptedSsn(encryptedSsn.getOrNull()) + + /** + * Sets [Builder.encryptedSsn] to an arbitrary JSON value. + * + * You should usually call [Builder.encryptedSsn] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun encryptedSsn(encryptedSsn: JsonField) = apply { + this.encryptedSsn = encryptedSsn + } + /** * Social Security Number of the individual. This field is only available with the `ssn` * scope enabled and the `options: { include: ['ssn'] }` param set in the body. @@ -582,21 +599,37 @@ private constructor( * Returns an immutable instance of [Individual]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dob() + * .ethnicity() + * .firstName() + * .gender() + * .lastName() + * .middleName() + * .phoneNumbers() + * .preferredName() + * .residence() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Individual = Individual( - id, - dob, + checkRequired("id", id), + checkRequired("dob", dob), + checkRequired("ethnicity", ethnicity), + checkRequired("firstName", firstName), + checkRequired("gender", gender), + checkRequired("lastName", lastName), + checkRequired("middleName", middleName), + checkRequired("phoneNumbers", phoneNumbers).map { it.toImmutable() }, + checkRequired("preferredName", preferredName), + checkRequired("residence", residence), (emails ?: JsonMissing.of()).map { it.toImmutable() }, encryptedSsn, - ethnicity, - firstName, - gender, - lastName, - middleName, - (phoneNumbers ?: JsonMissing.of()).map { it.toImmutable() }, - preferredName, - residence, ssn, additionalProperties.toMutableMap(), ) @@ -611,8 +644,6 @@ private constructor( id() dob() - emails().ifPresent { it.forEach { it.validate() } } - encryptedSsn() ethnicity().ifPresent { it.validate() } firstName() gender().ifPresent { it.validate() } @@ -621,6 +652,8 @@ private constructor( phoneNumbers().ifPresent { it.forEach { it?.validate() } } preferredName() residence().ifPresent { it.validate() } + emails().ifPresent { it.forEach { it.validate() } } + encryptedSsn() ssn() validated = true } @@ -642,8 +675,6 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (dob.asKnown().isPresent) 1 else 0) + - (emails.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (encryptedSsn.asKnown().isPresent) 1 else 0) + (ethnicity.asKnown().getOrNull()?.validity() ?: 0) + (if (firstName.asKnown().isPresent) 1 else 0) + (gender.asKnown().getOrNull()?.validity() ?: 0) + @@ -652,329 +683,33 @@ private constructor( (phoneNumbers.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + (if (preferredName.asKnown().isPresent) 1 else 0) + (residence.asKnown().getOrNull()?.validity() ?: 0) + + (emails.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (encryptedSsn.asKnown().isPresent) 1 else 0) + (if (ssn.asKnown().isPresent) 1 else 0) - class Email - private constructor( - private val data: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(data, type, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * @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") + /** The EEOC-defined ethnicity of the individual. */ + class Ethnicity @JsonCreator private constructor(private val value: JsonField) : Enum { /** - * Returns the raw JSON value of [data]. + * Returns this class instance's raw value. * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + * 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. */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * 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 + companion object { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmField val ASIAN = of("asian") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmField val WHITE = of("white") - fun toBuilder() = Builder().from(this) + @JvmField val BLACK_OR_AFRICAN_AMERICAN = of("black_or_african_american") - companion object { - - /** Returns a mutable builder for constructing an instance of [Email]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Email]. */ - class Builder internal constructor() { - - private var data: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(email: Email) = apply { - data = email.data - type = email.type - additionalProperties = email.additionalProperties.toMutableMap() - } - - fun data(data: String) = data(JsonField.of(data)) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun type(type: Type?) = 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 [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 [Email]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Email = Email(data, type, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Email = apply { - if (validated) { - return@apply - } - - data() - 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 (data.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 WORK = of("work") - - @JvmField val PERSONAL = of("personal") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - WORK, - PERSONAL, - } - - /** - * 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 { - WORK, - PERSONAL, - /** 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) { - WORK -> Value.WORK - PERSONAL -> Value.PERSONAL - 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) { - WORK -> Known.WORK - PERSONAL -> Known.PERSONAL - 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 - - 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Email && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Email{data=$data, type=$type, additionalProperties=$additionalProperties}" - } - - /** The EEOC-defined ethnicity of the individual. */ - class Ethnicity @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 ASIAN = of("asian") - - @JvmField val WHITE = of("white") - - @JvmField val BLACK_OR_AFRICAN_AMERICAN = of("black_or_african_american") - - @JvmField - val NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER = of("native_hawaiian_or_pacific_islander") + @JvmField + val NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER = of("native_hawaiian_or_pacific_islander") @JvmField val AMERICAN_INDIAN_OR_ALASKA_NATIVE = of("american_indian_or_alaska_native") @@ -1150,77 +885,265 @@ private constructor( DECLINE_TO_SPECIFY, } - /** - * An enum containing [Gender]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Gender] 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 { - FEMALE, - MALE, - OTHER, - DECLINE_TO_SPECIFY, - /** An enum member indicating that [Gender] was instantiated with an unknown value. */ - _UNKNOWN, - } + /** + * An enum containing [Gender]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Gender] 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 { + FEMALE, + MALE, + OTHER, + DECLINE_TO_SPECIFY, + /** An enum member indicating that [Gender] 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) { + FEMALE -> Value.FEMALE + MALE -> Value.MALE + OTHER -> Value.OTHER + DECLINE_TO_SPECIFY -> Value.DECLINE_TO_SPECIFY + 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) { + FEMALE -> Known.FEMALE + MALE -> Known.MALE + OTHER -> Known.OTHER + DECLINE_TO_SPECIFY -> Known.DECLINE_TO_SPECIFY + else -> throw FinchInvalidDataException("Unknown Gender: $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 + + fun validate(): Gender = 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 /* spotless:off */ other is Gender && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class PhoneNumber + private constructor( + private val data: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(data, type, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @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 [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [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 [PhoneNumber]. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PhoneNumber]. */ + class Builder internal constructor() { + + private var data: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(phoneNumber: PhoneNumber) = apply { + data = phoneNumber.data + type = phoneNumber.type + additionalProperties = phoneNumber.additionalProperties.toMutableMap() + } + + fun data(data: String?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun type(type: Type?) = 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 [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) + } - /** - * 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) { - FEMALE -> Value.FEMALE - MALE -> Value.MALE - OTHER -> Value.OTHER - DECLINE_TO_SPECIFY -> Value.DECLINE_TO_SPECIFY - else -> Value._UNKNOWN + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) } - /** - * 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) { - FEMALE -> Known.FEMALE - MALE -> Known.MALE - OTHER -> Known.OTHER - DECLINE_TO_SPECIFY -> Known.DECLINE_TO_SPECIFY - else -> throw FinchInvalidDataException("Unknown Gender: $value") + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - /** - * 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") } + /** + * Returns an immutable instance of [PhoneNumber]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PhoneNumber = + PhoneNumber( + checkRequired("data", data), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } private var validated: Boolean = false - fun validate(): Gender = apply { + fun validate(): PhoneNumber = apply { if (validated) { return@apply } - known() + data() + type().ifPresent { it.validate() } validated = true } @@ -1238,22 +1161,156 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (if (data.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 WORK = of("work") + + @JvmField val PERSONAL = of("personal") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WORK, + PERSONAL, + } + + /** + * 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 { + WORK, + PERSONAL, + /** 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) { + WORK -> Value.WORK + PERSONAL -> Value.PERSONAL + 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) { + WORK -> Known.WORK + PERSONAL -> Known.PERSONAL + 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 + + 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Gender && value == other.value /* spotless:on */ + return /* spotless:off */ other is PhoneNumber && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode() = value.hashCode() + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(data, type, additionalProperties) } + /* spotless:on */ - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "PhoneNumber{data=$data, type=$type, additionalProperties=$additionalProperties}" } - class PhoneNumber + class Email private constructor( private val data: JsonField, private val type: JsonField, @@ -1267,10 +1324,10 @@ private constructor( ) : this(data, type, mutableMapOf()) /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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 data(): Optional = data.getOptional("data") + fun data(): String = data.getRequired("data") /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -1306,28 +1363,33 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [PhoneNumber]. */ + /** + * Returns a mutable builder for constructing an instance of [Email]. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [PhoneNumber]. */ + /** A builder for [Email]. */ class Builder internal constructor() { - private var data: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var data: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(phoneNumber: PhoneNumber) = apply { - data = phoneNumber.data - type = phoneNumber.type - additionalProperties = phoneNumber.additionalProperties.toMutableMap() + internal fun from(email: Email) = apply { + data = email.data + type = email.type + additionalProperties = email.additionalProperties.toMutableMap() } - fun data(data: String?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) + fun data(data: String) = data(JsonField.of(data)) /** * Sets [Builder.data] to an arbitrary JSON value. @@ -1372,16 +1434,29 @@ private constructor( } /** - * Returns an immutable instance of [PhoneNumber]. + * Returns an immutable instance of [Email]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): PhoneNumber = PhoneNumber(data, type, additionalProperties.toMutableMap()) + fun build(): Email = + Email( + checkRequired("data", data), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): PhoneNumber = apply { + fun validate(): Email = apply { if (validated) { return@apply } @@ -1541,7 +1616,7 @@ private constructor( return true } - return /* spotless:off */ other is PhoneNumber && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Email && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1551,7 +1626,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PhoneNumber{data=$data, type=$type, additionalProperties=$additionalProperties}" + "Email{data=$data, type=$type, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1559,15 +1634,15 @@ private constructor( return true } - return /* spotless:off */ other is Individual && id == other.id && dob == other.dob && emails == other.emails && encryptedSsn == other.encryptedSsn && ethnicity == other.ethnicity && firstName == other.firstName && gender == other.gender && lastName == other.lastName && middleName == other.middleName && phoneNumbers == other.phoneNumbers && preferredName == other.preferredName && residence == other.residence && ssn == other.ssn && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Individual && id == other.id && dob == other.dob && ethnicity == other.ethnicity && firstName == other.firstName && gender == other.gender && lastName == other.lastName && middleName == other.middleName && phoneNumbers == other.phoneNumbers && preferredName == other.preferredName && residence == other.residence && emails == other.emails && encryptedSsn == other.encryptedSsn && ssn == other.ssn && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, dob, emails, encryptedSsn, ethnicity, firstName, gender, lastName, middleName, phoneNumbers, preferredName, residence, ssn, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, dob, ethnicity, firstName, gender, lastName, middleName, phoneNumbers, preferredName, residence, emails, encryptedSsn, ssn, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Individual{id=$id, dob=$dob, emails=$emails, encryptedSsn=$encryptedSsn, ethnicity=$ethnicity, firstName=$firstName, gender=$gender, lastName=$lastName, middleName=$middleName, phoneNumbers=$phoneNumbers, preferredName=$preferredName, residence=$residence, ssn=$ssn, additionalProperties=$additionalProperties}" + "Individual{id=$id, dob=$dob, ethnicity=$ethnicity, firstName=$firstName, gender=$gender, lastName=$lastName, middleName=$middleName, phoneNumbers=$phoneNumbers, preferredName=$preferredName, residence=$residence, emails=$emails, encryptedSsn=$encryptedSsn, ssn=$ssn, additionalProperties=$additionalProperties}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt index a01069c2..249dd4b3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt @@ -10,10 +10,10 @@ 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 -import java.util.Optional import kotlin.jvm.optionals.getOrNull class IndividualResponse @@ -34,22 +34,22 @@ private constructor( ) : this(body, code, individualId, mutableMapOf()) /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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 body(): Optional = body.getOptional("body") + fun body(): Individual = body.getRequired("body") /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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 code(): Optional = code.getOptional("code") + fun code(): Long = code.getRequired("code") /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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 individualId(): Optional = individualId.getOptional("individual_id") + fun individualId(): String = individualId.getRequired("individual_id") /** * Returns the raw JSON value of [body]. @@ -88,16 +88,25 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [IndividualResponse]. */ + /** + * Returns a mutable builder for constructing an instance of [IndividualResponse]. + * + * The following fields are required: + * ```java + * .body() + * .code() + * .individualId() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [IndividualResponse]. */ class Builder internal constructor() { - private var body: JsonField = JsonMissing.of() - private var code: JsonField = JsonMissing.of() - private var individualId: JsonField = JsonMissing.of() + private var body: JsonField? = null + private var code: JsonField? = null + private var individualId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -164,9 +173,23 @@ private constructor( * Returns an immutable instance of [IndividualResponse]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * .code() + * .individualId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): IndividualResponse = - IndividualResponse(body, code, individualId, additionalProperties.toMutableMap()) + IndividualResponse( + checkRequired("body", body), + checkRequired("code", code), + checkRequired("individualId", individualId), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -176,7 +199,7 @@ private constructor( return@apply } - body().ifPresent { it.validate() } + body().validate() code() individualId() validated = true diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt index 8306ddf1..8d32bf8c 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt @@ -19,13 +19,6 @@ internal class HrisIndividualRetrieveManyPageResponseTest { Individual.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dob("dob") - .addEmail( - Individual.Email.builder() - .data("data") - .type(Individual.Email.Type.WORK) - .build() - ) - .encryptedSsn("encrypted_ssn") .ethnicity(Individual.Ethnicity.ASIAN) .firstName("first_name") .gender(Individual.Gender.FEMALE) @@ -50,6 +43,13 @@ internal class HrisIndividualRetrieveManyPageResponseTest { .sourceId("source_id") .build() ) + .addEmail( + Individual.Email.builder() + .data("data") + .type(Individual.Email.Type.WORK) + .build() + ) + .encryptedSsn("encrypted_ssn") .ssn("ssn") .build() ) @@ -66,13 +66,6 @@ internal class HrisIndividualRetrieveManyPageResponseTest { Individual.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dob("dob") - .addEmail( - Individual.Email.builder() - .data("data") - .type(Individual.Email.Type.WORK) - .build() - ) - .encryptedSsn("encrypted_ssn") .ethnicity(Individual.Ethnicity.ASIAN) .firstName("first_name") .gender(Individual.Gender.FEMALE) @@ -97,6 +90,13 @@ internal class HrisIndividualRetrieveManyPageResponseTest { .sourceId("source_id") .build() ) + .addEmail( + Individual.Email.builder() + .data("data") + .type(Individual.Email.Type.WORK) + .build() + ) + .encryptedSsn("encrypted_ssn") .ssn("ssn") .build() ) @@ -117,13 +117,6 @@ internal class HrisIndividualRetrieveManyPageResponseTest { Individual.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dob("dob") - .addEmail( - Individual.Email.builder() - .data("data") - .type(Individual.Email.Type.WORK) - .build() - ) - .encryptedSsn("encrypted_ssn") .ethnicity(Individual.Ethnicity.ASIAN) .firstName("first_name") .gender(Individual.Gender.FEMALE) @@ -148,6 +141,13 @@ internal class HrisIndividualRetrieveManyPageResponseTest { .sourceId("source_id") .build() ) + .addEmail( + Individual.Email.builder() + .data("data") + .type(Individual.Email.Type.WORK) + .build() + ) + .encryptedSsn("encrypted_ssn") .ssn("ssn") .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt index 438aca92..8cb81209 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt @@ -17,13 +17,6 @@ internal class IndividualResponseTest { Individual.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dob("dob") - .addEmail( - Individual.Email.builder() - .data("data") - .type(Individual.Email.Type.WORK) - .build() - ) - .encryptedSsn("encrypted_ssn") .ethnicity(Individual.Ethnicity.ASIAN) .firstName("first_name") .gender(Individual.Gender.FEMALE) @@ -48,6 +41,13 @@ internal class IndividualResponseTest { .sourceId("source_id") .build() ) + .addEmail( + Individual.Email.builder() + .data("data") + .type(Individual.Email.Type.WORK) + .build() + ) + .encryptedSsn("encrypted_ssn") .ssn("ssn") .build() ) @@ -56,17 +56,10 @@ internal class IndividualResponseTest { .build() assertThat(individualResponse.body()) - .contains( + .isEqualTo( Individual.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dob("dob") - .addEmail( - Individual.Email.builder() - .data("data") - .type(Individual.Email.Type.WORK) - .build() - ) - .encryptedSsn("encrypted_ssn") .ethnicity(Individual.Ethnicity.ASIAN) .firstName("first_name") .gender(Individual.Gender.FEMALE) @@ -91,11 +84,18 @@ internal class IndividualResponseTest { .sourceId("source_id") .build() ) + .addEmail( + Individual.Email.builder() + .data("data") + .type(Individual.Email.Type.WORK) + .build() + ) + .encryptedSsn("encrypted_ssn") .ssn("ssn") .build() ) - assertThat(individualResponse.code()).contains(0L) - assertThat(individualResponse.individualId()).contains("individual_id") + assertThat(individualResponse.code()).isEqualTo(0L) + assertThat(individualResponse.individualId()).isEqualTo("individual_id") } @Test @@ -107,13 +107,6 @@ internal class IndividualResponseTest { Individual.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dob("dob") - .addEmail( - Individual.Email.builder() - .data("data") - .type(Individual.Email.Type.WORK) - .build() - ) - .encryptedSsn("encrypted_ssn") .ethnicity(Individual.Ethnicity.ASIAN) .firstName("first_name") .gender(Individual.Gender.FEMALE) @@ -138,6 +131,13 @@ internal class IndividualResponseTest { .sourceId("source_id") .build() ) + .addEmail( + Individual.Email.builder() + .data("data") + .type(Individual.Email.Type.WORK) + .build() + ) + .encryptedSsn("encrypted_ssn") .ssn("ssn") .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt index 5f90333c..2db9d62b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt @@ -16,10 +16,6 @@ internal class IndividualTest { Individual.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dob("dob") - .addEmail( - Individual.Email.builder().data("data").type(Individual.Email.Type.WORK).build() - ) - .encryptedSsn("encrypted_ssn") .ethnicity(Individual.Ethnicity.ASIAN) .firstName("first_name") .gender(Individual.Gender.FEMALE) @@ -44,16 +40,15 @@ internal class IndividualTest { .sourceId("source_id") .build() ) + .addEmail( + Individual.Email.builder().data("data").type(Individual.Email.Type.WORK).build() + ) + .encryptedSsn("encrypted_ssn") .ssn("ssn") .build() - assertThat(individual.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(individual.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(individual.dob()).contains("dob") - assertThat(individual.emails().getOrNull()) - .containsExactly( - Individual.Email.builder().data("data").type(Individual.Email.Type.WORK).build() - ) - assertThat(individual.encryptedSsn()).contains("encrypted_ssn") assertThat(individual.ethnicity()).contains(Individual.Ethnicity.ASIAN) assertThat(individual.firstName()).contains("first_name") assertThat(individual.gender()).contains(Individual.Gender.FEMALE) @@ -80,6 +75,11 @@ internal class IndividualTest { .sourceId("source_id") .build() ) + assertThat(individual.emails().getOrNull()) + .containsExactly( + Individual.Email.builder().data("data").type(Individual.Email.Type.WORK).build() + ) + assertThat(individual.encryptedSsn()).contains("encrypted_ssn") assertThat(individual.ssn()).contains("ssn") } @@ -90,10 +90,6 @@ internal class IndividualTest { Individual.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dob("dob") - .addEmail( - Individual.Email.builder().data("data").type(Individual.Email.Type.WORK).build() - ) - .encryptedSsn("encrypted_ssn") .ethnicity(Individual.Ethnicity.ASIAN) .firstName("first_name") .gender(Individual.Gender.FEMALE) @@ -118,6 +114,10 @@ internal class IndividualTest { .sourceId("source_id") .build() ) + .addEmail( + Individual.Email.builder().data("data").type(Individual.Email.Type.WORK).build() + ) + .encryptedSsn("encrypted_ssn") .ssn("ssn") .build() From 35e522ba3ad911b49f41ad4b62f1ddc3257dbcd2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 28 Apr 2025 21:09:06 +0000 Subject: [PATCH 12/27] feat(api): api update --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 4804d0f2..b7feacbc 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%2Ffinch-ebcacef9e289357a2688343001fd928ada6811c88b841cd738a9a09178b1991c.yml -openapi_spec_hash: 2d9c296dca75299fd6565aafc4875f19 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-c2370afb40b9a600e92693131137b40faa9e40e844239205fd075ca3ecdd1483.yml +openapi_spec_hash: 5fb5b714cb5dcb048e4e0e2b7a1e2e8d config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 From 43c21f75d63053a888c4ba99dd63847b145bf360 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 28 Apr 2025 22:21:45 +0000 Subject: [PATCH 13/27] feat(api): api update --- .stats.yml | 4 +- .../com/tryfinch/api/models/CompanyBenefit.kt | 555 +++++++++++++++++- .../tryfinch/api/models/CompanyBenefitTest.kt | 34 ++ 3 files changed, 587 insertions(+), 6 deletions(-) diff --git a/.stats.yml b/.stats.yml index b7feacbc..f7b6f115 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%2Ffinch-c2370afb40b9a600e92693131137b40faa9e40e844239205fd075ca3ecdd1483.yml -openapi_spec_hash: 5fb5b714cb5dcb048e4e0e2b7a1e2e8d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-93c2fbc3e83e40488eb98b3a725ff189f13d8f71c0835ecfa32b0263985291e4.yml +openapi_spec_hash: e9893a65174ade751b2e63f6e5fa0936 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyBenefit.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyBenefit.kt index bc621dbe..5cce568b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyBenefit.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyBenefit.kt @@ -6,11 +6,14 @@ 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.checkKnown import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects @@ -20,6 +23,7 @@ import kotlin.jvm.optionals.getOrNull class CompanyBenefit private constructor( private val benefitId: JsonField, + private val companyContribution: JsonField, private val description: JsonField, private val frequency: JsonField, private val type: JsonField, @@ -29,6 +33,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("benefit_id") @ExcludeMissing benefitId: JsonField = JsonMissing.of(), + @JsonProperty("company_contribution") + @ExcludeMissing + companyContribution: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), @@ -36,7 +43,7 @@ private constructor( @ExcludeMissing frequency: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(benefitId, description, frequency, type, mutableMapOf()) + ) : this(benefitId, companyContribution, description, frequency, type, mutableMapOf()) /** * The id of the benefit. @@ -46,6 +53,15 @@ private constructor( */ fun benefitId(): String = benefitId.getRequired("benefit_id") + /** + * The company match for this benefit. + * + * @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") + /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -75,6 +91,16 @@ private constructor( */ @JsonProperty("benefit_id") @ExcludeMissing fun _benefitId(): JsonField = benefitId + /** + * 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 [description]. * @@ -118,6 +144,7 @@ private constructor( * The following fields are required: * ```java * .benefitId() + * .companyContribution() * .description() * .frequency() * .type() @@ -130,6 +157,7 @@ private constructor( class Builder internal constructor() { private var benefitId: JsonField? = null + private var companyContribution: JsonField? = null private var description: JsonField? = null private var frequency: JsonField? = null private var type: JsonField? = null @@ -138,6 +166,7 @@ private constructor( @JvmSynthetic internal fun from(companyBenefit: CompanyBenefit) = apply { benefitId = companyBenefit.benefitId + companyContribution = companyBenefit.companyContribution description = companyBenefit.description frequency = companyBenefit.frequency type = companyBenefit.type @@ -156,6 +185,28 @@ private constructor( */ fun benefitId(benefitId: JsonField) = apply { this.benefitId = benefitId } + /** The company match for this benefit. */ + fun companyContribution(companyContribution: BenefitCompanyMatchContribution?) = + companyContribution(JsonField.ofNullable(companyContribution)) + + /** + * Alias for calling [Builder.companyContribution] with `companyContribution.orElse(null)`. + */ + fun companyContribution(companyContribution: Optional) = + companyContribution(companyContribution.getOrNull()) + + /** + * Sets [Builder.companyContribution] to an arbitrary JSON value. + * + * You should usually call [Builder.companyContribution] with a well-typed + * [BenefitCompanyMatchContribution] 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 + } + fun description(description: String?) = description(JsonField.ofNullable(description)) /** Alias for calling [Builder.description] with `description.orElse(null)`. */ @@ -227,6 +278,7 @@ private constructor( * The following fields are required: * ```java * .benefitId() + * .companyContribution() * .description() * .frequency() * .type() @@ -237,6 +289,7 @@ private constructor( fun build(): CompanyBenefit = CompanyBenefit( checkRequired("benefitId", benefitId), + checkRequired("companyContribution", companyContribution), checkRequired("description", description), checkRequired("frequency", frequency), checkRequired("type", type), @@ -252,6 +305,7 @@ private constructor( } benefitId() + companyContribution().ifPresent { it.validate() } description() frequency().ifPresent { it.validate() } type().ifPresent { it.validate() } @@ -274,24 +328,517 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (benefitId.asKnown().isPresent) 1 else 0) + + (companyContribution.asKnown().getOrNull()?.validity() ?: 0) + (if (description.asKnown().isPresent) 1 else 0) + (frequency.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + /** The company match for this benefit. */ + class BenefitCompanyMatchContribution + private constructor( + private val tiers: JsonField>, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(tiers, type, mutableMapOf()) + + /** + * @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 [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 + * [BenefitCompanyMatchContribution]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BenefitCompanyMatchContribution]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(benefitCompanyMatchContribution: BenefitCompanyMatchContribution) = + apply { + tiers = benefitCompanyMatchContribution.tiers.map { it.toMutableList() } + type = benefitCompanyMatchContribution.type + additionalProperties = + benefitCompanyMatchContribution.additionalProperties.toMutableMap() + } + + 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 [BenefitCompanyMatchContribution]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BenefitCompanyMatchContribution = + BenefitCompanyMatchContribution( + (tiers ?: JsonMissing.of()).map { it.toImmutable() }, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BenefitCompanyMatchContribution = apply { + if (validated) { + return@apply + } + + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Tier + 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()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun match(): Optional = match.getOptional("match") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun threshold(): Optional = threshold.getOptional("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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var match: JsonField = JsonMissing.of() + private var threshold: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + match = tier.match + threshold = tier.threshold + additionalProperties = tier.additionalProperties.toMutableMap() + } + + fun match(match: Double) = match(JsonField.of(match)) + + /** + * Sets [Builder.match] to an arbitrary JSON value. + * + * You should usually call [Builder.match] with a well-typed [Double] 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 } + + fun threshold(threshold: Double) = threshold(JsonField.of(threshold)) + + /** + * Sets [Builder.threshold] to an arbitrary JSON value. + * + * You should usually call [Builder.threshold] with a well-typed [Double] 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. + */ + fun build(): Tier = Tier(match, threshold, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + 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 /* spotless:off */ other is Tier && match == other.match && threshold == other.threshold && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(match, threshold, additionalProperties) } + /* spotless:on */ + + 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 MATCH = of("match") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + MATCH + } + + /** + * 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 { + MATCH, + /** 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) { + MATCH -> Value.MATCH + 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) { + MATCH -> Known.MATCH + 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 + + 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BenefitCompanyMatchContribution && tiers == other.tiers && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(tiers, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BenefitCompanyMatchContribution{tiers=$tiers, type=$type, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CompanyBenefit && benefitId == other.benefitId && description == other.description && frequency == other.frequency && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CompanyBenefit && benefitId == other.benefitId && companyContribution == other.companyContribution && description == other.description && frequency == other.frequency && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(benefitId, description, frequency, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(benefitId, companyContribution, description, frequency, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "CompanyBenefit{benefitId=$benefitId, description=$description, frequency=$frequency, type=$type, additionalProperties=$additionalProperties}" + "CompanyBenefit{benefitId=$benefitId, companyContribution=$companyContribution, description=$description, frequency=$frequency, type=$type, additionalProperties=$additionalProperties}" } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt index b4ec445b..cd0ff6a2 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt @@ -14,12 +14,35 @@ internal class CompanyBenefitTest { val companyBenefit = CompanyBenefit.builder() .benefitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .companyContribution( + CompanyBenefit.BenefitCompanyMatchContribution.builder() + .addTier( + CompanyBenefit.BenefitCompanyMatchContribution.Tier.builder() + .match(1.0) + .threshold(1.0) + .build() + ) + .type(CompanyBenefit.BenefitCompanyMatchContribution.Type.MATCH) + .build() + ) .description("description") .frequency(BenefitFrequency.ONE_TIME) .type(BenefitType._401K) .build() assertThat(companyBenefit.benefitId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(companyBenefit.companyContribution()) + .contains( + CompanyBenefit.BenefitCompanyMatchContribution.builder() + .addTier( + CompanyBenefit.BenefitCompanyMatchContribution.Tier.builder() + .match(1.0) + .threshold(1.0) + .build() + ) + .type(CompanyBenefit.BenefitCompanyMatchContribution.Type.MATCH) + .build() + ) assertThat(companyBenefit.description()).contains("description") assertThat(companyBenefit.frequency()).contains(BenefitFrequency.ONE_TIME) assertThat(companyBenefit.type()).contains(BenefitType._401K) @@ -31,6 +54,17 @@ internal class CompanyBenefitTest { val companyBenefit = CompanyBenefit.builder() .benefitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .companyContribution( + CompanyBenefit.BenefitCompanyMatchContribution.builder() + .addTier( + CompanyBenefit.BenefitCompanyMatchContribution.Tier.builder() + .match(1.0) + .threshold(1.0) + .build() + ) + .type(CompanyBenefit.BenefitCompanyMatchContribution.Type.MATCH) + .build() + ) .description("description") .frequency(BenefitFrequency.ONE_TIME) .type(BenefitType._401K) From f45fb2151509dd96e2630b94ed4b3a1f3f711439 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 29 Apr 2025 02:31:47 +0000 Subject: [PATCH 14/27] feat(api): api update --- .stats.yml | 4 +- .../com/tryfinch/api/models/Individual.kt | 2794 ++++++++++------- .../tryfinch/api/models/IndividualResponse.kt | 8 + ...sIndividualRetrieveManyPageResponseTest.kt | 42 +- .../api/models/IndividualResponseTest.kt | 102 +- .../com/tryfinch/api/models/IndividualTest.kt | 185 +- 6 files changed, 1833 insertions(+), 1302 deletions(-) diff --git a/.stats.yml b/.stats.yml index f7b6f115..8ed0ece0 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%2Ffinch-93c2fbc3e83e40488eb98b3a725ff189f13d8f71c0835ecfa32b0263985291e4.yml -openapi_spec_hash: e9893a65174ade751b2e63f6e5fa0936 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-639dd4ab9ac2acad21a6764fda369a1d189a3e64bf71a65db36daf0f32d98242.yml +openapi_spec_hash: c148f859bdd0b723c856bd472f115f1f config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt index 475f3a6e..52ef21a7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt @@ -6,13 +6,24 @@ 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.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.BaseDeserializer +import com.tryfinch.api.core.BaseSerializer 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.allMaxBy import com.tryfinch.api.core.checkKnown import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.getOrThrow import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections @@ -20,942 +31,830 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +@JsonDeserialize(using = Individual.Deserializer::class) +@JsonSerialize(using = Individual.Serializer::class) class Individual private constructor( - private val id: JsonField, - private val dob: JsonField, - private val ethnicity: JsonField, - private val firstName: JsonField, - private val gender: JsonField, - private val lastName: JsonField, - private val middleName: JsonField, - private val phoneNumbers: JsonField>, - private val preferredName: JsonField, - private val residence: JsonField, - private val emails: JsonField>, - private val encryptedSsn: JsonField, - private val ssn: JsonField, - private val additionalProperties: MutableMap, + private val unionMember0: UnionMember0? = null, + private val unionMember1: UnionMember1? = null, + private val _json: JsonValue? = null, ) { - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("dob") @ExcludeMissing dob: JsonField = JsonMissing.of(), - @JsonProperty("ethnicity") - @ExcludeMissing - ethnicity: JsonField = JsonMissing.of(), - @JsonProperty("first_name") @ExcludeMissing firstName: JsonField = JsonMissing.of(), - @JsonProperty("gender") @ExcludeMissing gender: JsonField = JsonMissing.of(), - @JsonProperty("last_name") @ExcludeMissing lastName: JsonField = JsonMissing.of(), - @JsonProperty("middle_name") - @ExcludeMissing - middleName: JsonField = JsonMissing.of(), - @JsonProperty("phone_numbers") - @ExcludeMissing - phoneNumbers: JsonField> = JsonMissing.of(), - @JsonProperty("preferred_name") - @ExcludeMissing - preferredName: JsonField = JsonMissing.of(), - @JsonProperty("residence") - @ExcludeMissing - residence: JsonField = JsonMissing.of(), - @JsonProperty("emails") @ExcludeMissing emails: JsonField> = JsonMissing.of(), - @JsonProperty("encrypted_ssn") - @ExcludeMissing - encryptedSsn: JsonField = JsonMissing.of(), - @JsonProperty("ssn") @ExcludeMissing ssn: JsonField = JsonMissing.of(), - ) : this( - id, - dob, - ethnicity, - firstName, - gender, - lastName, - middleName, - phoneNumbers, - preferredName, - residence, - emails, - encryptedSsn, - ssn, - mutableMapOf(), - ) - - /** - * A stable Finch `id` (UUID v4) for an individual in the company. - * - * @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 id(): String = id.getRequired("id") + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun dob(): Optional = dob.getOptional("dob") - - /** - * The EEOC-defined ethnicity of the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ethnicity(): Optional = ethnicity.getOptional("ethnicity") - - /** - * The legal first name of the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun firstName(): Optional = firstName.getOptional("first_name") - - /** - * The gender of the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun gender(): Optional = gender.getOptional("gender") - - /** - * The legal last name of the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun lastName(): Optional = lastName.getOptional("last_name") + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - /** - * The legal middle name of the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun middleName(): Optional = middleName.getOptional("middle_name") + fun isUnionMember0(): Boolean = unionMember0 != null - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun phoneNumbers(): Optional> = phoneNumbers.getOptional("phone_numbers") + fun isUnionMember1(): Boolean = unionMember1 != null - /** - * The preferred name of the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferredName(): Optional = preferredName.getOptional("preferred_name") + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun residence(): Optional = residence.getOptional("residence") + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun emails(): Optional> = emails.getOptional("emails") + fun _json(): Optional = Optional.ofNullable(_json) - /** - * Social Security Number of the individual in **encrypted** format. This field is only - * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set in - * the body. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun encryptedSsn(): Optional = encryptedSsn.getOptional("encrypted_ssn") + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + else -> visitor.unknown(_json) + } - /** - * Social Security Number of the individual. This field is only available with the `ssn` scope - * enabled and the `options: { include: ['ssn'] }` param set in the body. - * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ssn(): Optional = ssn.getOptional("ssn") + private var validated: Boolean = false - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun validate(): Individual = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [dob]. - * - * Unlike [dob], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } - /** - * Returns the raw JSON value of [ethnicity]. - * - * Unlike [ethnicity], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ethnicity") @ExcludeMissing fun _ethnicity(): JsonField = ethnicity + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + } + ) + validated = true + } - /** - * Returns the raw JSON value of [firstName]. - * - * Unlike [firstName], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } /** - * Returns the raw JSON value of [gender]. + * Returns a score indicating how many valid values are contained in this object recursively. * - * Unlike [gender], this method doesn't throw if the JSON field has an unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("gender") @ExcludeMissing fun _gender(): JsonField = gender + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() - /** - * Returns the raw JSON value of [lastName]. - * - * Unlike [lastName], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName + override fun visitUnionMember1(unionMember1: UnionMember1) = unionMember1.validity() - /** - * Returns the raw JSON value of [middleName]. - * - * Unlike [middleName], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("middle_name") @ExcludeMissing fun _middleName(): JsonField = middleName + override fun unknown(json: JsonValue?) = 0 + } + ) - /** - * Returns the raw JSON value of [phoneNumbers]. - * - * Unlike [phoneNumbers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("phone_numbers") - @ExcludeMissing - fun _phoneNumbers(): JsonField> = phoneNumbers + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [preferredName]. - * - * Unlike [preferredName], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferred_name") - @ExcludeMissing - fun _preferredName(): JsonField = preferredName + return /* spotless:off */ other is Individual && unionMember0 == other.unionMember0 && unionMember1 == other.unionMember1 /* spotless:on */ + } - /** - * Returns the raw JSON value of [residence]. - * - * Unlike [residence], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("residence") @ExcludeMissing fun _residence(): JsonField = residence + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, unionMember1) /* spotless:on */ - /** - * Returns the raw JSON value of [emails]. - * - * Unlike [emails], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails + override fun toString(): String = + when { + unionMember0 != null -> "Individual{unionMember0=$unionMember0}" + unionMember1 != null -> "Individual{unionMember1=$unionMember1}" + _json != null -> "Individual{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Individual") + } - /** - * Returns the raw JSON value of [encryptedSsn]. - * - * Unlike [encryptedSsn], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("encrypted_ssn") - @ExcludeMissing - fun _encryptedSsn(): JsonField = encryptedSsn + companion object { - /** - * Returns the raw JSON value of [ssn]. - * - * Unlike [ssn], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ssn") @ExcludeMissing fun _ssn(): JsonField = ssn + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = Individual(unionMember0 = unionMember0) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = Individual(unionMember1 = unionMember1) } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** An interface that defines how to map each variant of [Individual] to a value of type [T]. */ + interface Visitor { - fun toBuilder() = Builder().from(this) + fun visitUnionMember0(unionMember0: UnionMember0): T - companion object { + fun visitUnionMember1(unionMember1: UnionMember1): T /** - * Returns a mutable builder for constructing an instance of [Individual]. + * Maps an unknown variant of [Individual] to a value of type [T]. + * + * An instance of [Individual] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. * - * The following fields are required: - * ```java - * .id() - * .dob() - * .ethnicity() - * .firstName() - * .gender() - * .lastName() - * .middleName() - * .phoneNumbers() - * .preferredName() - * .residence() - * ``` + * @throws FinchInvalidDataException in the default implementation. */ - @JvmStatic fun builder() = Builder() + fun unknown(json: JsonValue?): T { + throw FinchInvalidDataException("Unknown Individual: $json") + } } - /** A builder for [Individual]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var dob: JsonField? = null - private var ethnicity: JsonField? = null - private var firstName: JsonField? = null - private var gender: JsonField? = null - private var lastName: JsonField? = null - private var middleName: JsonField? = null - private var phoneNumbers: JsonField>? = null - private var preferredName: JsonField? = null - private var residence: JsonField? = null - private var emails: JsonField>? = null - private var encryptedSsn: JsonField = JsonMissing.of() - private var ssn: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + internal class Deserializer : BaseDeserializer(Individual::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Individual { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Individual(unionMember0 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Individual(unionMember1 = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> Individual(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } - @JvmSynthetic - internal fun from(individual: Individual) = apply { - id = individual.id - dob = individual.dob - ethnicity = individual.ethnicity - firstName = individual.firstName - gender = individual.gender - lastName = individual.lastName - middleName = individual.middleName - phoneNumbers = individual.phoneNumbers.map { it.toMutableList() } - preferredName = individual.preferredName - residence = individual.residence - emails = individual.emails.map { it.toMutableList() } - encryptedSsn = individual.encryptedSsn - ssn = individual.ssn - additionalProperties = individual.additionalProperties.toMutableMap() + internal class Serializer : BaseSerializer(Individual::class) { + + override fun serialize( + value: Individual, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Individual") + } } + } + + class UnionMember0 + private constructor( + private val id: JsonField, + private val dob: JsonField, + private val ethnicity: JsonField, + private val firstName: JsonField, + private val gender: JsonField, + private val lastName: JsonField, + private val middleName: JsonField, + private val phoneNumbers: JsonField>, + private val preferredName: JsonField, + private val residence: JsonField, + private val emails: JsonField>, + private val encryptedSsn: JsonField, + private val ssn: JsonField, + private val additionalProperties: MutableMap, + ) { - /** A stable Finch `id` (UUID v4) for an individual in the company. */ - fun id(id: String) = id(JsonField.of(id)) + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dob") @ExcludeMissing dob: JsonField = JsonMissing.of(), + @JsonProperty("ethnicity") + @ExcludeMissing + ethnicity: JsonField = JsonMissing.of(), + @JsonProperty("first_name") + @ExcludeMissing + firstName: JsonField = JsonMissing.of(), + @JsonProperty("gender") @ExcludeMissing gender: JsonField = JsonMissing.of(), + @JsonProperty("last_name") + @ExcludeMissing + lastName: JsonField = JsonMissing.of(), + @JsonProperty("middle_name") + @ExcludeMissing + middleName: JsonField = JsonMissing.of(), + @JsonProperty("phone_numbers") + @ExcludeMissing + phoneNumbers: JsonField> = JsonMissing.of(), + @JsonProperty("preferred_name") + @ExcludeMissing + preferredName: JsonField = JsonMissing.of(), + @JsonProperty("residence") + @ExcludeMissing + residence: JsonField = JsonMissing.of(), + @JsonProperty("emails") + @ExcludeMissing + emails: JsonField> = JsonMissing.of(), + @JsonProperty("encrypted_ssn") + @ExcludeMissing + encryptedSsn: JsonField = JsonMissing.of(), + @JsonProperty("ssn") @ExcludeMissing ssn: JsonField = JsonMissing.of(), + ) : this( + id, + dob, + ethnicity, + firstName, + gender, + lastName, + middleName, + phoneNumbers, + preferredName, + residence, + emails, + encryptedSsn, + ssn, + mutableMapOf(), + ) /** - * Sets [Builder.id] to an arbitrary JSON value. + * A stable Finch `id` (UUID v4) for an individual in the company. * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * @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 id(id: JsonField) = apply { this.id = id } - - fun dob(dob: String?) = dob(JsonField.ofNullable(dob)) + fun id(): String = id.getRequired("id") - /** Alias for calling [Builder.dob] with `dob.orElse(null)`. */ - fun dob(dob: Optional) = dob(dob.getOrNull()) + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dob(): Optional = dob.getOptional("dob") /** - * Sets [Builder.dob] to an arbitrary JSON value. + * The EEOC-defined ethnicity of the individual. * - * You should usually call [Builder.dob] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun dob(dob: JsonField) = apply { this.dob = dob } - - /** The EEOC-defined ethnicity of the individual. */ - fun ethnicity(ethnicity: Ethnicity?) = ethnicity(JsonField.ofNullable(ethnicity)) - - /** Alias for calling [Builder.ethnicity] with `ethnicity.orElse(null)`. */ - fun ethnicity(ethnicity: Optional) = ethnicity(ethnicity.getOrNull()) + fun ethnicity(): Optional = ethnicity.getOptional("ethnicity") /** - * Sets [Builder.ethnicity] to an arbitrary JSON value. + * The legal first name of the individual. * - * You should usually call [Builder.ethnicity] with a well-typed [Ethnicity] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun ethnicity(ethnicity: JsonField) = apply { this.ethnicity = ethnicity } - - /** The legal first name of the individual. */ - fun firstName(firstName: String?) = firstName(JsonField.ofNullable(firstName)) - - /** Alias for calling [Builder.firstName] with `firstName.orElse(null)`. */ - fun firstName(firstName: Optional) = firstName(firstName.getOrNull()) + fun firstName(): Optional = firstName.getOptional("first_name") /** - * Sets [Builder.firstName] to an arbitrary JSON value. + * The gender of the individual. * - * You should usually call [Builder.firstName] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun firstName(firstName: JsonField) = apply { this.firstName = firstName } - - /** The gender of the individual. */ - fun gender(gender: Gender?) = gender(JsonField.ofNullable(gender)) - - /** Alias for calling [Builder.gender] with `gender.orElse(null)`. */ - fun gender(gender: Optional) = gender(gender.getOrNull()) + fun gender(): Optional = gender.getOptional("gender") /** - * Sets [Builder.gender] to an arbitrary JSON value. + * The legal last name of the individual. * - * You should usually call [Builder.gender] with a well-typed [Gender] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun gender(gender: JsonField) = apply { this.gender = gender } - - /** The legal last name of the individual. */ - fun lastName(lastName: String?) = lastName(JsonField.ofNullable(lastName)) - - /** Alias for calling [Builder.lastName] with `lastName.orElse(null)`. */ - fun lastName(lastName: Optional) = lastName(lastName.getOrNull()) + fun lastName(): Optional = lastName.getOptional("last_name") /** - * Sets [Builder.lastName] to an arbitrary JSON value. + * The legal middle name of the individual. * - * You should usually call [Builder.lastName] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun lastName(lastName: JsonField) = apply { this.lastName = lastName } + fun middleName(): Optional = middleName.getOptional("middle_name") - /** The legal middle name of the individual. */ - fun middleName(middleName: String?) = middleName(JsonField.ofNullable(middleName)) - - /** Alias for calling [Builder.middleName] with `middleName.orElse(null)`. */ - fun middleName(middleName: Optional) = middleName(middleName.getOrNull()) + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun phoneNumbers(): Optional> = phoneNumbers.getOptional("phone_numbers") /** - * Sets [Builder.middleName] to an arbitrary JSON value. + * The preferred name of the individual. * - * You should usually call [Builder.middleName] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun middleName(middleName: JsonField) = apply { this.middleName = middleName } + fun preferredName(): Optional = preferredName.getOptional("preferred_name") - fun phoneNumbers(phoneNumbers: List?) = - phoneNumbers(JsonField.ofNullable(phoneNumbers)) + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun residence(): Optional = residence.getOptional("residence") - /** Alias for calling [Builder.phoneNumbers] with `phoneNumbers.orElse(null)`. */ - fun phoneNumbers(phoneNumbers: Optional>) = - phoneNumbers(phoneNumbers.getOrNull()) + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun emails(): Optional> = emails.getOptional("emails") /** - * Sets [Builder.phoneNumbers] to an arbitrary JSON value. + * Social Security Number of the individual in **encrypted** format. This field is only + * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set + * in the body. * - * You should usually call [Builder.phoneNumbers] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun phoneNumbers(phoneNumbers: JsonField>) = apply { - this.phoneNumbers = phoneNumbers.map { it.toMutableList() } - } + fun encryptedSsn(): Optional = encryptedSsn.getOptional("encrypted_ssn") /** - * Adds a single [PhoneNumber] to [phoneNumbers]. + * Social Security Number of the individual. This field is only available with the `ssn` + * scope enabled and the `options: { include: ['ssn'] }` param set in the body. + * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun addPhoneNumber(phoneNumber: PhoneNumber) = apply { - phoneNumbers = - (phoneNumbers ?: JsonField.of(mutableListOf())).also { - checkKnown("phoneNumbers", it).add(phoneNumber) - } - } - - /** The preferred name of the individual. */ - fun preferredName(preferredName: String?) = - preferredName(JsonField.ofNullable(preferredName)) - - /** Alias for calling [Builder.preferredName] with `preferredName.orElse(null)`. */ - fun preferredName(preferredName: Optional) = - preferredName(preferredName.getOrNull()) + fun ssn(): Optional = ssn.getOptional("ssn") /** - * Sets [Builder.preferredName] to an arbitrary JSON value. + * Returns the raw JSON value of [id]. * - * You should usually call [Builder.preferredName] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun preferredName(preferredName: JsonField) = apply { - this.preferredName = preferredName - } - - fun residence(residence: Location?) = residence(JsonField.ofNullable(residence)) - - /** Alias for calling [Builder.residence] with `residence.orElse(null)`. */ - fun residence(residence: Optional) = residence(residence.getOrNull()) + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Sets [Builder.residence] to an arbitrary JSON value. + * Returns the raw JSON value of [dob]. * - * You should usually call [Builder.residence] with a well-typed [Location] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * Unlike [dob], this method doesn't throw if the JSON field has an unexpected type. */ - fun residence(residence: JsonField) = apply { this.residence = residence } + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob - fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) + /** + * Returns the raw JSON value of [ethnicity]. + * + * Unlike [ethnicity], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ethnicity") + @ExcludeMissing + fun _ethnicity(): JsonField = ethnicity - /** Alias for calling [Builder.emails] with `emails.orElse(null)`. */ - fun emails(emails: Optional>) = emails(emails.getOrNull()) + /** + * Returns the raw JSON value of [firstName]. + * + * Unlike [firstName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** - * Sets [Builder.emails] to an arbitrary JSON value. + * Returns the raw JSON value of [gender]. * - * You should usually call [Builder.emails] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * Unlike [gender], this method doesn't throw if the JSON field has an unexpected type. */ - fun emails(emails: JsonField>) = apply { - this.emails = emails.map { it.toMutableList() } - } + @JsonProperty("gender") @ExcludeMissing fun _gender(): JsonField = gender /** - * Adds a single [Email] to [emails]. + * Returns the raw JSON value of [lastName]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Unlike [lastName], this method doesn't throw if the JSON field has an unexpected type. */ - fun addEmail(email: Email) = apply { - emails = - (emails ?: JsonField.of(mutableListOf())).also { - checkKnown("emails", it).add(email) - } - } + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName /** - * Social Security Number of the individual in **encrypted** format. This field is only - * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set - * in the body. + * Returns the raw JSON value of [middleName]. + * + * Unlike [middleName], this method doesn't throw if the JSON field has an unexpected type. */ - fun encryptedSsn(encryptedSsn: String?) = encryptedSsn(JsonField.ofNullable(encryptedSsn)) + @JsonProperty("middle_name") + @ExcludeMissing + fun _middleName(): JsonField = middleName - /** Alias for calling [Builder.encryptedSsn] with `encryptedSsn.orElse(null)`. */ - fun encryptedSsn(encryptedSsn: Optional) = encryptedSsn(encryptedSsn.getOrNull()) + /** + * Returns the raw JSON value of [phoneNumbers]. + * + * Unlike [phoneNumbers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("phone_numbers") + @ExcludeMissing + fun _phoneNumbers(): JsonField> = phoneNumbers /** - * Sets [Builder.encryptedSsn] to an arbitrary JSON value. + * Returns the raw JSON value of [preferredName]. * - * You should usually call [Builder.encryptedSsn] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * Unlike [preferredName], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun encryptedSsn(encryptedSsn: JsonField) = apply { - this.encryptedSsn = encryptedSsn - } + @JsonProperty("preferred_name") + @ExcludeMissing + fun _preferredName(): JsonField = preferredName /** - * Social Security Number of the individual. This field is only available with the `ssn` - * scope enabled and the `options: { include: ['ssn'] }` param set in the body. - * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). + * Returns the raw JSON value of [residence]. + * + * Unlike [residence], this method doesn't throw if the JSON field has an unexpected type. */ - fun ssn(ssn: String?) = ssn(JsonField.ofNullable(ssn)) + @JsonProperty("residence") @ExcludeMissing fun _residence(): JsonField = residence - /** Alias for calling [Builder.ssn] with `ssn.orElse(null)`. */ - fun ssn(ssn: Optional) = ssn(ssn.getOrNull()) + /** + * Returns the raw JSON value of [emails]. + * + * Unlike [emails], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails /** - * Sets [Builder.ssn] to an arbitrary JSON value. + * Returns the raw JSON value of [encryptedSsn]. * - * You should usually call [Builder.ssn] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * Unlike [encryptedSsn], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun ssn(ssn: JsonField) = apply { this.ssn = ssn } + @JsonProperty("encrypted_ssn") + @ExcludeMissing + fun _encryptedSsn(): JsonField = encryptedSsn - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [ssn]. + * + * Unlike [ssn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ssn") @ExcludeMissing fun _ssn(): JsonField = ssn - fun putAdditionalProperty(key: String, value: JsonValue) = apply { + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + companion object { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns a mutable builder for constructing an instance of [UnionMember0]. + * + * The following fields are required: + * ```java + * .id() + * .dob() + * .ethnicity() + * .firstName() + * .gender() + * .lastName() + * .middleName() + * .phoneNumbers() + * .preferredName() + * .residence() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** - * Returns an immutable instance of [Individual]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .dob() - * .ethnicity() - * .firstName() - * .gender() - * .lastName() - * .middleName() - * .phoneNumbers() - * .preferredName() - * .residence() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Individual = - Individual( - checkRequired("id", id), - checkRequired("dob", dob), - checkRequired("ethnicity", ethnicity), - checkRequired("firstName", firstName), - checkRequired("gender", gender), - checkRequired("lastName", lastName), - checkRequired("middleName", middleName), - checkRequired("phoneNumbers", phoneNumbers).map { it.toImmutable() }, - checkRequired("preferredName", preferredName), - checkRequired("residence", residence), - (emails ?: JsonMissing.of()).map { it.toImmutable() }, - encryptedSsn, - ssn, - additionalProperties.toMutableMap(), - ) - } + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { - private var validated: Boolean = false + private var id: JsonField? = null + private var dob: JsonField? = null + private var ethnicity: JsonField? = null + private var firstName: JsonField? = null + private var gender: JsonField? = null + private var lastName: JsonField? = null + private var middleName: JsonField? = null + private var phoneNumbers: JsonField>? = null + private var preferredName: JsonField? = null + private var residence: JsonField? = null + private var emails: JsonField>? = null + private var encryptedSsn: JsonField = JsonMissing.of() + private var ssn: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun validate(): Individual = apply { - if (validated) { - return@apply - } + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + id = unionMember0.id + dob = unionMember0.dob + ethnicity = unionMember0.ethnicity + firstName = unionMember0.firstName + gender = unionMember0.gender + lastName = unionMember0.lastName + middleName = unionMember0.middleName + phoneNumbers = unionMember0.phoneNumbers.map { it.toMutableList() } + preferredName = unionMember0.preferredName + residence = unionMember0.residence + emails = unionMember0.emails.map { it.toMutableList() } + encryptedSsn = unionMember0.encryptedSsn + ssn = unionMember0.ssn + additionalProperties = unionMember0.additionalProperties.toMutableMap() + } - id() - dob() - ethnicity().ifPresent { it.validate() } - firstName() - gender().ifPresent { it.validate() } - lastName() - middleName() - phoneNumbers().ifPresent { it.forEach { it?.validate() } } - preferredName() - residence().ifPresent { it.validate() } - emails().ifPresent { it.forEach { it.validate() } } - encryptedSsn() - ssn() - validated = true - } + /** A stable Finch `id` (UUID v4) for an individual in the company. */ + fun id(id: String) = id(JsonField.of(id)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (dob.asKnown().isPresent) 1 else 0) + - (ethnicity.asKnown().getOrNull()?.validity() ?: 0) + - (if (firstName.asKnown().isPresent) 1 else 0) + - (gender.asKnown().getOrNull()?.validity() ?: 0) + - (if (lastName.asKnown().isPresent) 1 else 0) + - (if (middleName.asKnown().isPresent) 1 else 0) + - (phoneNumbers.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (if (preferredName.asKnown().isPresent) 1 else 0) + - (residence.asKnown().getOrNull()?.validity() ?: 0) + - (emails.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (encryptedSsn.asKnown().isPresent) 1 else 0) + - (if (ssn.asKnown().isPresent) 1 else 0) - - /** The EEOC-defined ethnicity of the individual. */ - class Ethnicity @JsonCreator private constructor(private val value: JsonField) : Enum { + fun dob(dob: String?) = dob(JsonField.ofNullable(dob)) - /** - * 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 + /** Alias for calling [Builder.dob] with `dob.orElse(null)`. */ + fun dob(dob: Optional) = dob(dob.getOrNull()) - companion object { + /** + * Sets [Builder.dob] to an arbitrary JSON value. + * + * You should usually call [Builder.dob] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dob(dob: JsonField) = apply { this.dob = dob } - @JvmField val ASIAN = of("asian") + /** The EEOC-defined ethnicity of the individual. */ + fun ethnicity(ethnicity: Ethnicity?) = ethnicity(JsonField.ofNullable(ethnicity)) - @JvmField val WHITE = of("white") + /** Alias for calling [Builder.ethnicity] with `ethnicity.orElse(null)`. */ + fun ethnicity(ethnicity: Optional) = ethnicity(ethnicity.getOrNull()) - @JvmField val BLACK_OR_AFRICAN_AMERICAN = of("black_or_african_american") + /** + * Sets [Builder.ethnicity] to an arbitrary JSON value. + * + * You should usually call [Builder.ethnicity] with a well-typed [Ethnicity] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ethnicity(ethnicity: JsonField) = apply { this.ethnicity = ethnicity } - @JvmField - val NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER = of("native_hawaiian_or_pacific_islander") + /** The legal first name of the individual. */ + fun firstName(firstName: String?) = firstName(JsonField.ofNullable(firstName)) - @JvmField val AMERICAN_INDIAN_OR_ALASKA_NATIVE = of("american_indian_or_alaska_native") + /** Alias for calling [Builder.firstName] with `firstName.orElse(null)`. */ + fun firstName(firstName: Optional) = firstName(firstName.getOrNull()) - @JvmField val HISPANIC_OR_LATINO = of("hispanic_or_latino") + /** + * Sets [Builder.firstName] to an arbitrary JSON value. + * + * You should usually call [Builder.firstName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstName(firstName: JsonField) = apply { this.firstName = firstName } - @JvmField val TWO_OR_MORE_RACES = of("two_or_more_races") + /** The gender of the individual. */ + fun gender(gender: Gender?) = gender(JsonField.ofNullable(gender)) - @JvmField val DECLINE_TO_SPECIFY = of("decline_to_specify") + /** Alias for calling [Builder.gender] with `gender.orElse(null)`. */ + fun gender(gender: Optional) = gender(gender.getOrNull()) - @JvmStatic fun of(value: String) = Ethnicity(JsonField.of(value)) - } + /** + * Sets [Builder.gender] to an arbitrary JSON value. + * + * You should usually call [Builder.gender] with a well-typed [Gender] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gender(gender: JsonField) = apply { this.gender = gender } - /** An enum containing [Ethnicity]'s known values. */ - enum class Known { - ASIAN, - WHITE, - BLACK_OR_AFRICAN_AMERICAN, - NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER, - AMERICAN_INDIAN_OR_ALASKA_NATIVE, - HISPANIC_OR_LATINO, - TWO_OR_MORE_RACES, - DECLINE_TO_SPECIFY, - } + /** The legal last name of the individual. */ + fun lastName(lastName: String?) = lastName(JsonField.ofNullable(lastName)) + + /** Alias for calling [Builder.lastName] with `lastName.orElse(null)`. */ + fun lastName(lastName: Optional) = lastName(lastName.getOrNull()) - /** - * An enum containing [Ethnicity]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Ethnicity] 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 { - ASIAN, - WHITE, - BLACK_OR_AFRICAN_AMERICAN, - NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER, - AMERICAN_INDIAN_OR_ALASKA_NATIVE, - HISPANIC_OR_LATINO, - TWO_OR_MORE_RACES, - DECLINE_TO_SPECIFY, /** - * An enum member indicating that [Ethnicity] was instantiated with an unknown value. + * Sets [Builder.lastName] to an arbitrary JSON value. + * + * You should usually call [Builder.lastName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - _UNKNOWN, - } + fun lastName(lastName: JsonField) = apply { this.lastName = lastName } - /** - * 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) { - ASIAN -> Value.ASIAN - WHITE -> Value.WHITE - BLACK_OR_AFRICAN_AMERICAN -> Value.BLACK_OR_AFRICAN_AMERICAN - NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER -> Value.NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER - AMERICAN_INDIAN_OR_ALASKA_NATIVE -> Value.AMERICAN_INDIAN_OR_ALASKA_NATIVE - HISPANIC_OR_LATINO -> Value.HISPANIC_OR_LATINO - TWO_OR_MORE_RACES -> Value.TWO_OR_MORE_RACES - DECLINE_TO_SPECIFY -> Value.DECLINE_TO_SPECIFY - else -> Value._UNKNOWN - } + /** The legal middle name of the individual. */ + fun middleName(middleName: String?) = middleName(JsonField.ofNullable(middleName)) - /** - * 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) { - ASIAN -> Known.ASIAN - WHITE -> Known.WHITE - BLACK_OR_AFRICAN_AMERICAN -> Known.BLACK_OR_AFRICAN_AMERICAN - NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER -> Known.NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER - AMERICAN_INDIAN_OR_ALASKA_NATIVE -> Known.AMERICAN_INDIAN_OR_ALASKA_NATIVE - HISPANIC_OR_LATINO -> Known.HISPANIC_OR_LATINO - TWO_OR_MORE_RACES -> Known.TWO_OR_MORE_RACES - DECLINE_TO_SPECIFY -> Known.DECLINE_TO_SPECIFY - else -> throw FinchInvalidDataException("Unknown Ethnicity: $value") - } + /** Alias for calling [Builder.middleName] with `middleName.orElse(null)`. */ + fun middleName(middleName: Optional) = middleName(middleName.getOrNull()) - /** - * 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") } + /** + * Sets [Builder.middleName] to an arbitrary JSON value. + * + * You should usually call [Builder.middleName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun middleName(middleName: JsonField) = apply { this.middleName = middleName } - private var validated: Boolean = false + fun phoneNumbers(phoneNumbers: List?) = + phoneNumbers(JsonField.ofNullable(phoneNumbers)) - fun validate(): Ethnicity = apply { - if (validated) { - return@apply - } + /** Alias for calling [Builder.phoneNumbers] with `phoneNumbers.orElse(null)`. */ + fun phoneNumbers(phoneNumbers: Optional>) = + phoneNumbers(phoneNumbers.getOrNull()) - known() - validated = true - } + /** + * Sets [Builder.phoneNumbers] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumbers] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun phoneNumbers(phoneNumbers: JsonField>) = apply { + this.phoneNumbers = phoneNumbers.map { it.toMutableList() } + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false + /** + * Adds a single [PhoneNumber] to [phoneNumbers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPhoneNumber(phoneNumber: PhoneNumber) = apply { + phoneNumbers = + (phoneNumbers ?: JsonField.of(mutableListOf())).also { + checkKnown("phoneNumbers", it).add(phoneNumber) + } } - /** - * 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 + /** The preferred name of the individual. */ + fun preferredName(preferredName: String?) = + preferredName(JsonField.ofNullable(preferredName)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** Alias for calling [Builder.preferredName] with `preferredName.orElse(null)`. */ + fun preferredName(preferredName: Optional) = + preferredName(preferredName.getOrNull()) + + /** + * Sets [Builder.preferredName] to an arbitrary JSON value. + * + * You should usually call [Builder.preferredName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun preferredName(preferredName: JsonField) = apply { + this.preferredName = preferredName } - return /* spotless:off */ other is Ethnicity && value == other.value /* spotless:on */ - } + fun residence(residence: Location?) = residence(JsonField.ofNullable(residence)) - override fun hashCode() = value.hashCode() + /** Alias for calling [Builder.residence] with `residence.orElse(null)`. */ + fun residence(residence: Optional) = residence(residence.getOrNull()) - override fun toString() = value.toString() - } + /** + * Sets [Builder.residence] to an arbitrary JSON value. + * + * You should usually call [Builder.residence] with a well-typed [Location] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun residence(residence: JsonField) = apply { this.residence = residence } - /** The gender of the individual. */ - class Gender @JsonCreator private constructor(private val value: JsonField) : Enum { + fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) - /** - * 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 + /** Alias for calling [Builder.emails] with `emails.orElse(null)`. */ + fun emails(emails: Optional>) = emails(emails.getOrNull()) - companion object { + /** + * Sets [Builder.emails] to an arbitrary JSON value. + * + * You should usually call [Builder.emails] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun emails(emails: JsonField>) = apply { + this.emails = emails.map { it.toMutableList() } + } - @JvmField val FEMALE = of("female") + /** + * Adds a single [Email] to [emails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEmail(email: Email) = apply { + emails = + (emails ?: JsonField.of(mutableListOf())).also { + checkKnown("emails", it).add(email) + } + } - @JvmField val MALE = of("male") + /** + * Social Security Number of the individual in **encrypted** format. This field is only + * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param + * set in the body. + */ + fun encryptedSsn(encryptedSsn: String?) = + encryptedSsn(JsonField.ofNullable(encryptedSsn)) - @JvmField val OTHER = of("other") + /** Alias for calling [Builder.encryptedSsn] with `encryptedSsn.orElse(null)`. */ + fun encryptedSsn(encryptedSsn: Optional) = + encryptedSsn(encryptedSsn.getOrNull()) - @JvmField val DECLINE_TO_SPECIFY = of("decline_to_specify") + /** + * Sets [Builder.encryptedSsn] to an arbitrary JSON value. + * + * You should usually call [Builder.encryptedSsn] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun encryptedSsn(encryptedSsn: JsonField) = apply { + this.encryptedSsn = encryptedSsn + } - @JvmStatic fun of(value: String) = Gender(JsonField.of(value)) - } + /** + * Social Security Number of the individual. This field is only available with the `ssn` + * scope enabled and the `options: { include: ['ssn'] }` param set in the body. + * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). + */ + fun ssn(ssn: String?) = ssn(JsonField.ofNullable(ssn)) - /** An enum containing [Gender]'s known values. */ - enum class Known { - FEMALE, - MALE, - OTHER, - DECLINE_TO_SPECIFY, - } + /** Alias for calling [Builder.ssn] with `ssn.orElse(null)`. */ + fun ssn(ssn: Optional) = ssn(ssn.getOrNull()) - /** - * An enum containing [Gender]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Gender] 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 { - FEMALE, - MALE, - OTHER, - DECLINE_TO_SPECIFY, - /** An enum member indicating that [Gender] was instantiated with an unknown value. */ - _UNKNOWN, - } + /** + * Sets [Builder.ssn] to an arbitrary JSON value. + * + * You should usually call [Builder.ssn] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ssn(ssn: JsonField) = apply { this.ssn = ssn } - /** - * 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) { - FEMALE -> Value.FEMALE - MALE -> Value.MALE - OTHER -> Value.OTHER - DECLINE_TO_SPECIFY -> Value.DECLINE_TO_SPECIFY - else -> Value._UNKNOWN + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * 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) { - FEMALE -> Known.FEMALE - MALE -> Known.MALE - OTHER -> Known.OTHER - DECLINE_TO_SPECIFY -> Known.DECLINE_TO_SPECIFY - else -> throw FinchInvalidDataException("Unknown Gender: $value") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, 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") } + 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 [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dob() + * .ethnicity() + * .firstName() + * .gender() + * .lastName() + * .middleName() + * .phoneNumbers() + * .preferredName() + * .residence() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnionMember0 = + UnionMember0( + checkRequired("id", id), + checkRequired("dob", dob), + checkRequired("ethnicity", ethnicity), + checkRequired("firstName", firstName), + checkRequired("gender", gender), + checkRequired("lastName", lastName), + checkRequired("middleName", middleName), + checkRequired("phoneNumbers", phoneNumbers).map { it.toImmutable() }, + checkRequired("preferredName", preferredName), + checkRequired("residence", residence), + (emails ?: JsonMissing.of()).map { it.toImmutable() }, + encryptedSsn, + ssn, + additionalProperties.toMutableMap(), + ) + } private var validated: Boolean = false - fun validate(): Gender = apply { + fun validate(): UnionMember0 = apply { if (validated) { return@apply } - known() + id() + dob() + ethnicity().ifPresent { it.validate() } + firstName() + gender().ifPresent { it.validate() } + lastName() + middleName() + phoneNumbers().ifPresent { it.forEach { it?.validate() } } + preferredName() + residence().ifPresent { it.validate() } + emails().ifPresent { it.forEach { it.validate() } } + encryptedSsn() + ssn() validated = true } @@ -973,293 +872,820 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dob.asKnown().isPresent) 1 else 0) + + (ethnicity.asKnown().getOrNull()?.validity() ?: 0) + + (if (firstName.asKnown().isPresent) 1 else 0) + + (gender.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastName.asKnown().isPresent) 1 else 0) + + (if (middleName.asKnown().isPresent) 1 else 0) + + (phoneNumbers.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + + (if (preferredName.asKnown().isPresent) 1 else 0) + + (residence.asKnown().getOrNull()?.validity() ?: 0) + + (emails.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (encryptedSsn.asKnown().isPresent) 1 else 0) + + (if (ssn.asKnown().isPresent) 1 else 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The EEOC-defined ethnicity of the individual. */ + class Ethnicity @JsonCreator private constructor(private val value: JsonField) : + Enum { - return /* spotless:off */ other is Gender && value == other.value /* spotless:on */ - } + /** + * 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 - override fun hashCode() = value.hashCode() + companion object { - override fun toString() = value.toString() - } + @JvmField val ASIAN = of("asian") - class PhoneNumber - private constructor( - private val data: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { + @JvmField val WHITE = of("white") - @JsonCreator - private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(data, type, mutableMapOf()) + @JvmField val BLACK_OR_AFRICAN_AMERICAN = of("black_or_african_american") - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") + @JvmField + val NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER = of("native_hawaiian_or_pacific_islander") - /** - * @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") + @JvmField + val AMERICAN_INDIAN_OR_ALASKA_NATIVE = of("american_indian_or_alaska_native") - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JvmField val HISPANIC_OR_LATINO = of("hispanic_or_latino") - /** - * 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 + @JvmField val TWO_OR_MORE_RACES = of("two_or_more_races") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmField val DECLINE_TO_SPECIFY = of("decline_to_specify") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmStatic fun of(value: String) = Ethnicity(JsonField.of(value)) + } - fun toBuilder() = Builder().from(this) + /** An enum containing [Ethnicity]'s known values. */ + enum class Known { + ASIAN, + WHITE, + BLACK_OR_AFRICAN_AMERICAN, + NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER, + AMERICAN_INDIAN_OR_ALASKA_NATIVE, + HISPANIC_OR_LATINO, + TWO_OR_MORE_RACES, + DECLINE_TO_SPECIFY, + } - companion object { + /** + * An enum containing [Ethnicity]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Ethnicity] 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 { + ASIAN, + WHITE, + BLACK_OR_AFRICAN_AMERICAN, + NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER, + AMERICAN_INDIAN_OR_ALASKA_NATIVE, + HISPANIC_OR_LATINO, + TWO_OR_MORE_RACES, + DECLINE_TO_SPECIFY, + /** + * An enum member indicating that [Ethnicity] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } /** - * Returns a mutable builder for constructing an instance of [PhoneNumber]. + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. * - * The following fields are required: - * ```java - * .data() - * .type() - * ``` + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. */ - @JvmStatic fun builder() = Builder() - } + fun value(): Value = + when (this) { + ASIAN -> Value.ASIAN + WHITE -> Value.WHITE + BLACK_OR_AFRICAN_AMERICAN -> Value.BLACK_OR_AFRICAN_AMERICAN + NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER -> Value.NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER + AMERICAN_INDIAN_OR_ALASKA_NATIVE -> Value.AMERICAN_INDIAN_OR_ALASKA_NATIVE + HISPANIC_OR_LATINO -> Value.HISPANIC_OR_LATINO + TWO_OR_MORE_RACES -> Value.TWO_OR_MORE_RACES + DECLINE_TO_SPECIFY -> Value.DECLINE_TO_SPECIFY + else -> Value._UNKNOWN + } - /** A builder for [PhoneNumber]. */ - class Builder internal constructor() { + /** + * 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) { + ASIAN -> Known.ASIAN + WHITE -> Known.WHITE + BLACK_OR_AFRICAN_AMERICAN -> Known.BLACK_OR_AFRICAN_AMERICAN + NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER -> Known.NATIVE_HAWAIIAN_OR_PACIFIC_ISLANDER + AMERICAN_INDIAN_OR_ALASKA_NATIVE -> Known.AMERICAN_INDIAN_OR_ALASKA_NATIVE + HISPANIC_OR_LATINO -> Known.HISPANIC_OR_LATINO + TWO_OR_MORE_RACES -> Known.TWO_OR_MORE_RACES + DECLINE_TO_SPECIFY -> Known.DECLINE_TO_SPECIFY + else -> throw FinchInvalidDataException("Unknown Ethnicity: $value") + } - private var data: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * 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") + } - @JvmSynthetic - internal fun from(phoneNumber: PhoneNumber) = apply { - data = phoneNumber.data - type = phoneNumber.type - additionalProperties = phoneNumber.additionalProperties.toMutableMap() - } + private var validated: Boolean = false + + fun validate(): Ethnicity = apply { + if (validated) { + return@apply + } - fun data(data: String?) = data(JsonField.ofNullable(data)) + known() + validated = true + } - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } /** - * Sets [Builder.data] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.data] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * Used for best match union deserialization. */ - fun data(data: JsonField) = apply { this.data = data } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - fun type(type: Type?) = type(JsonField.ofNullable(type)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Ethnicity && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) + override fun toString() = value.toString() + } + + /** The gender of the individual. */ + class Gender @JsonCreator private constructor(private val value: JsonField) : Enum { /** - * Sets [Builder.type] to an arbitrary JSON value. + * Returns this class instance's raw 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. + * 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. */ - fun type(type: JsonField) = apply { this.type = type } + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + companion object { + + @JvmField val FEMALE = of("female") + + @JvmField val MALE = of("male") + + @JvmField val OTHER = of("other") + + @JvmField val DECLINE_TO_SPECIFY = of("decline_to_specify") + + @JvmStatic fun of(value: String) = Gender(JsonField.of(value)) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** An enum containing [Gender]'s known values. */ + enum class Known { + FEMALE, + MALE, + OTHER, + DECLINE_TO_SPECIFY, } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + /** + * An enum containing [Gender]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Gender] 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 { + FEMALE, + MALE, + OTHER, + DECLINE_TO_SPECIFY, + /** + * An enum member indicating that [Gender] was instantiated with an unknown value. + */ + _UNKNOWN, } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * 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) { + FEMALE -> Value.FEMALE + MALE -> Value.MALE + OTHER -> Value.OTHER + DECLINE_TO_SPECIFY -> Value.DECLINE_TO_SPECIFY + else -> Value._UNKNOWN + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * 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) { + FEMALE -> Known.FEMALE + MALE -> Known.MALE + OTHER -> Known.OTHER + DECLINE_TO_SPECIFY -> Known.DECLINE_TO_SPECIFY + else -> throw FinchInvalidDataException("Unknown Gender: $value") + } /** - * Returns an immutable instance of [PhoneNumber]. + * Returns this class instance's primitive wire representation. * - * Further updates to this [Builder] will not mutate the returned instance. + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. * - * The following fields are required: - * ```java - * .data() - * .type() - * ``` + * @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 + + fun validate(): Gender = 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. * - * @throws IllegalStateException if any required field is unset. + * Used for best match union deserialization. */ - fun build(): PhoneNumber = - PhoneNumber( - checkRequired("data", data), - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): PhoneNumber = apply { - if (validated) { - return@apply + return /* spotless:off */ other is Gender && value == other.value /* spotless:on */ } - data() - type().ifPresent { it.validate() } - validated = true + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false + class PhoneNumber + private constructor( + private val data: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(data, type, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @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 [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [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) } - /** - * 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 (data.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PhoneNumber]. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PhoneNumber]. */ + class Builder internal constructor() { + + private var data: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(phoneNumber: PhoneNumber) = apply { + data = phoneNumber.data + type = phoneNumber.type + additionalProperties = phoneNumber.additionalProperties.toMutableMap() + } + + fun data(data: String?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun type(type: Type?) = 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 [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 [PhoneNumber]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PhoneNumber = + PhoneNumber( + checkRequired("data", data), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PhoneNumber = apply { + if (validated) { + return@apply + } + + data() + 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 (data.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 WORK = of("work") + + @JvmField val PERSONAL = of("personal") - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } - /** - * 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 + /** An enum containing [Type]'s known values. */ + enum class Known { + WORK, + PERSONAL, + } - companion object { + /** + * 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 { + WORK, + PERSONAL, + /** + * 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) { + WORK -> Value.WORK + PERSONAL -> Value.PERSONAL + 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) { + WORK -> Known.WORK + PERSONAL -> Known.PERSONAL + 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 + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } - @JvmField val WORK = of("work") + 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } - @JvmField val PERSONAL = of("personal") + override fun hashCode() = value.hashCode() - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + override fun toString() = value.toString() } - /** An enum containing [Type]'s known values. */ - enum class Known { - WORK, - PERSONAL, + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PhoneNumber && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(data, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PhoneNumber{data=$data, type=$type, additionalProperties=$additionalProperties}" + } + + class Email + private constructor( + private val data: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(data, type, mutableMapOf()) + /** - * 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. + * @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). */ - enum class Value { - WORK, - PERSONAL, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } + fun data(): String = data.getRequired("data") /** - * 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. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - fun value(): Value = - when (this) { - WORK -> Value.WORK - PERSONAL -> Value.PERSONAL - else -> Value._UNKNOWN - } + fun type(): Optional = type.getOptional("type") /** - * 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. + * Returns the raw JSON value of [data]. * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. */ - fun known(): Known = - when (this) { - WORK -> Known.WORK - PERSONAL -> Known.PERSONAL - else -> throw FinchInvalidDataException("Unknown Type: $value") - } + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data /** - * Returns this class instance's primitive wire representation. + * Returns the raw JSON value of [type]. * - * 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. + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") + @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 [Email]. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Email]. */ + class Builder internal constructor() { + + private var data: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(email: Email) = apply { + data = email.data + type = email.type + additionalProperties = email.additionalProperties.toMutableMap() + } + + fun data(data: String) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun type(type: Type?) = 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 [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 [Email]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Email = + Email( + checkRequired("data", data), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false - fun validate(): Type = apply { + fun validate(): Email = apply { if (validated) { return@apply } - known() + data() + type().ifPresent { it.validate() } validated = true } @@ -1277,19 +1703,157 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (if (data.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 WORK = of("work") + + @JvmField val PERSONAL = of("personal") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + WORK, + PERSONAL, + } + + /** + * 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 { + WORK, + PERSONAL, + /** + * 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) { + WORK -> Value.WORK + PERSONAL -> Value.PERSONAL + 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) { + WORK -> Known.WORK + PERSONAL -> Known.PERSONAL + 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 + + 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Email && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode() = value.hashCode() + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(data, type, additionalProperties) } + /* spotless:on */ - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "Email{data=$data, type=$type, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1297,57 +1861,89 @@ private constructor( return true } - return /* spotless:off */ other is PhoneNumber && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnionMember0 && id == other.id && dob == other.dob && ethnicity == other.ethnicity && firstName == other.firstName && gender == other.gender && lastName == other.lastName && middleName == other.middleName && phoneNumbers == other.phoneNumbers && preferredName == other.preferredName && residence == other.residence && emails == other.emails && encryptedSsn == other.encryptedSsn && ssn == other.ssn && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, dob, ethnicity, firstName, gender, lastName, middleName, phoneNumbers, preferredName, residence, emails, encryptedSsn, ssn, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "PhoneNumber{data=$data, type=$type, additionalProperties=$additionalProperties}" + "UnionMember0{id=$id, dob=$dob, ethnicity=$ethnicity, firstName=$firstName, gender=$gender, lastName=$lastName, middleName=$middleName, phoneNumbers=$phoneNumbers, preferredName=$preferredName, residence=$residence, emails=$emails, encryptedSsn=$encryptedSsn, ssn=$ssn, additionalProperties=$additionalProperties}" } - class Email + class UnionMember1 private constructor( - private val data: JsonField, - private val type: JsonField, + private val code: JsonField, + private val message: JsonField, + private val name: JsonField, + private val finchCode: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(data, type, mutableMapOf()) + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("finch_code") + @ExcludeMissing + finchCode: JsonField = JsonMissing.of(), + ) : this(code, message, name, finchCode, mutableMapOf()) + + /** + * @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 code(): Double = code.getRequired("code") + + /** + * @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 message(): String = message.getRequired("message") /** * @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 data(): String = data.getRequired("data") + fun name(): String = name.getRequired("name") /** * @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") + fun finchCode(): Optional = finchCode.getOptional("finch_code") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message /** - * Returns the raw JSON value of [data]. + * Returns the raw JSON value of [name]. * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [type]. + * Returns the raw JSON value of [finchCode]. * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [finchCode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("finch_code") @ExcludeMissing fun _finchCode(): JsonField = finchCode @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1364,55 +1960,79 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Email]. + * Returns a mutable builder for constructing an instance of [UnionMember1]. * * The following fields are required: * ```java - * .data() - * .type() + * .code() + * .message() + * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [Email]. */ + /** A builder for [UnionMember1]. */ class Builder internal constructor() { - private var data: JsonField? = null - private var type: JsonField? = null + private var code: JsonField? = null + private var message: JsonField? = null + private var name: JsonField? = null + private var finchCode: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(email: Email) = apply { - data = email.data - type = email.type - additionalProperties = email.additionalProperties.toMutableMap() + internal fun from(unionMember1: UnionMember1) = apply { + code = unionMember1.code + message = unionMember1.message + name = unionMember1.name + finchCode = unionMember1.finchCode + additionalProperties = unionMember1.additionalProperties.toMutableMap() } - fun data(data: String) = data(JsonField.of(data)) + fun code(code: Double) = code(JsonField.of(code)) /** - * Sets [Builder.data] to an arbitrary JSON value. + * Sets [Builder.code] to an arbitrary JSON value. * - * You should usually call [Builder.data] with a well-typed [String] value instead. This + * You should usually call [Builder.code] with a well-typed [Double] value instead. This * method is primarily for setting the field to an undocumented or not yet supported * value. */ - fun data(data: JsonField) = apply { this.data = data } + fun code(code: JsonField) = apply { this.code = code } + + fun message(message: String) = message(JsonField.of(message)) - fun type(type: Type?) = type(JsonField.ofNullable(type)) + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun message(message: JsonField) = apply { this.message = message } - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) + fun name(name: String) = name(JsonField.of(name)) /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets [Builder.name] to an arbitrary JSON value. * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * You should usually call [Builder.name] with a well-typed [String] value instead. This * method is primarily for setting the field to an undocumented or not yet supported * value. */ - fun type(type: JsonField) = apply { this.type = type } + fun name(name: JsonField) = apply { this.name = name } + + fun finchCode(finchCode: String) = finchCode(JsonField.of(finchCode)) + + /** + * Sets [Builder.finchCode] to an arbitrary JSON value. + * + * You should usually call [Builder.finchCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun finchCode(finchCode: JsonField) = apply { this.finchCode = finchCode } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1434,35 +2054,40 @@ private constructor( } /** - * Returns an immutable instance of [Email]. + * Returns an immutable instance of [UnionMember1]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .data() - * .type() + * .code() + * .message() + * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): Email = - Email( - checkRequired("data", data), - checkRequired("type", type), + fun build(): UnionMember1 = + UnionMember1( + checkRequired("code", code), + checkRequired("message", message), + checkRequired("name", name), + finchCode, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Email = apply { + fun validate(): UnionMember1 = apply { if (validated) { return@apply } - data() - type().ifPresent { it.validate() } + code() + message() + name() + finchCode() validated = true } @@ -1482,167 +2107,26 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (data.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 WORK = of("work") - - @JvmField val PERSONAL = of("personal") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - WORK, - PERSONAL, - } - - /** - * 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 { - WORK, - PERSONAL, - /** 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) { - WORK -> Value.WORK - PERSONAL -> Value.PERSONAL - 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) { - WORK -> Known.WORK - PERSONAL -> Known.PERSONAL - 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 - - 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + (if (code.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (finchCode.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Email && data == other.data && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnionMember1 && code == other.code && message == other.message && name == other.name && finchCode == other.finchCode && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(data, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(code, message, name, finchCode, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Email{data=$data, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Individual && id == other.id && dob == other.dob && ethnicity == other.ethnicity && firstName == other.firstName && gender == other.gender && lastName == other.lastName && middleName == other.middleName && phoneNumbers == other.phoneNumbers && preferredName == other.preferredName && residence == other.residence && emails == other.emails && encryptedSsn == other.encryptedSsn && ssn == other.ssn && additionalProperties == other.additionalProperties /* spotless:on */ + "UnionMember1{code=$code, message=$message, name=$name, finchCode=$finchCode, additionalProperties=$additionalProperties}" } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, dob, ethnicity, firstName, gender, lastName, middleName, phoneNumbers, preferredName, residence, emails, encryptedSsn, ssn, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Individual{id=$id, dob=$dob, ethnicity=$ethnicity, firstName=$firstName, gender=$gender, lastName=$lastName, middleName=$middleName, phoneNumbers=$phoneNumbers, preferredName=$preferredName, residence=$residence, emails=$emails, encryptedSsn=$encryptedSsn, ssn=$ssn, additionalProperties=$additionalProperties}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt index 249dd4b3..a3bf0e0f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt @@ -127,6 +127,14 @@ private constructor( */ fun body(body: JsonField) = apply { this.body = body } + /** Alias for calling [body] with `Individual.ofUnionMember0(unionMember0)`. */ + fun body(unionMember0: Individual.UnionMember0) = + body(Individual.ofUnionMember0(unionMember0)) + + /** Alias for calling [body] with `Individual.ofUnionMember1(unionMember1)`. */ + fun body(unionMember1: Individual.UnionMember1) = + body(Individual.ofUnionMember1(unionMember1)) + fun code(code: Long) = code(JsonField.of(code)) /** diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt index 8d32bf8c..28194510 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt @@ -16,18 +16,18 @@ internal class HrisIndividualRetrieveManyPageResponseTest { .addResponse( IndividualResponse.builder() .body( - Individual.builder() + Individual.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dob("dob") - .ethnicity(Individual.Ethnicity.ASIAN) + .ethnicity(Individual.UnionMember0.Ethnicity.ASIAN) .firstName("first_name") - .gender(Individual.Gender.FEMALE) + .gender(Individual.UnionMember0.Gender.FEMALE) .lastName("last_name") .middleName("middle_name") .addPhoneNumber( - Individual.PhoneNumber.builder() + Individual.UnionMember0.PhoneNumber.builder() .data("data") - .type(Individual.PhoneNumber.Type.WORK) + .type(Individual.UnionMember0.PhoneNumber.Type.WORK) .build() ) .preferredName("preferred_name") @@ -44,9 +44,9 @@ internal class HrisIndividualRetrieveManyPageResponseTest { .build() ) .addEmail( - Individual.Email.builder() + Individual.UnionMember0.Email.builder() .data("data") - .type(Individual.Email.Type.WORK) + .type(Individual.UnionMember0.Email.Type.WORK) .build() ) .encryptedSsn("encrypted_ssn") @@ -63,18 +63,18 @@ internal class HrisIndividualRetrieveManyPageResponseTest { .containsExactly( IndividualResponse.builder() .body( - Individual.builder() + Individual.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dob("dob") - .ethnicity(Individual.Ethnicity.ASIAN) + .ethnicity(Individual.UnionMember0.Ethnicity.ASIAN) .firstName("first_name") - .gender(Individual.Gender.FEMALE) + .gender(Individual.UnionMember0.Gender.FEMALE) .lastName("last_name") .middleName("middle_name") .addPhoneNumber( - Individual.PhoneNumber.builder() + Individual.UnionMember0.PhoneNumber.builder() .data("data") - .type(Individual.PhoneNumber.Type.WORK) + .type(Individual.UnionMember0.PhoneNumber.Type.WORK) .build() ) .preferredName("preferred_name") @@ -91,9 +91,9 @@ internal class HrisIndividualRetrieveManyPageResponseTest { .build() ) .addEmail( - Individual.Email.builder() + Individual.UnionMember0.Email.builder() .data("data") - .type(Individual.Email.Type.WORK) + .type(Individual.UnionMember0.Email.Type.WORK) .build() ) .encryptedSsn("encrypted_ssn") @@ -114,18 +114,18 @@ internal class HrisIndividualRetrieveManyPageResponseTest { .addResponse( IndividualResponse.builder() .body( - Individual.builder() + Individual.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dob("dob") - .ethnicity(Individual.Ethnicity.ASIAN) + .ethnicity(Individual.UnionMember0.Ethnicity.ASIAN) .firstName("first_name") - .gender(Individual.Gender.FEMALE) + .gender(Individual.UnionMember0.Gender.FEMALE) .lastName("last_name") .middleName("middle_name") .addPhoneNumber( - Individual.PhoneNumber.builder() + Individual.UnionMember0.PhoneNumber.builder() .data("data") - .type(Individual.PhoneNumber.Type.WORK) + .type(Individual.UnionMember0.PhoneNumber.Type.WORK) .build() ) .preferredName("preferred_name") @@ -142,9 +142,9 @@ internal class HrisIndividualRetrieveManyPageResponseTest { .build() ) .addEmail( - Individual.Email.builder() + Individual.UnionMember0.Email.builder() .data("data") - .type(Individual.Email.Type.WORK) + .type(Individual.UnionMember0.Email.Type.WORK) .build() ) .encryptedSsn("encrypted_ssn") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt index 8cb81209..3f480bc3 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt @@ -14,18 +14,18 @@ internal class IndividualResponseTest { val individualResponse = IndividualResponse.builder() .body( - Individual.builder() + Individual.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dob("dob") - .ethnicity(Individual.Ethnicity.ASIAN) + .ethnicity(Individual.UnionMember0.Ethnicity.ASIAN) .firstName("first_name") - .gender(Individual.Gender.FEMALE) + .gender(Individual.UnionMember0.Gender.FEMALE) .lastName("last_name") .middleName("middle_name") .addPhoneNumber( - Individual.PhoneNumber.builder() + Individual.UnionMember0.PhoneNumber.builder() .data("data") - .type(Individual.PhoneNumber.Type.WORK) + .type(Individual.UnionMember0.PhoneNumber.Type.WORK) .build() ) .preferredName("preferred_name") @@ -42,9 +42,9 @@ internal class IndividualResponseTest { .build() ) .addEmail( - Individual.Email.builder() + Individual.UnionMember0.Email.builder() .data("data") - .type(Individual.Email.Type.WORK) + .type(Individual.UnionMember0.Email.Type.WORK) .build() ) .encryptedSsn("encrypted_ssn") @@ -57,42 +57,44 @@ internal class IndividualResponseTest { assertThat(individualResponse.body()) .isEqualTo( - Individual.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dob("dob") - .ethnicity(Individual.Ethnicity.ASIAN) - .firstName("first_name") - .gender(Individual.Gender.FEMALE) - .lastName("last_name") - .middleName("middle_name") - .addPhoneNumber( - Individual.PhoneNumber.builder() - .data("data") - .type(Individual.PhoneNumber.Type.WORK) - .build() - ) - .preferredName("preferred_name") - .residence( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .name("name") - .sourceId("source_id") - .build() - ) - .addEmail( - Individual.Email.builder() - .data("data") - .type(Individual.Email.Type.WORK) - .build() - ) - .encryptedSsn("encrypted_ssn") - .ssn("ssn") - .build() + Individual.ofUnionMember0( + Individual.UnionMember0.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dob("dob") + .ethnicity(Individual.UnionMember0.Ethnicity.ASIAN) + .firstName("first_name") + .gender(Individual.UnionMember0.Gender.FEMALE) + .lastName("last_name") + .middleName("middle_name") + .addPhoneNumber( + Individual.UnionMember0.PhoneNumber.builder() + .data("data") + .type(Individual.UnionMember0.PhoneNumber.Type.WORK) + .build() + ) + .preferredName("preferred_name") + .residence( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .name("name") + .sourceId("source_id") + .build() + ) + .addEmail( + Individual.UnionMember0.Email.builder() + .data("data") + .type(Individual.UnionMember0.Email.Type.WORK) + .build() + ) + .encryptedSsn("encrypted_ssn") + .ssn("ssn") + .build() + ) ) assertThat(individualResponse.code()).isEqualTo(0L) assertThat(individualResponse.individualId()).isEqualTo("individual_id") @@ -104,18 +106,18 @@ internal class IndividualResponseTest { val individualResponse = IndividualResponse.builder() .body( - Individual.builder() + Individual.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dob("dob") - .ethnicity(Individual.Ethnicity.ASIAN) + .ethnicity(Individual.UnionMember0.Ethnicity.ASIAN) .firstName("first_name") - .gender(Individual.Gender.FEMALE) + .gender(Individual.UnionMember0.Gender.FEMALE) .lastName("last_name") .middleName("middle_name") .addPhoneNumber( - Individual.PhoneNumber.builder() + Individual.UnionMember0.PhoneNumber.builder() .data("data") - .type(Individual.PhoneNumber.Type.WORK) + .type(Individual.UnionMember0.PhoneNumber.Type.WORK) .build() ) .preferredName("preferred_name") @@ -132,9 +134,9 @@ internal class IndividualResponseTest { .build() ) .addEmail( - Individual.Email.builder() + Individual.UnionMember0.Email.builder() .data("data") - .type(Individual.Email.Type.WORK) + .type(Individual.UnionMember0.Email.Type.WORK) .build() ) .encryptedSsn("encrypted_ssn") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt index 2db9d62b..572f10d6 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt @@ -3,28 +3,32 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.jsonMapper -import kotlin.jvm.optionals.getOrNull +import com.tryfinch.api.errors.FinchInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource internal class IndividualTest { @Test - fun create() { - val individual = - Individual.builder() + fun ofUnionMember0() { + val unionMember0 = + Individual.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dob("dob") - .ethnicity(Individual.Ethnicity.ASIAN) + .ethnicity(Individual.UnionMember0.Ethnicity.ASIAN) .firstName("first_name") - .gender(Individual.Gender.FEMALE) + .gender(Individual.UnionMember0.Gender.FEMALE) .lastName("last_name") .middleName("middle_name") .addPhoneNumber( - Individual.PhoneNumber.builder() + Individual.UnionMember0.PhoneNumber.builder() .data("data") - .type(Individual.PhoneNumber.Type.WORK) + .type(Individual.UnionMember0.PhoneNumber.Type.WORK) .build() ) .preferredName("preferred_name") @@ -41,85 +45,101 @@ internal class IndividualTest { .build() ) .addEmail( - Individual.Email.builder().data("data").type(Individual.Email.Type.WORK).build() + Individual.UnionMember0.Email.builder() + .data("data") + .type(Individual.UnionMember0.Email.Type.WORK) + .build() ) .encryptedSsn("encrypted_ssn") .ssn("ssn") .build() - assertThat(individual.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(individual.dob()).contains("dob") - assertThat(individual.ethnicity()).contains(Individual.Ethnicity.ASIAN) - assertThat(individual.firstName()).contains("first_name") - assertThat(individual.gender()).contains(Individual.Gender.FEMALE) - assertThat(individual.lastName()).contains("last_name") - assertThat(individual.middleName()).contains("middle_name") - assertThat(individual.phoneNumbers().getOrNull()) - .containsExactly( - Individual.PhoneNumber.builder() - .data("data") - .type(Individual.PhoneNumber.Type.WORK) - .build() - ) - assertThat(individual.preferredName()).contains("preferred_name") - assertThat(individual.residence()) - .contains( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .name("name") - .sourceId("source_id") + val individual = Individual.ofUnionMember0(unionMember0) + + assertThat(individual.unionMember0()).contains(unionMember0) + assertThat(individual.unionMember1()).isEmpty + } + + @Test + fun ofUnionMember0Roundtrip() { + val jsonMapper = jsonMapper() + val individual = + Individual.ofUnionMember0( + Individual.UnionMember0.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dob("dob") + .ethnicity(Individual.UnionMember0.Ethnicity.ASIAN) + .firstName("first_name") + .gender(Individual.UnionMember0.Gender.FEMALE) + .lastName("last_name") + .middleName("middle_name") + .addPhoneNumber( + Individual.UnionMember0.PhoneNumber.builder() + .data("data") + .type(Individual.UnionMember0.PhoneNumber.Type.WORK) + .build() + ) + .preferredName("preferred_name") + .residence( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .name("name") + .sourceId("source_id") + .build() + ) + .addEmail( + Individual.UnionMember0.Email.builder() + .data("data") + .type(Individual.UnionMember0.Email.Type.WORK) + .build() + ) + .encryptedSsn("encrypted_ssn") + .ssn("ssn") .build() ) - assertThat(individual.emails().getOrNull()) - .containsExactly( - Individual.Email.builder().data("data").type(Individual.Email.Type.WORK).build() + + val roundtrippedIndividual = + jsonMapper.readValue( + jsonMapper.writeValueAsString(individual), + jacksonTypeRef(), ) - assertThat(individual.encryptedSsn()).contains("encrypted_ssn") - assertThat(individual.ssn()).contains("ssn") + + assertThat(roundtrippedIndividual).isEqualTo(individual) } @Test - fun roundtrip() { + fun ofUnionMember1() { + val unionMember1 = + Individual.UnionMember1.builder() + .code(0.0) + .message("message") + .name("name") + .finchCode("finch_code") + .build() + + val individual = Individual.ofUnionMember1(unionMember1) + + assertThat(individual.unionMember0()).isEmpty + assertThat(individual.unionMember1()).contains(unionMember1) + } + + @Test + fun ofUnionMember1Roundtrip() { val jsonMapper = jsonMapper() val individual = - Individual.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dob("dob") - .ethnicity(Individual.Ethnicity.ASIAN) - .firstName("first_name") - .gender(Individual.Gender.FEMALE) - .lastName("last_name") - .middleName("middle_name") - .addPhoneNumber( - Individual.PhoneNumber.builder() - .data("data") - .type(Individual.PhoneNumber.Type.WORK) - .build() - ) - .preferredName("preferred_name") - .residence( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .name("name") - .sourceId("source_id") - .build() - ) - .addEmail( - Individual.Email.builder().data("data").type(Individual.Email.Type.WORK).build() - ) - .encryptedSsn("encrypted_ssn") - .ssn("ssn") - .build() + Individual.ofUnionMember1( + Individual.UnionMember1.builder() + .code(0.0) + .message("message") + .name("name") + .finchCode("finch_code") + .build() + ) val roundtrippedIndividual = jsonMapper.readValue( @@ -129,4 +149,21 @@ internal class IndividualTest { assertThat(roundtrippedIndividual).isEqualTo(individual) } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val individual = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { individual.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } } From 9e451d0ea744078d1c4f10c878a950ca3719237b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 29 Apr 2025 10:50:03 +0000 Subject: [PATCH 15/27] feat(api): api update --- .stats.yml | 4 +- .../com/tryfinch/api/models/CompanyBenefit.kt | 34 +- .../api/models/HrisBenefitCreateParams.kt | 604 +++++++++++++++++- .../tryfinch/api/models/CompanyBenefitTest.kt | 12 +- .../api/models/HrisBenefitCreateParamsTest.kt | 34 + .../async/hris/BenefitServiceAsyncTest.kt | 14 + .../blocking/hris/BenefitServiceTest.kt | 14 + 7 files changed, 684 insertions(+), 32 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8ed0ece0..7aa72ef0 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%2Ffinch-639dd4ab9ac2acad21a6764fda369a1d189a3e64bf71a65db36daf0f32d98242.yml -openapi_spec_hash: c148f859bdd0b723c856bd472f115f1f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-0583a6e86a80bc62551727b12c37e02a9b4e4ac5bce822b2e2c1cade3588a6f4.yml +openapi_spec_hash: 53783b6cc1f63d9fb5d3a4dba7b0a806 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyBenefit.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyBenefit.kt index 5cce568b..2ece80bf 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyBenefit.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyBenefit.kt @@ -511,37 +511,37 @@ private constructor( class Tier private constructor( - private val match: JsonField, - private val threshold: JsonField, + private val match: JsonField, + private val threshold: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("match") @ExcludeMissing match: JsonField = JsonMissing.of(), + @JsonProperty("match") @ExcludeMissing match: JsonField = JsonMissing.of(), @JsonProperty("threshold") @ExcludeMissing - threshold: JsonField = JsonMissing.of(), + threshold: JsonField = JsonMissing.of(), ) : this(match, threshold, mutableMapOf()) /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun match(): Optional = match.getOptional("match") + fun match(): Optional = match.getOptional("match") /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun threshold(): Optional = threshold.getOptional("threshold") + fun threshold(): Optional = threshold.getOptional("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 + @JsonProperty("match") @ExcludeMissing fun _match(): JsonField = match /** * Returns the raw JSON value of [threshold]. @@ -549,9 +549,7 @@ private constructor( * Unlike [threshold], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("threshold") - @ExcludeMissing - fun _threshold(): JsonField = threshold + @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField = threshold @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -574,8 +572,8 @@ private constructor( /** A builder for [Tier]. */ class Builder internal constructor() { - private var match: JsonField = JsonMissing.of() - private var threshold: JsonField = JsonMissing.of() + private var match: JsonField = JsonMissing.of() + private var threshold: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -585,27 +583,27 @@ private constructor( additionalProperties = tier.additionalProperties.toMutableMap() } - fun match(match: Double) = match(JsonField.of(match)) + 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 [Double] value instead. + * 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 } + fun match(match: JsonField) = apply { this.match = match } - fun threshold(threshold: Double) = threshold(JsonField.of(threshold)) + 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 [Double] 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 threshold(threshold: JsonField) = apply { this.threshold = threshold } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitCreateParams.kt index 72a4557e..80d41eaa 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitCreateParams.kt @@ -6,13 +6,16 @@ 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.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 @@ -30,6 +33,15 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { + /** + * The company match for this benefit. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun companyContribution(): Optional = + body.companyContribution() + /** * Name of the benefit as it appears in the provider and pay statements. Recommend limiting this * to <30 characters due to limitations in specific providers (e.g. Justworks). @@ -55,6 +67,15 @@ private constructor( */ fun type(): Optional = body.type() + /** + * Returns the raw JSON value of [companyContribution]. + * + * Unlike [companyContribution], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _companyContribution(): JsonField = + body._companyContribution() + /** * Returns the raw JSON value of [description]. * @@ -111,12 +132,36 @@ private constructor( * * 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: + * - [companyContribution] * - [description] * - [frequency] * - [type] */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** The company match for this benefit. */ + fun companyContribution(companyContribution: BenefitCompanyMatchContribution?) = apply { + body.companyContribution(companyContribution) + } + + /** + * Alias for calling [Builder.companyContribution] with `companyContribution.orElse(null)`. + */ + fun companyContribution(companyContribution: Optional) = + companyContribution(companyContribution.getOrNull()) + + /** + * Sets [Builder.companyContribution] to an arbitrary JSON value. + * + * You should usually call [Builder.companyContribution] with a well-typed + * [BenefitCompanyMatchContribution] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun companyContribution(companyContribution: JsonField) = + apply { + body.companyContribution(companyContribution) + } + /** * Name of the benefit as it appears in the provider and pay statements. Recommend limiting * this to <30 characters due to limitations in specific providers (e.g. Justworks). @@ -300,6 +345,7 @@ private constructor( class Body private constructor( + private val companyContribution: JsonField, private val description: JsonField, private val frequency: JsonField, private val type: JsonField, @@ -308,6 +354,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("company_contribution") + @ExcludeMissing + companyContribution: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), @@ -315,7 +364,16 @@ private constructor( @ExcludeMissing frequency: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(description, frequency, type, mutableMapOf()) + ) : this(companyContribution, description, frequency, type, mutableMapOf()) + + /** + * The company match for this benefit. + * + * @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") /** * Name of the benefit as it appears in the provider and pay statements. Recommend limiting @@ -342,6 +400,16 @@ private constructor( */ fun type(): Optional = type.getOptional("type") + /** + * 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 [description]. * @@ -388,6 +456,8 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var companyContribution: JsonField = + JsonMissing.of() private var description: JsonField = JsonMissing.of() private var frequency: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -395,12 +465,36 @@ private constructor( @JvmSynthetic internal fun from(body: Body) = apply { + companyContribution = body.companyContribution description = body.description frequency = body.frequency type = body.type additionalProperties = body.additionalProperties.toMutableMap() } + /** The company match for this benefit. */ + fun companyContribution(companyContribution: BenefitCompanyMatchContribution?) = + companyContribution(JsonField.ofNullable(companyContribution)) + + /** + * Alias for calling [Builder.companyContribution] with + * `companyContribution.orElse(null)`. + */ + fun companyContribution( + companyContribution: Optional + ) = companyContribution(companyContribution.getOrNull()) + + /** + * Sets [Builder.companyContribution] to an arbitrary JSON value. + * + * You should usually call [Builder.companyContribution] with a well-typed + * [BenefitCompanyMatchContribution] 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 } + /** * Name of the benefit as it appears in the provider and pay statements. Recommend * limiting this to <30 characters due to limitations in specific providers (e.g. @@ -476,7 +570,13 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Body = - Body(description, frequency, type, additionalProperties.toMutableMap()) + Body( + companyContribution, + description, + frequency, + type, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -486,6 +586,7 @@ private constructor( return@apply } + companyContribution().ifPresent { it.validate() } description() frequency().ifPresent { it.validate() } type().ifPresent { it.validate() } @@ -508,7 +609,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (description.asKnown().isPresent) 1 else 0) + + (companyContribution.asKnown().getOrNull()?.validity() ?: 0) + + (if (description.asKnown().isPresent) 1 else 0) + (frequency.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) @@ -517,17 +619,507 @@ private constructor( return true } - return /* spotless:off */ other is Body && description == other.description && frequency == other.frequency && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Body && companyContribution == other.companyContribution && description == other.description && frequency == other.frequency && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(companyContribution, description, frequency, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{companyContribution=$companyContribution, description=$description, frequency=$frequency, type=$type, additionalProperties=$additionalProperties}" + } + + /** The company match for this benefit. */ + class BenefitCompanyMatchContribution + private constructor( + private val tiers: JsonField>, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tiers") @ExcludeMissing tiers: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(tiers, type, mutableMapOf()) + + /** + * @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 [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 + * [BenefitCompanyMatchContribution]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BenefitCompanyMatchContribution]. */ + class Builder internal constructor() { + + private var tiers: JsonField>? = null + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(benefitCompanyMatchContribution: BenefitCompanyMatchContribution) = + apply { + tiers = benefitCompanyMatchContribution.tiers.map { it.toMutableList() } + type = benefitCompanyMatchContribution.type + additionalProperties = + benefitCompanyMatchContribution.additionalProperties.toMutableMap() + } + + 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 [BenefitCompanyMatchContribution]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BenefitCompanyMatchContribution = + BenefitCompanyMatchContribution( + (tiers ?: JsonMissing.of()).map { it.toImmutable() }, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BenefitCompanyMatchContribution = apply { + if (validated) { + return@apply + } + + 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 = + (tiers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Tier + 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()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun match(): Optional = match.getOptional("match") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun threshold(): Optional = threshold.getOptional("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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tier]. */ + class Builder internal constructor() { + + private var match: JsonField = JsonMissing.of() + private var threshold: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tier: Tier) = apply { + match = tier.match + threshold = tier.threshold + additionalProperties = tier.additionalProperties.toMutableMap() + } + + 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 } + + 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. + */ + fun build(): Tier = Tier(match, threshold, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + 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 /* spotless:off */ other is Tier && match == other.match && threshold == other.threshold && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(match, threshold, additionalProperties) } + /* spotless:on */ + + 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 MATCH = of("match") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + MATCH + } + + /** + * 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 { + MATCH, + /** 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) { + MATCH -> Value.MATCH + 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) { + MATCH -> Known.MATCH + 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 + + 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BenefitCompanyMatchContribution && tiers == other.tiers && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(description, frequency, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(tiers, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Body{description=$description, frequency=$frequency, type=$type, additionalProperties=$additionalProperties}" + "BenefitCompanyMatchContribution{tiers=$tiers, type=$type, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt index cd0ff6a2..7f4ae9bc 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt @@ -18,8 +18,8 @@ internal class CompanyBenefitTest { CompanyBenefit.BenefitCompanyMatchContribution.builder() .addTier( CompanyBenefit.BenefitCompanyMatchContribution.Tier.builder() - .match(1.0) - .threshold(1.0) + .match(1L) + .threshold(1L) .build() ) .type(CompanyBenefit.BenefitCompanyMatchContribution.Type.MATCH) @@ -36,8 +36,8 @@ internal class CompanyBenefitTest { CompanyBenefit.BenefitCompanyMatchContribution.builder() .addTier( CompanyBenefit.BenefitCompanyMatchContribution.Tier.builder() - .match(1.0) - .threshold(1.0) + .match(1L) + .threshold(1L) .build() ) .type(CompanyBenefit.BenefitCompanyMatchContribution.Type.MATCH) @@ -58,8 +58,8 @@ internal class CompanyBenefitTest { CompanyBenefit.BenefitCompanyMatchContribution.builder() .addTier( CompanyBenefit.BenefitCompanyMatchContribution.Tier.builder() - .match(1.0) - .threshold(1.0) + .match(1L) + .threshold(1L) .build() ) .type(CompanyBenefit.BenefitCompanyMatchContribution.Type.MATCH) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitCreateParamsTest.kt index fea44e47..d16fa73a 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitCreateParamsTest.kt @@ -10,6 +10,17 @@ internal class HrisBenefitCreateParamsTest { @Test fun create() { HrisBenefitCreateParams.builder() + .companyContribution( + HrisBenefitCreateParams.BenefitCompanyMatchContribution.builder() + .addTier( + HrisBenefitCreateParams.BenefitCompanyMatchContribution.Tier.builder() + .match(1L) + .threshold(1L) + .build() + ) + .type(HrisBenefitCreateParams.BenefitCompanyMatchContribution.Type.MATCH) + .build() + ) .description("description") .frequency(BenefitFrequency.ONE_TIME) .type(BenefitType._401K) @@ -20,6 +31,17 @@ internal class HrisBenefitCreateParamsTest { fun body() { val params = HrisBenefitCreateParams.builder() + .companyContribution( + HrisBenefitCreateParams.BenefitCompanyMatchContribution.builder() + .addTier( + HrisBenefitCreateParams.BenefitCompanyMatchContribution.Tier.builder() + .match(1L) + .threshold(1L) + .build() + ) + .type(HrisBenefitCreateParams.BenefitCompanyMatchContribution.Type.MATCH) + .build() + ) .description("description") .frequency(BenefitFrequency.ONE_TIME) .type(BenefitType._401K) @@ -27,6 +49,18 @@ internal class HrisBenefitCreateParamsTest { val body = params._body() + assertThat(body.companyContribution()) + .contains( + HrisBenefitCreateParams.BenefitCompanyMatchContribution.builder() + .addTier( + HrisBenefitCreateParams.BenefitCompanyMatchContribution.Tier.builder() + .match(1L) + .threshold(1L) + .build() + ) + .type(HrisBenefitCreateParams.BenefitCompanyMatchContribution.Type.MATCH) + .build() + ) assertThat(body.description()).contains("description") assertThat(body.frequency()).contains(BenefitFrequency.ONE_TIME) assertThat(body.type()).contains(BenefitType._401K) 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 93d19f5a..861af561 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 @@ -27,6 +27,20 @@ internal class BenefitServiceAsyncTest { val createCompanyBenefitsResponseFuture = benefitServiceAsync.create( HrisBenefitCreateParams.builder() + .companyContribution( + HrisBenefitCreateParams.BenefitCompanyMatchContribution.builder() + .addTier( + HrisBenefitCreateParams.BenefitCompanyMatchContribution.Tier + .builder() + .match(1L) + .threshold(1L) + .build() + ) + .type( + HrisBenefitCreateParams.BenefitCompanyMatchContribution.Type.MATCH + ) + .build() + ) .description("description") .frequency(BenefitFrequency.ONE_TIME) .type(BenefitType._401K) 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 f04e7929..bdcc2d7f 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 @@ -27,6 +27,20 @@ internal class BenefitServiceTest { val createCompanyBenefitsResponse = benefitService.create( HrisBenefitCreateParams.builder() + .companyContribution( + HrisBenefitCreateParams.BenefitCompanyMatchContribution.builder() + .addTier( + HrisBenefitCreateParams.BenefitCompanyMatchContribution.Tier + .builder() + .match(1L) + .threshold(1L) + .build() + ) + .type( + HrisBenefitCreateParams.BenefitCompanyMatchContribution.Type.MATCH + ) + .build() + ) .description("description") .frequency(BenefitFrequency.ONE_TIME) .type(BenefitType._401K) From a9fefbc485cfa35d7c34aa409333a7b2e244f26a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 29 Apr 2025 13:33:23 +0000 Subject: [PATCH 16/27] feat(api): api update --- .stats.yml | 4 +- .../com/tryfinch/api/models/Individual.kt | 63 +++++++++---------- .../tryfinch/api/models/IndividualResponse.kt | 5 +- .../com/tryfinch/api/models/IndividualTest.kt | 18 +++--- 4 files changed, 44 insertions(+), 46 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7aa72ef0..9bc1b534 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%2Ffinch-0583a6e86a80bc62551727b12c37e02a9b4e4ac5bce822b2e2c1cade3588a6f4.yml -openapi_spec_hash: 53783b6cc1f63d9fb5d3a4dba7b0a806 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-e5ab676f0996530fe4c702d8cbb88862ab8382792d01197a9576e06f5a359d00.yml +openapi_spec_hash: d5d110fa239579917a521521145c1264 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt index 52ef21a7..5197ccd9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt @@ -36,28 +36,28 @@ import kotlin.jvm.optionals.getOrNull class Individual private constructor( private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, + private val batchError: BatchError? = null, private val _json: JsonValue? = null, ) { fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + fun batchError(): Optional = Optional.ofNullable(batchError) fun isUnionMember0(): Boolean = unionMember0 != null - fun isUnionMember1(): Boolean = unionMember1 != null + fun isBatchError(): Boolean = batchError != null fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + fun asBatchError(): BatchError = batchError.getOrThrow("batchError") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + batchError != null -> visitor.visitBatchError(batchError) else -> visitor.unknown(_json) } @@ -74,8 +74,8 @@ private constructor( unionMember0.validate() } - override fun visitUnionMember1(unionMember1: UnionMember1) { - unionMember1.validate() + override fun visitBatchError(batchError: BatchError) { + batchError.validate() } } ) @@ -101,7 +101,7 @@ private constructor( object : Visitor { override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() - override fun visitUnionMember1(unionMember1: UnionMember1) = unionMember1.validity() + override fun visitBatchError(batchError: BatchError) = batchError.validity() override fun unknown(json: JsonValue?) = 0 } @@ -112,15 +112,15 @@ private constructor( return true } - return /* spotless:off */ other is Individual && unionMember0 == other.unionMember0 && unionMember1 == other.unionMember1 /* spotless:on */ + return /* spotless:off */ other is Individual && unionMember0 == other.unionMember0 && batchError == other.batchError /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, unionMember1) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, batchError) /* spotless:on */ override fun toString(): String = when { unionMember0 != null -> "Individual{unionMember0=$unionMember0}" - unionMember1 != null -> "Individual{unionMember1=$unionMember1}" + batchError != null -> "Individual{batchError=$batchError}" _json != null -> "Individual{_unknown=$_json}" else -> throw IllegalStateException("Invalid Individual") } @@ -130,8 +130,7 @@ private constructor( @JvmStatic fun ofUnionMember0(unionMember0: UnionMember0) = Individual(unionMember0 = unionMember0) - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Individual(unionMember1 = unionMember1) + @JvmStatic fun ofBatchError(batchError: BatchError) = Individual(batchError = batchError) } /** An interface that defines how to map each variant of [Individual] to a value of type [T]. */ @@ -139,7 +138,7 @@ private constructor( fun visitUnionMember0(unionMember0: UnionMember0): T - fun visitUnionMember1(unionMember1: UnionMember1): T + fun visitBatchError(batchError: BatchError): T /** * Maps an unknown variant of [Individual] to a value of type [T]. @@ -165,8 +164,8 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { Individual(unionMember0 = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Individual(unionMember1 = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + Individual(batchError = it, _json = json) }, ) .filterNotNull() @@ -193,7 +192,7 @@ private constructor( ) { when { value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value.batchError != null -> generator.writeObject(value.batchError) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Individual") } @@ -1874,7 +1873,7 @@ private constructor( "UnionMember0{id=$id, dob=$dob, ethnicity=$ethnicity, firstName=$firstName, gender=$gender, lastName=$lastName, middleName=$middleName, phoneNumbers=$phoneNumbers, preferredName=$preferredName, residence=$residence, emails=$emails, encryptedSsn=$encryptedSsn, ssn=$ssn, additionalProperties=$additionalProperties}" } - class UnionMember1 + class BatchError private constructor( private val code: JsonField, private val message: JsonField, @@ -1960,7 +1959,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UnionMember1]. + * Returns a mutable builder for constructing an instance of [BatchError]. * * The following fields are required: * ```java @@ -1972,7 +1971,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UnionMember1]. */ + /** A builder for [BatchError]. */ class Builder internal constructor() { private var code: JsonField? = null @@ -1982,12 +1981,12 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - code = unionMember1.code - message = unionMember1.message - name = unionMember1.name - finchCode = unionMember1.finchCode - additionalProperties = unionMember1.additionalProperties.toMutableMap() + internal fun from(batchError: BatchError) = apply { + code = batchError.code + message = batchError.message + name = batchError.name + finchCode = batchError.finchCode + additionalProperties = batchError.additionalProperties.toMutableMap() } fun code(code: Double) = code(JsonField.of(code)) @@ -2054,7 +2053,7 @@ private constructor( } /** - * Returns an immutable instance of [UnionMember1]. + * Returns an immutable instance of [BatchError]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2067,8 +2066,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UnionMember1 = - UnionMember1( + fun build(): BatchError = + BatchError( checkRequired("code", code), checkRequired("message", message), checkRequired("name", name), @@ -2079,7 +2078,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnionMember1 = apply { + fun validate(): BatchError = apply { if (validated) { return@apply } @@ -2117,7 +2116,7 @@ private constructor( return true } - return /* spotless:off */ other is UnionMember1 && code == other.code && message == other.message && name == other.name && finchCode == other.finchCode && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BatchError && code == other.code && message == other.message && name == other.name && finchCode == other.finchCode && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2127,6 +2126,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnionMember1{code=$code, message=$message, name=$name, finchCode=$finchCode, additionalProperties=$additionalProperties}" + "BatchError{code=$code, message=$message, name=$name, finchCode=$finchCode, additionalProperties=$additionalProperties}" } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt index a3bf0e0f..e2930cf2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt @@ -131,9 +131,8 @@ private constructor( fun body(unionMember0: Individual.UnionMember0) = body(Individual.ofUnionMember0(unionMember0)) - /** Alias for calling [body] with `Individual.ofUnionMember1(unionMember1)`. */ - fun body(unionMember1: Individual.UnionMember1) = - body(Individual.ofUnionMember1(unionMember1)) + /** Alias for calling [body] with `Individual.ofBatchError(batchError)`. */ + fun body(batchError: Individual.BatchError) = body(Individual.ofBatchError(batchError)) fun code(code: Long) = code(JsonField.of(code)) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt index 572f10d6..b6ae2c0f 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt @@ -57,7 +57,7 @@ internal class IndividualTest { val individual = Individual.ofUnionMember0(unionMember0) assertThat(individual.unionMember0()).contains(unionMember0) - assertThat(individual.unionMember1()).isEmpty + assertThat(individual.batchError()).isEmpty } @Test @@ -113,27 +113,27 @@ internal class IndividualTest { } @Test - fun ofUnionMember1() { - val unionMember1 = - Individual.UnionMember1.builder() + fun ofBatchError() { + val batchError = + Individual.BatchError.builder() .code(0.0) .message("message") .name("name") .finchCode("finch_code") .build() - val individual = Individual.ofUnionMember1(unionMember1) + val individual = Individual.ofBatchError(batchError) assertThat(individual.unionMember0()).isEmpty - assertThat(individual.unionMember1()).contains(unionMember1) + assertThat(individual.batchError()).contains(batchError) } @Test - fun ofUnionMember1Roundtrip() { + fun ofBatchErrorRoundtrip() { val jsonMapper = jsonMapper() val individual = - Individual.ofUnionMember1( - Individual.UnionMember1.builder() + Individual.ofBatchError( + Individual.BatchError.builder() .code(0.0) .message("message") .name("name") From cc2b8288f7c3ce5bc62e7ca074fd53fc6f05e253 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 29 Apr 2025 22:32:32 +0000 Subject: [PATCH 17/27] feat(api): api update --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 9bc1b534..8eed112d 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%2Ffinch-e5ab676f0996530fe4c702d8cbb88862ab8382792d01197a9576e06f5a359d00.yml -openapi_spec_hash: d5d110fa239579917a521521145c1264 +openapi_spec_hash: 5c0dec3d2e1fea26d5f99560b226aedd config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 From d399e4f9395f2e84f6a97399ae6f0fdcbc34d7cd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 1 May 2025 16:16:26 +0000 Subject: [PATCH 18/27] feat(api): api update --- .stats.yml | 4 +- .../com/tryfinch/api/models/EmploymentData.kt | 3625 ++++++++++------- .../api/models/EmploymentDataResponse.kt | 63 +- .../kotlin/com/tryfinch/api/models/Income.kt | 39 +- .../api/models/EmploymentDataResponseTest.kt | 215 +- .../tryfinch/api/models/EmploymentDataTest.kt | 292 +- ...sEmploymentRetrieveManyPageResponseTest.kt | 169 +- 7 files changed, 2686 insertions(+), 1721 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8eed112d..209f18ee 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%2Ffinch-e5ab676f0996530fe4c702d8cbb88862ab8382792d01197a9576e06f5a359d00.yml -openapi_spec_hash: 5c0dec3d2e1fea26d5f99560b226aedd +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-9810fd8ae1eed14c34c83de1ac110dbfb8cc23d2ac930b641cb0ad40f327ecb8.yml +openapi_spec_hash: e0d44a94626fd6208a0d585ce93d7e89 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentData.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentData.kt index b90cc44a..d62ad375 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentData.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentData.kt @@ -6,12 +6,24 @@ 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.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.BaseDeserializer +import com.tryfinch.api.core.BaseSerializer 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.allMaxBy import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.getOrThrow import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections @@ -19,959 +31,595 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +@JsonDeserialize(using = EmploymentData.Deserializer::class) +@JsonSerialize(using = EmploymentData.Serializer::class) class EmploymentData private constructor( - private val id: JsonField, - private val classCode: JsonField, - private val customFields: JsonField>, - private val department: JsonField, - private val employment: JsonField, - private val employmentStatus: JsonField, - private val endDate: JsonField, - private val firstName: JsonField, - private val income: JsonField, - private val incomeHistory: JsonField>, - private val isActive: JsonField, - private val lastName: JsonField, - private val latestRehireDate: JsonField, - private val location: JsonField, - private val manager: JsonField, - private val middleName: JsonField, - private val sourceId: JsonField, - private val startDate: JsonField, - private val title: JsonField, - private val workId: JsonField, - private val additionalProperties: MutableMap, + private val unionMember0: UnionMember0? = null, + private val batchError: BatchError? = null, + private val _json: JsonValue? = null, ) { - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("class_code") @ExcludeMissing classCode: JsonField = JsonMissing.of(), - @JsonProperty("custom_fields") - @ExcludeMissing - customFields: JsonField> = JsonMissing.of(), - @JsonProperty("department") - @ExcludeMissing - department: JsonField = JsonMissing.of(), - @JsonProperty("employment") - @ExcludeMissing - employment: JsonField = JsonMissing.of(), - @JsonProperty("employment_status") - @ExcludeMissing - employmentStatus: JsonField = JsonMissing.of(), - @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), - @JsonProperty("first_name") @ExcludeMissing firstName: JsonField = JsonMissing.of(), - @JsonProperty("income") @ExcludeMissing income: JsonField = JsonMissing.of(), - @JsonProperty("income_history") - @ExcludeMissing - incomeHistory: JsonField> = JsonMissing.of(), - @JsonProperty("is_active") @ExcludeMissing isActive: JsonField = JsonMissing.of(), - @JsonProperty("last_name") @ExcludeMissing lastName: JsonField = JsonMissing.of(), - @JsonProperty("latest_rehire_date") - @ExcludeMissing - latestRehireDate: JsonField = JsonMissing.of(), - @JsonProperty("location") @ExcludeMissing location: JsonField = JsonMissing.of(), - @JsonProperty("manager") @ExcludeMissing manager: JsonField = JsonMissing.of(), - @JsonProperty("middle_name") - @ExcludeMissing - middleName: JsonField = JsonMissing.of(), - @JsonProperty("source_id") @ExcludeMissing sourceId: JsonField = JsonMissing.of(), - @JsonProperty("start_date") @ExcludeMissing startDate: JsonField = JsonMissing.of(), - @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), - @JsonProperty("work_id") @ExcludeMissing workId: JsonField = JsonMissing.of(), - ) : this( - id, - classCode, - customFields, - department, - employment, - employmentStatus, - endDate, - firstName, - income, - incomeHistory, - isActive, - lastName, - latestRehireDate, - location, - manager, - middleName, - sourceId, - startDate, - title, - workId, - mutableMapOf(), - ) - - /** - * A stable Finch `id` (UUID v4) for an individual in the company. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - - /** - * Worker's compensation classification code for this employee - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun classCode(): Optional = classCode.getOptional("class_code") - - /** - * Custom fields for the individual. These are fields which are defined by the employer in the - * system. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun customFields(): Optional> = customFields.getOptional("custom_fields") - - /** - * The department object. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun department(): Optional = department.getOptional("department") - - /** - * The employment object. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun employment(): Optional = employment.getOptional("employment") - - /** - * The detailed employment status of the individual. Available options: `active`, `deceased`, - * `leave`, `onboarding`, `prehire`, `retired`, `terminated`. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun employmentStatus(): Optional = - employmentStatus.getOptional("employment_status") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun endDate(): Optional = endDate.getOptional("end_date") - - /** - * The legal first name of the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun firstName(): Optional = firstName.getOptional("first_name") - - /** - * The employee's income as reported by the provider. This may not always be annualized income, - * but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what information the - * provider returns. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun income(): Optional = income.getOptional("income") - - /** - * The array of income history. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun incomeHistory(): Optional> = incomeHistory.getOptional("income_history") - - /** - * `true` if the individual an an active employee or contractor at the company. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun isActive(): Optional = isActive.getOptional("is_active") - - /** - * The legal last name of the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun lastName(): Optional = lastName.getOptional("last_name") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun latestRehireDate(): Optional = latestRehireDate.getOptional("latest_rehire_date") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun location(): Optional = location.getOptional("location") + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - /** - * The manager object representing the manager of the individual within the org. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun manager(): Optional = manager.getOptional("manager") + fun batchError(): Optional = Optional.ofNullable(batchError) - /** - * The legal middle name of the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun middleName(): Optional = middleName.getOptional("middle_name") + fun isUnionMember0(): Boolean = unionMember0 != null - /** - * The source system's unique employment identifier for this individual - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun sourceId(): Optional = sourceId.getOptional("source_id") + fun isBatchError(): Boolean = batchError != null - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun startDate(): Optional = startDate.getOptional("start_date") + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - /** - * The current title of the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun title(): Optional = title.getOptional("title") + fun asBatchError(): BatchError = batchError.getOrThrow("batchError") - /** - * This field is deprecated in favour of `source_id` - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - @Deprecated("deprecated") fun workId(): Optional = workId.getOptional("work_id") + fun _json(): Optional = Optional.ofNullable(_json) - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + batchError != null -> visitor.visitBatchError(batchError) + else -> visitor.unknown(_json) + } - /** - * Returns the raw JSON value of [classCode]. - * - * Unlike [classCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("class_code") @ExcludeMissing fun _classCode(): JsonField = classCode + private var validated: Boolean = false - /** - * Returns the raw JSON value of [customFields]. - * - * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("custom_fields") - @ExcludeMissing - fun _customFields(): JsonField> = customFields + fun validate(): EmploymentData = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [department]. - * - * Unlike [department], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("department") - @ExcludeMissing - fun _department(): JsonField = department + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } - /** - * Returns the raw JSON value of [employment]. - * - * Unlike [employment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("employment") - @ExcludeMissing - fun _employment(): JsonField = employment + override fun visitBatchError(batchError: BatchError) { + batchError.validate() + } + } + ) + validated = true + } - /** - * Returns the raw JSON value of [employmentStatus]. - * - * Unlike [employmentStatus], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("employment_status") - @ExcludeMissing - fun _employmentStatus(): JsonField = employmentStatus + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } /** - * Returns the raw JSON value of [endDate]. + * Returns a score indicating how many valid values are contained in this object recursively. * - * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() - /** - * Returns the raw JSON value of [firstName]. - * - * Unlike [firstName], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName + override fun visitBatchError(batchError: BatchError) = batchError.validity() - /** - * Returns the raw JSON value of [income]. - * - * Unlike [income], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("income") @ExcludeMissing fun _income(): JsonField = income + override fun unknown(json: JsonValue?) = 0 + } + ) - /** - * Returns the raw JSON value of [incomeHistory]. - * - * Unlike [incomeHistory], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("income_history") - @ExcludeMissing - fun _incomeHistory(): JsonField> = incomeHistory + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [isActive]. - * - * Unlike [isActive], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("is_active") @ExcludeMissing fun _isActive(): JsonField = isActive + return /* spotless:off */ other is EmploymentData && unionMember0 == other.unionMember0 && batchError == other.batchError /* spotless:on */ + } - /** - * Returns the raw JSON value of [lastName]. - * - * Unlike [lastName], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, batchError) /* spotless:on */ - /** - * Returns the raw JSON value of [latestRehireDate]. - * - * Unlike [latestRehireDate], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("latest_rehire_date") - @ExcludeMissing - fun _latestRehireDate(): JsonField = latestRehireDate + override fun toString(): String = + when { + unionMember0 != null -> "EmploymentData{unionMember0=$unionMember0}" + batchError != null -> "EmploymentData{batchError=$batchError}" + _json != null -> "EmploymentData{_unknown=$_json}" + else -> throw IllegalStateException("Invalid EmploymentData") + } - /** - * Returns the raw JSON value of [location]. - * - * Unlike [location], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location + companion object { - /** - * Returns the raw JSON value of [manager]. - * - * Unlike [manager], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("manager") @ExcludeMissing fun _manager(): JsonField = manager + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = EmploymentData(unionMember0 = unionMember0) - /** - * Returns the raw JSON value of [middleName]. - * - * Unlike [middleName], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("middle_name") @ExcludeMissing fun _middleName(): JsonField = middleName + @JvmStatic + fun ofBatchError(batchError: BatchError) = EmploymentData(batchError = batchError) + } /** - * Returns the raw JSON value of [sourceId]. - * - * Unlike [sourceId], this method doesn't throw if the JSON field has an unexpected type. + * An interface that defines how to map each variant of [EmploymentData] to a value of type [T]. */ - @JsonProperty("source_id") @ExcludeMissing fun _sourceId(): JsonField = sourceId + interface Visitor { - /** - * Returns the raw JSON value of [startDate]. - * - * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate(): JsonField = startDate + fun visitUnionMember0(unionMember0: UnionMember0): T - /** - * Returns the raw JSON value of [title]. - * - * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + fun visitBatchError(batchError: BatchError): T - /** - * Returns the raw JSON value of [workId]. - * - * Unlike [workId], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("work_id") - @ExcludeMissing - fun _workId(): JsonField = workId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + /** + * Maps an unknown variant of [EmploymentData] to a value of type [T]. + * + * An instance of [EmploymentData] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is unaware + * of. + * + * @throws FinchInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw FinchInvalidDataException("Unknown EmploymentData: $json") + } } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [EmploymentData]. */ - @JvmStatic fun builder() = Builder() + internal class Deserializer : BaseDeserializer(EmploymentData::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): EmploymentData { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + EmploymentData(unionMember0 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + EmploymentData(batchError = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> EmploymentData(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } } - /** A builder for [EmploymentData]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var classCode: JsonField = JsonMissing.of() - private var customFields: JsonField>? = null - private var department: JsonField = JsonMissing.of() - private var employment: JsonField = JsonMissing.of() - private var employmentStatus: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var firstName: JsonField = JsonMissing.of() - private var income: JsonField = JsonMissing.of() - private var incomeHistory: JsonField>? = null - private var isActive: JsonField = JsonMissing.of() - private var lastName: JsonField = JsonMissing.of() - private var latestRehireDate: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var manager: JsonField = JsonMissing.of() - private var middleName: JsonField = JsonMissing.of() - private var sourceId: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var title: JsonField = JsonMissing.of() - private var workId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(employmentData: EmploymentData) = apply { - id = employmentData.id - classCode = employmentData.classCode - customFields = employmentData.customFields.map { it.toMutableList() } - department = employmentData.department - employment = employmentData.employment - employmentStatus = employmentData.employmentStatus - endDate = employmentData.endDate - firstName = employmentData.firstName - income = employmentData.income - incomeHistory = employmentData.incomeHistory.map { it.toMutableList() } - isActive = employmentData.isActive - lastName = employmentData.lastName - latestRehireDate = employmentData.latestRehireDate - location = employmentData.location - manager = employmentData.manager - middleName = employmentData.middleName - sourceId = employmentData.sourceId - startDate = employmentData.startDate - title = employmentData.title - workId = employmentData.workId - additionalProperties = employmentData.additionalProperties.toMutableMap() + internal class Serializer : BaseSerializer(EmploymentData::class) { + + override fun serialize( + value: EmploymentData, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.batchError != null -> generator.writeObject(value.batchError) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid EmploymentData") + } } + } + + class UnionMember0 + private constructor( + private val id: JsonField, + private val classCode: JsonField, + private val customFields: JsonField>, + private val department: JsonField, + private val employment: JsonField, + private val employmentStatus: JsonField, + private val endDate: JsonField, + private val firstName: JsonField, + private val isActive: JsonField, + private val lastName: JsonField, + private val latestRehireDate: JsonField, + private val location: JsonField, + private val manager: JsonField, + private val middleName: JsonField, + private val sourceId: JsonField, + private val startDate: JsonField, + private val title: JsonField, + private val workId: JsonField, + private val income: JsonField, + private val incomeHistory: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** A stable Finch `id` (UUID v4) for an individual in the company. */ - fun id(id: String) = id(JsonField.of(id)) + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("class_code") + @ExcludeMissing + classCode: JsonField = JsonMissing.of(), + @JsonProperty("custom_fields") + @ExcludeMissing + customFields: JsonField> = JsonMissing.of(), + @JsonProperty("department") + @ExcludeMissing + department: JsonField = JsonMissing.of(), + @JsonProperty("employment") + @ExcludeMissing + employment: JsonField = JsonMissing.of(), + @JsonProperty("employment_status") + @ExcludeMissing + employmentStatus: JsonField = JsonMissing.of(), + @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), + @JsonProperty("first_name") + @ExcludeMissing + firstName: JsonField = JsonMissing.of(), + @JsonProperty("is_active") + @ExcludeMissing + isActive: JsonField = JsonMissing.of(), + @JsonProperty("last_name") + @ExcludeMissing + lastName: JsonField = JsonMissing.of(), + @JsonProperty("latest_rehire_date") + @ExcludeMissing + latestRehireDate: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + location: JsonField = JsonMissing.of(), + @JsonProperty("manager") @ExcludeMissing manager: JsonField = JsonMissing.of(), + @JsonProperty("middle_name") + @ExcludeMissing + middleName: JsonField = JsonMissing.of(), + @JsonProperty("source_id") + @ExcludeMissing + sourceId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + @JsonProperty("work_id") @ExcludeMissing workId: JsonField = JsonMissing.of(), + @JsonProperty("income") @ExcludeMissing income: JsonField = JsonMissing.of(), + @JsonProperty("income_history") + @ExcludeMissing + incomeHistory: JsonField> = JsonMissing.of(), + ) : this( + id, + classCode, + customFields, + department, + employment, + employmentStatus, + endDate, + firstName, + isActive, + lastName, + latestRehireDate, + location, + manager, + middleName, + sourceId, + startDate, + title, + workId, + income, + incomeHistory, + mutableMapOf(), + ) /** - * Sets [Builder.id] to an arbitrary JSON value. + * A stable Finch `id` (UUID v4) for an individual in the company. * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * @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 id(id: JsonField) = apply { this.id = id } - - /** Worker's compensation classification code for this employee */ - fun classCode(classCode: String?) = classCode(JsonField.ofNullable(classCode)) - - /** Alias for calling [Builder.classCode] with `classCode.orElse(null)`. */ - fun classCode(classCode: Optional) = classCode(classCode.getOrNull()) + fun id(): String = id.getRequired("id") /** - * Sets [Builder.classCode] to an arbitrary JSON value. + * Worker's compensation classification code for this employee * - * You should usually call [Builder.classCode] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun classCode(classCode: JsonField) = apply { this.classCode = classCode } + fun classCode(): Optional = classCode.getOptional("class_code") /** * Custom fields for the individual. These are fields which are defined by the employer in * the system. - */ - fun customFields(customFields: List?) = - customFields(JsonField.ofNullable(customFields)) - - /** Alias for calling [Builder.customFields] with `customFields.orElse(null)`. */ - fun customFields(customFields: Optional>) = - customFields(customFields.getOrNull()) - - /** - * Sets [Builder.customFields] to an arbitrary JSON value. * - * You should usually call [Builder.customFields] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun customFields(customFields: JsonField>) = apply { - this.customFields = customFields.map { it.toMutableList() } - } + fun customFields(): Optional> = customFields.getOptional("custom_fields") /** - * Adds a single [CustomField] to [customFields]. + * The department object. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun addCustomField(customField: CustomField) = apply { - customFields = - (customFields ?: JsonField.of(mutableListOf())).also { - checkKnown("customFields", it).add(customField) - } - } - - /** The department object. */ - fun department(department: Department?) = department(JsonField.ofNullable(department)) - - /** Alias for calling [Builder.department] with `department.orElse(null)`. */ - fun department(department: Optional) = department(department.getOrNull()) + fun department(): Optional = department.getOptional("department") /** - * Sets [Builder.department] to an arbitrary JSON value. + * The employment object. * - * You should usually call [Builder.department] with a well-typed [Department] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun department(department: JsonField) = apply { this.department = department } - - /** The employment object. */ - fun employment(employment: Employment?) = employment(JsonField.ofNullable(employment)) - - /** Alias for calling [Builder.employment] with `employment.orElse(null)`. */ - fun employment(employment: Optional) = employment(employment.getOrNull()) + fun employment(): Optional = employment.getOptional("employment") /** - * Sets [Builder.employment] to an arbitrary JSON value. + * The detailed employment status of the individual. Available options: `active`, + * `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. * - * You should usually call [Builder.employment] with a well-typed [Employment] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun employment(employment: JsonField) = apply { this.employment = employment } + fun employmentStatus(): Optional = + employmentStatus.getOptional("employment_status") /** - * The detailed employment status of the individual. Available options: `active`, - * `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun employmentStatus(employmentStatus: EmploymentStatus?) = - employmentStatus(JsonField.ofNullable(employmentStatus)) - - /** Alias for calling [Builder.employmentStatus] with `employmentStatus.orElse(null)`. */ - fun employmentStatus(employmentStatus: Optional) = - employmentStatus(employmentStatus.getOrNull()) + fun endDate(): Optional = endDate.getOptional("end_date") /** - * Sets [Builder.employmentStatus] to an arbitrary JSON value. + * The legal first name of the individual. * - * You should usually call [Builder.employmentStatus] with a well-typed [EmploymentStatus] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun employmentStatus(employmentStatus: JsonField) = apply { - this.employmentStatus = employmentStatus - } - - fun endDate(endDate: String?) = endDate(JsonField.ofNullable(endDate)) - - /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ - fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) + fun firstName(): Optional = firstName.getOptional("first_name") /** - * Sets [Builder.endDate] to an arbitrary JSON value. + * `true` if the individual an an active employee or contractor at the company. * - * You should usually call [Builder.endDate] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - - /** The legal first name of the individual. */ - fun firstName(firstName: String?) = firstName(JsonField.ofNullable(firstName)) - - /** Alias for calling [Builder.firstName] with `firstName.orElse(null)`. */ - fun firstName(firstName: Optional) = firstName(firstName.getOrNull()) + fun isActive(): Optional = isActive.getOptional("is_active") /** - * Sets [Builder.firstName] to an arbitrary JSON value. + * The legal last name of the individual. * - * You should usually call [Builder.firstName] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun firstName(firstName: JsonField) = apply { this.firstName = firstName } + fun lastName(): Optional = lastName.getOptional("last_name") /** - * The employee's income as reported by the provider. This may not always be annualized - * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what - * information the provider returns. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun income(income: Income?) = income(JsonField.ofNullable(income)) - - /** Alias for calling [Builder.income] with `income.orElse(null)`. */ - fun income(income: Optional) = income(income.getOrNull()) + fun latestRehireDate(): Optional = + latestRehireDate.getOptional("latest_rehire_date") /** - * Sets [Builder.income] to an arbitrary JSON value. - * - * You should usually call [Builder.income] with a well-typed [Income] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun income(income: JsonField) = apply { this.income = income } - - /** The array of income history. */ - fun incomeHistory(incomeHistory: List?) = - incomeHistory(JsonField.ofNullable(incomeHistory)) - - /** Alias for calling [Builder.incomeHistory] with `incomeHistory.orElse(null)`. */ - fun incomeHistory(incomeHistory: Optional>) = - incomeHistory(incomeHistory.getOrNull()) + fun location(): Optional = location.getOptional("location") /** - * Sets [Builder.incomeHistory] to an arbitrary JSON value. + * The manager object representing the manager of the individual within the org. * - * You should usually call [Builder.incomeHistory] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun incomeHistory(incomeHistory: JsonField>) = apply { - this.incomeHistory = incomeHistory.map { it.toMutableList() } - } + fun manager(): Optional = manager.getOptional("manager") /** - * Adds a single [Income] to [Builder.incomeHistory]. + * The legal middle name of the individual. * - * @throws IllegalStateException if the field was previously set to a non-list. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun addIncomeHistory(incomeHistory: Income) = apply { - this.incomeHistory = - (this.incomeHistory ?: JsonField.of(mutableListOf())).also { - checkKnown("incomeHistory", it).add(incomeHistory) - } - } - - /** `true` if the individual an an active employee or contractor at the company. */ - fun isActive(isActive: Boolean?) = isActive(JsonField.ofNullable(isActive)) + fun middleName(): Optional = middleName.getOptional("middle_name") /** - * Alias for [Builder.isActive]. + * The source system's unique employment identifier for this individual * - * This unboxed primitive overload exists for backwards compatibility. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun isActive(isActive: Boolean) = isActive(isActive as Boolean?) + fun sourceId(): Optional = sourceId.getOptional("source_id") - /** Alias for calling [Builder.isActive] with `isActive.orElse(null)`. */ - fun isActive(isActive: Optional) = isActive(isActive.getOrNull()) + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun startDate(): Optional = startDate.getOptional("start_date") /** - * Sets [Builder.isActive] to an arbitrary JSON value. + * The current title of the individual. * - * You should usually call [Builder.isActive] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - - /** The legal last name of the individual. */ - fun lastName(lastName: String?) = lastName(JsonField.ofNullable(lastName)) - - /** Alias for calling [Builder.lastName] with `lastName.orElse(null)`. */ - fun lastName(lastName: Optional) = lastName(lastName.getOrNull()) + fun title(): Optional = title.getOptional("title") /** - * Sets [Builder.lastName] to an arbitrary JSON value. + * This field is deprecated in favour of `source_id` * - * You should usually call [Builder.lastName] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun lastName(lastName: JsonField) = apply { this.lastName = lastName } - - fun latestRehireDate(latestRehireDate: String?) = - latestRehireDate(JsonField.ofNullable(latestRehireDate)) - - /** Alias for calling [Builder.latestRehireDate] with `latestRehireDate.orElse(null)`. */ - fun latestRehireDate(latestRehireDate: Optional) = - latestRehireDate(latestRehireDate.getOrNull()) + @Deprecated("deprecated") fun workId(): Optional = workId.getOptional("work_id") /** - * Sets [Builder.latestRehireDate] to an arbitrary JSON value. + * The employee's income as reported by the provider. This may not always be annualized + * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what + * information the provider returns. * - * You should usually call [Builder.latestRehireDate] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun latestRehireDate(latestRehireDate: JsonField) = apply { - this.latestRehireDate = latestRehireDate - } - - fun location(location: Location?) = location(JsonField.ofNullable(location)) - - /** Alias for calling [Builder.location] with `location.orElse(null)`. */ - fun location(location: Optional) = location(location.getOrNull()) + fun income(): Optional = income.getOptional("income") /** - * Sets [Builder.location] to an arbitrary JSON value. + * The array of income history. * - * You should usually call [Builder.location] with a well-typed [Location] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun location(location: JsonField) = apply { this.location = location } - - /** The manager object representing the manager of the individual within the org. */ - fun manager(manager: Manager?) = manager(JsonField.ofNullable(manager)) - - /** Alias for calling [Builder.manager] with `manager.orElse(null)`. */ - fun manager(manager: Optional) = manager(manager.getOrNull()) + fun incomeHistory(): Optional> = incomeHistory.getOptional("income_history") /** - * Sets [Builder.manager] to an arbitrary JSON value. + * Returns the raw JSON value of [id]. * - * You should usually call [Builder.manager] with a well-typed [Manager] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun manager(manager: JsonField) = apply { this.manager = manager } - - /** The legal middle name of the individual. */ - fun middleName(middleName: String?) = middleName(JsonField.ofNullable(middleName)) - - /** Alias for calling [Builder.middleName] with `middleName.orElse(null)`. */ - fun middleName(middleName: Optional) = middleName(middleName.getOrNull()) + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Sets [Builder.middleName] to an arbitrary JSON value. + * Returns the raw JSON value of [classCode]. * - * You should usually call [Builder.middleName] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * Unlike [classCode], this method doesn't throw if the JSON field has an unexpected type. */ - fun middleName(middleName: JsonField) = apply { this.middleName = middleName } - - /** The source system's unique employment identifier for this individual */ - fun sourceId(sourceId: String?) = sourceId(JsonField.ofNullable(sourceId)) - - /** Alias for calling [Builder.sourceId] with `sourceId.orElse(null)`. */ - fun sourceId(sourceId: Optional) = sourceId(sourceId.getOrNull()) + @JsonProperty("class_code") @ExcludeMissing fun _classCode(): JsonField = classCode /** - * Sets [Builder.sourceId] to an arbitrary JSON value. + * Returns the raw JSON value of [customFields]. * - * You should usually call [Builder.sourceId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun sourceId(sourceId: JsonField) = apply { this.sourceId = sourceId } - - fun startDate(startDate: String?) = startDate(JsonField.ofNullable(startDate)) - - /** Alias for calling [Builder.startDate] with `startDate.orElse(null)`. */ - fun startDate(startDate: Optional) = startDate(startDate.getOrNull()) + @JsonProperty("custom_fields") + @ExcludeMissing + fun _customFields(): JsonField> = customFields /** - * Sets [Builder.startDate] to an arbitrary JSON value. + * Returns the raw JSON value of [department]. * - * You should usually call [Builder.startDate] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * Unlike [department], this method doesn't throw if the JSON field has an unexpected type. */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - - /** The current title of the individual. */ - fun title(title: String?) = title(JsonField.ofNullable(title)) - - /** Alias for calling [Builder.title] with `title.orElse(null)`. */ - fun title(title: Optional) = title(title.getOrNull()) + @JsonProperty("department") + @ExcludeMissing + fun _department(): JsonField = department /** - * Sets [Builder.title] to an arbitrary JSON value. + * Returns the raw JSON value of [employment]. * - * You should usually call [Builder.title] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * Unlike [employment], this method doesn't throw if the JSON field has an unexpected type. */ - fun title(title: JsonField) = apply { this.title = title } - - /** This field is deprecated in favour of `source_id` */ - @Deprecated("deprecated") fun workId(workId: String?) = workId(JsonField.ofNullable(workId)) - - /** Alias for calling [Builder.workId] with `workId.orElse(null)`. */ - @Deprecated("deprecated") fun workId(workId: Optional) = workId(workId.getOrNull()) + @JsonProperty("employment") + @ExcludeMissing + fun _employment(): JsonField = employment /** - * Sets [Builder.workId] to an arbitrary JSON value. + * Returns the raw JSON value of [employmentStatus]. * - * You should usually call [Builder.workId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * Unlike [employmentStatus], this method doesn't throw if the JSON field has an unexpected + * type. */ - @Deprecated("deprecated") - fun workId(workId: JsonField) = apply { this.workId = workId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JsonProperty("employment_status") + @ExcludeMissing + fun _employmentStatus(): JsonField = employmentStatus - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Returns the raw JSON value of [firstName]. + * + * Unlike [firstName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** + * Returns the raw JSON value of [isActive]. + * + * Unlike [isActive], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_active") @ExcludeMissing fun _isActive(): JsonField = isActive - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [lastName]. + * + * Unlike [lastName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName /** - * Returns an immutable instance of [EmploymentData]. + * Returns the raw JSON value of [latestRehireDate]. * - * Further updates to this [Builder] will not mutate the returned instance. + * Unlike [latestRehireDate], this method doesn't throw if the JSON field has an unexpected + * type. */ - fun build(): EmploymentData = - EmploymentData( - id, - classCode, - (customFields ?: JsonMissing.of()).map { it.toImmutable() }, - department, - employment, - employmentStatus, - endDate, - firstName, - income, - (incomeHistory ?: JsonMissing.of()).map { it.toImmutable() }, - isActive, - lastName, - latestRehireDate, - location, - manager, - middleName, - sourceId, - startDate, - title, - workId, - additionalProperties.toMutableMap(), - ) - } + @JsonProperty("latest_rehire_date") + @ExcludeMissing + fun _latestRehireDate(): JsonField = latestRehireDate - private var validated: Boolean = false + /** + * Returns the raw JSON value of [location]. + * + * Unlike [location], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location - fun validate(): EmploymentData = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [manager]. + * + * Unlike [manager], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("manager") @ExcludeMissing fun _manager(): JsonField = manager - id() - classCode() - customFields().ifPresent { it.forEach { it.validate() } } - department().ifPresent { it.validate() } - employment().ifPresent { it.validate() } - employmentStatus().ifPresent { it.validate() } - endDate() - firstName() - income().ifPresent { it.validate() } - incomeHistory().ifPresent { it.forEach { it?.validate() } } - isActive() - lastName() - latestRehireDate() - location().ifPresent { it.validate() } - manager().ifPresent { it.validate() } - middleName() - sourceId() - startDate() - title() - workId() - validated = true - } + /** + * Returns the raw JSON value of [middleName]. + * + * Unlike [middleName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("middle_name") + @ExcludeMissing + fun _middleName(): JsonField = middleName - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [sourceId]. + * + * Unlike [sourceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source_id") @ExcludeMissing fun _sourceId(): JsonField = sourceId - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (classCode.asKnown().isPresent) 1 else 0) + - (customFields.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (department.asKnown().getOrNull()?.validity() ?: 0) + - (employment.asKnown().getOrNull()?.validity() ?: 0) + - (employmentStatus.asKnown().getOrNull()?.validity() ?: 0) + - (if (endDate.asKnown().isPresent) 1 else 0) + - (if (firstName.asKnown().isPresent) 1 else 0) + - (income.asKnown().getOrNull()?.validity() ?: 0) + - (incomeHistory.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (if (isActive.asKnown().isPresent) 1 else 0) + - (if (lastName.asKnown().isPresent) 1 else 0) + - (if (latestRehireDate.asKnown().isPresent) 1 else 0) + - (location.asKnown().getOrNull()?.validity() ?: 0) + - (manager.asKnown().getOrNull()?.validity() ?: 0) + - (if (middleName.asKnown().isPresent) 1 else 0) + - (if (sourceId.asKnown().isPresent) 1 else 0) + - (if (startDate.asKnown().isPresent) 1 else 0) + - (if (title.asKnown().isPresent) 1 else 0) + - (if (workId.asKnown().isPresent) 1 else 0) - - class CustomField - private constructor( - private val name: JsonField, - private val value: JsonValue, - private val additionalProperties: MutableMap, - ) { + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") @ExcludeMissing fun _startDate(): JsonField = startDate - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonValue = JsonMissing.of(), - ) : this(name, value, mutableMapOf()) + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Returns the raw JSON value of [workId]. + * + * Unlike [workId], this method doesn't throw if the JSON field has an unexpected type. */ - fun name(): Optional = name.getOptional("name") + @Deprecated("deprecated") + @JsonProperty("work_id") + @ExcludeMissing + fun _workId(): JsonField = workId - @JsonProperty("value") @ExcludeMissing fun _value(): JsonValue = value + /** + * Returns the raw JSON value of [income]. + * + * Unlike [income], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("income") @ExcludeMissing fun _income(): JsonField = income /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [incomeHistory]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [incomeHistory], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("income_history") + @ExcludeMissing + fun _incomeHistory(): JsonField> = incomeHistory @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -987,180 +635,444 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [CustomField]. */ + /** + * Returns a mutable builder for constructing an instance of [UnionMember0]. + * + * The following fields are required: + * ```java + * .id() + * .classCode() + * .customFields() + * .department() + * .employment() + * .employmentStatus() + * .endDate() + * .firstName() + * .isActive() + * .lastName() + * .latestRehireDate() + * .location() + * .manager() + * .middleName() + * .sourceId() + * .startDate() + * .title() + * .workId() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [CustomField]. */ + /** A builder for [UnionMember0]. */ class Builder internal constructor() { - private var name: JsonField = JsonMissing.of() - private var value: JsonValue = JsonMissing.of() + private var id: JsonField? = null + private var classCode: JsonField? = null + private var customFields: JsonField>? = null + private var department: JsonField? = null + private var employment: JsonField? = null + private var employmentStatus: JsonField? = null + private var endDate: JsonField? = null + private var firstName: JsonField? = null + private var isActive: JsonField? = null + private var lastName: JsonField? = null + private var latestRehireDate: JsonField? = null + private var location: JsonField? = null + private var manager: JsonField? = null + private var middleName: JsonField? = null + private var sourceId: JsonField? = null + private var startDate: JsonField? = null + private var title: JsonField? = null + private var workId: JsonField? = null + private var income: JsonField = JsonMissing.of() + private var incomeHistory: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(customField: CustomField) = apply { - name = customField.name - value = customField.value - additionalProperties = customField.additionalProperties.toMutableMap() + internal fun from(unionMember0: UnionMember0) = apply { + id = unionMember0.id + classCode = unionMember0.classCode + customFields = unionMember0.customFields.map { it.toMutableList() } + department = unionMember0.department + employment = unionMember0.employment + employmentStatus = unionMember0.employmentStatus + endDate = unionMember0.endDate + firstName = unionMember0.firstName + isActive = unionMember0.isActive + lastName = unionMember0.lastName + latestRehireDate = unionMember0.latestRehireDate + location = unionMember0.location + manager = unionMember0.manager + middleName = unionMember0.middleName + sourceId = unionMember0.sourceId + startDate = unionMember0.startDate + title = unionMember0.title + workId = unionMember0.workId + income = unionMember0.income + incomeHistory = unionMember0.incomeHistory.map { it.toMutableList() } + additionalProperties = unionMember0.additionalProperties.toMutableMap() } - fun name(name: String) = name(JsonField.of(name)) + /** A stable Finch `id` (UUID v4) for an individual in the company. */ + fun id(id: String) = id(JsonField.of(id)) /** - * Sets [Builder.name] to an arbitrary JSON value. + * Sets [Builder.id] to an arbitrary JSON value. * - * You should usually call [Builder.name] with a well-typed [String] value instead. This + * You should usually call [Builder.id] with a well-typed [String] value instead. This * method is primarily for setting the field to an undocumented or not yet supported * value. */ - fun name(name: JsonField) = apply { this.name = name } + fun id(id: JsonField) = apply { this.id = id } - fun value(value: JsonValue) = apply { this.value = value } + /** Worker's compensation classification code for this employee */ + fun classCode(classCode: String?) = classCode(JsonField.ofNullable(classCode)) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** Alias for calling [Builder.classCode] with `classCode.orElse(null)`. */ + fun classCode(classCode: Optional) = classCode(classCode.getOrNull()) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.classCode] to an arbitrary JSON value. + * + * You should usually call [Builder.classCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun classCode(classCode: JsonField) = apply { this.classCode = classCode } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * Custom fields for the individual. These are fields which are defined by the employer + * in the system. + */ + fun customFields(customFields: List?) = + customFields(JsonField.ofNullable(customFields)) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + /** Alias for calling [Builder.customFields] with `customFields.orElse(null)`. */ + fun customFields(customFields: Optional>) = + customFields(customFields.getOrNull()) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Sets [Builder.customFields] to an arbitrary JSON value. + * + * You should usually call [Builder.customFields] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun customFields(customFields: JsonField>) = apply { + this.customFields = customFields.map { it.toMutableList() } } /** - * Returns an immutable instance of [CustomField]. + * Adds a single [CustomField] to [customFields]. * - * Further updates to this [Builder] will not mutate the returned instance. + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun build(): CustomField = CustomField(name, value, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): CustomField = apply { - if (validated) { - return@apply + fun addCustomField(customField: CustomField) = apply { + customFields = + (customFields ?: JsonField.of(mutableListOf())).also { + checkKnown("customFields", it).add(customField) + } } - name() - validated = true - } + /** The department object. */ + fun department(department: Department?) = department(JsonField.ofNullable(department)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false + /** Alias for calling [Builder.department] with `department.orElse(null)`. */ + fun department(department: Optional) = department(department.getOrNull()) + + /** + * Sets [Builder.department] to an arbitrary JSON value. + * + * You should usually call [Builder.department] with a well-typed [Department] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun department(department: JsonField) = apply { + this.department = department } - /** - * 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 (name.asKnown().isPresent) 1 else 0) + /** The employment object. */ + fun employment(employment: Employment?) = employment(JsonField.ofNullable(employment)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** Alias for calling [Builder.employment] with `employment.orElse(null)`. */ + fun employment(employment: Optional) = employment(employment.getOrNull()) + + /** + * Sets [Builder.employment] to an arbitrary JSON value. + * + * You should usually call [Builder.employment] with a well-typed [Employment] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun employment(employment: JsonField) = apply { + this.employment = employment } - return /* spotless:off */ other is CustomField && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** + * The detailed employment status of the individual. Available options: `active`, + * `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. + */ + fun employmentStatus(employmentStatus: EmploymentStatus?) = + employmentStatus(JsonField.ofNullable(employmentStatus)) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, value, additionalProperties) } - /* spotless:on */ + /** + * Alias for calling [Builder.employmentStatus] with `employmentStatus.orElse(null)`. + */ + fun employmentStatus(employmentStatus: Optional) = + employmentStatus(employmentStatus.getOrNull()) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.employmentStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.employmentStatus] with a well-typed + * [EmploymentStatus] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun employmentStatus(employmentStatus: JsonField) = apply { + this.employmentStatus = employmentStatus + } - override fun toString() = - "CustomField{name=$name, value=$value, additionalProperties=$additionalProperties}" - } + fun endDate(endDate: String?) = endDate(JsonField.ofNullable(endDate)) - /** The department object. */ - class Department - private constructor( - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { + /** Alias for calling [Builder.endDate] with `endDate.orElse(null)`. */ + fun endDate(endDate: Optional) = endDate(endDate.getOrNull()) - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() - ) : this(name, mutableMapOf()) + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - /** - * The name of the department associated with the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") + /** The legal first name of the individual. */ + fun firstName(firstName: String?) = firstName(JsonField.ofNullable(firstName)) - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** Alias for calling [Builder.firstName] with `firstName.orElse(null)`. */ + fun firstName(firstName: Optional) = firstName(firstName.getOrNull()) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.firstName] to an arbitrary JSON value. + * + * You should usually call [Builder.firstName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstName(firstName: JsonField) = apply { this.firstName = firstName } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** `true` if the individual an an active employee or contractor at the company. */ + fun isActive(isActive: Boolean?) = isActive(JsonField.ofNullable(isActive)) - fun toBuilder() = Builder().from(this) + /** + * Alias for [Builder.isActive]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun isActive(isActive: Boolean) = isActive(isActive as Boolean?) - companion object { + /** Alias for calling [Builder.isActive] with `isActive.orElse(null)`. */ + fun isActive(isActive: Optional) = isActive(isActive.getOrNull()) - /** Returns a mutable builder for constructing an instance of [Department]. */ - @JvmStatic fun builder() = Builder() - } + /** + * Sets [Builder.isActive] to an arbitrary JSON value. + * + * You should usually call [Builder.isActive] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - /** A builder for [Department]. */ - class Builder internal constructor() { + /** The legal last name of the individual. */ + fun lastName(lastName: String?) = lastName(JsonField.ofNullable(lastName)) - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** Alias for calling [Builder.lastName] with `lastName.orElse(null)`. */ + fun lastName(lastName: Optional) = lastName(lastName.getOrNull()) - @JvmSynthetic - internal fun from(department: Department) = apply { - name = department.name - additionalProperties = department.additionalProperties.toMutableMap() + /** + * Sets [Builder.lastName] to an arbitrary JSON value. + * + * You should usually call [Builder.lastName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastName(lastName: JsonField) = apply { this.lastName = lastName } + + fun latestRehireDate(latestRehireDate: String?) = + latestRehireDate(JsonField.ofNullable(latestRehireDate)) + + /** + * Alias for calling [Builder.latestRehireDate] with `latestRehireDate.orElse(null)`. + */ + fun latestRehireDate(latestRehireDate: Optional) = + latestRehireDate(latestRehireDate.getOrNull()) + + /** + * Sets [Builder.latestRehireDate] to an arbitrary JSON value. + * + * You should usually call [Builder.latestRehireDate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun latestRehireDate(latestRehireDate: JsonField) = apply { + this.latestRehireDate = latestRehireDate } - /** The name of the department associated with the individual. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) + fun location(location: Location?) = location(JsonField.ofNullable(location)) - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) + /** Alias for calling [Builder.location] with `location.orElse(null)`. */ + fun location(location: Optional) = location(location.getOrNull()) /** - * Sets [Builder.name] to an arbitrary JSON value. + * Sets [Builder.location] to an arbitrary JSON value. * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.location] with a well-typed [Location] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun name(name: JsonField) = apply { this.name = name } + fun location(location: JsonField) = apply { this.location = location } + + /** The manager object representing the manager of the individual within the org. */ + fun manager(manager: Manager?) = manager(JsonField.ofNullable(manager)) + + /** Alias for calling [Builder.manager] with `manager.orElse(null)`. */ + fun manager(manager: Optional) = manager(manager.getOrNull()) + + /** + * Sets [Builder.manager] to an arbitrary JSON value. + * + * You should usually call [Builder.manager] with a well-typed [Manager] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun manager(manager: JsonField) = apply { this.manager = manager } + + /** The legal middle name of the individual. */ + fun middleName(middleName: String?) = middleName(JsonField.ofNullable(middleName)) + + /** Alias for calling [Builder.middleName] with `middleName.orElse(null)`. */ + fun middleName(middleName: Optional) = middleName(middleName.getOrNull()) + + /** + * Sets [Builder.middleName] to an arbitrary JSON value. + * + * You should usually call [Builder.middleName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun middleName(middleName: JsonField) = apply { this.middleName = middleName } + + /** The source system's unique employment identifier for this individual */ + fun sourceId(sourceId: String?) = sourceId(JsonField.ofNullable(sourceId)) + + /** Alias for calling [Builder.sourceId] with `sourceId.orElse(null)`. */ + fun sourceId(sourceId: Optional) = sourceId(sourceId.getOrNull()) + + /** + * Sets [Builder.sourceId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceId(sourceId: JsonField) = apply { this.sourceId = sourceId } + + fun startDate(startDate: String?) = startDate(JsonField.ofNullable(startDate)) + + /** Alias for calling [Builder.startDate] with `startDate.orElse(null)`. */ + fun startDate(startDate: Optional) = startDate(startDate.getOrNull()) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + /** The current title of the individual. */ + fun title(title: String?) = title(JsonField.ofNullable(title)) + + /** Alias for calling [Builder.title] with `title.orElse(null)`. */ + fun title(title: Optional) = title(title.getOrNull()) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + /** This field is deprecated in favour of `source_id` */ + @Deprecated("deprecated") + fun workId(workId: String?) = workId(JsonField.ofNullable(workId)) + + /** Alias for calling [Builder.workId] with `workId.orElse(null)`. */ + @Deprecated("deprecated") + fun workId(workId: Optional) = workId(workId.getOrNull()) + + /** + * Sets [Builder.workId] to an arbitrary JSON value. + * + * You should usually call [Builder.workId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun workId(workId: JsonField) = apply { this.workId = workId } + + /** + * The employee's income as reported by the provider. This may not always be annualized + * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what + * information the provider returns. + */ + fun income(income: Income?) = income(JsonField.ofNullable(income)) + + /** Alias for calling [Builder.income] with `income.orElse(null)`. */ + fun income(income: Optional) = income(income.getOrNull()) + + /** + * Sets [Builder.income] to an arbitrary JSON value. + * + * You should usually call [Builder.income] with a well-typed [Income] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun income(income: JsonField) = apply { this.income = income } + + /** The array of income history. */ + fun incomeHistory(incomeHistory: List?) = + incomeHistory(JsonField.ofNullable(incomeHistory)) + + /** Alias for calling [Builder.incomeHistory] with `incomeHistory.orElse(null)`. */ + fun incomeHistory(incomeHistory: Optional>) = + incomeHistory(incomeHistory.getOrNull()) + + /** + * Sets [Builder.incomeHistory] to an arbitrary JSON value. + * + * You should usually call [Builder.incomeHistory] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun incomeHistory(incomeHistory: JsonField>) = apply { + this.incomeHistory = incomeHistory.map { it.toMutableList() } + } + + /** + * Adds a single [Income] to [Builder.incomeHistory]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIncomeHistory(incomeHistory: Income) = apply { + this.incomeHistory = + (this.incomeHistory ?: JsonField.of(mutableListOf())).also { + checkKnown("incomeHistory", it).add(incomeHistory) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1182,21 +1094,87 @@ private constructor( } /** - * Returns an immutable instance of [Department]. + * Returns an immutable instance of [UnionMember0]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .classCode() + * .customFields() + * .department() + * .employment() + * .employmentStatus() + * .endDate() + * .firstName() + * .isActive() + * .lastName() + * .latestRehireDate() + * .location() + * .manager() + * .middleName() + * .sourceId() + * .startDate() + * .title() + * .workId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Department = Department(name, additionalProperties.toMutableMap()) + fun build(): UnionMember0 = + UnionMember0( + checkRequired("id", id), + checkRequired("classCode", classCode), + checkRequired("customFields", customFields).map { it.toImmutable() }, + checkRequired("department", department), + checkRequired("employment", employment), + checkRequired("employmentStatus", employmentStatus), + checkRequired("endDate", endDate), + checkRequired("firstName", firstName), + checkRequired("isActive", isActive), + checkRequired("lastName", lastName), + checkRequired("latestRehireDate", latestRehireDate), + checkRequired("location", location), + checkRequired("manager", manager), + checkRequired("middleName", middleName), + checkRequired("sourceId", sourceId), + checkRequired("startDate", startDate), + checkRequired("title", title), + checkRequired("workId", workId), + income, + (incomeHistory ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Department = apply { + fun validate(): UnionMember0 = apply { if (validated) { return@apply } - name() + id() + classCode() + customFields().ifPresent { it.forEach { it.validate() } } + department().ifPresent { it.validate() } + employment().ifPresent { it.validate() } + employmentStatus().ifPresent { it.validate() } + endDate() + firstName() + isActive() + lastName() + latestRehireDate() + location().ifPresent { it.validate() } + manager().ifPresent { it.validate() } + middleName() + sourceId() + startDate() + title() + workId() + income().ifPresent { it.validate() } + incomeHistory().ifPresent { it.forEach { it?.validate() } } validated = true } @@ -1214,200 +1192,1127 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (classCode.asKnown().isPresent) 1 else 0) + + (customFields.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (department.asKnown().getOrNull()?.validity() ?: 0) + + (employment.asKnown().getOrNull()?.validity() ?: 0) + + (employmentStatus.asKnown().getOrNull()?.validity() ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (firstName.asKnown().isPresent) 1 else 0) + + (if (isActive.asKnown().isPresent) 1 else 0) + + (if (lastName.asKnown().isPresent) 1 else 0) + + (if (latestRehireDate.asKnown().isPresent) 1 else 0) + + (location.asKnown().getOrNull()?.validity() ?: 0) + + (manager.asKnown().getOrNull()?.validity() ?: 0) + + (if (middleName.asKnown().isPresent) 1 else 0) + + (if (sourceId.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + (if (title.asKnown().isPresent) 1 else 0) + + (if (workId.asKnown().isPresent) 1 else 0) + + (income.asKnown().getOrNull()?.validity() ?: 0) + + (incomeHistory.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + + class CustomField + private constructor( + private val name: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(name, value, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - return /* spotless:off */ other is Department && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } - /* spotless:on */ + fun toBuilder() = Builder().from(this) - override fun hashCode(): Int = hashCode + companion object { - override fun toString() = - "Department{name=$name, additionalProperties=$additionalProperties}" - } + /** Returns a mutable builder for constructing an instance of [CustomField]. */ + @JvmStatic fun builder() = Builder() + } - /** The employment object. */ - class Employment - private constructor( - private val subtype: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { + /** A builder for [CustomField]. */ + class Builder internal constructor() { - @JsonCreator - private constructor( - @JsonProperty("subtype") @ExcludeMissing subtype: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(subtype, type, mutableMapOf()) + private var name: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * The secondary employment type of the individual. Options: `full_time`, `part_time`, - * `intern`, `temp`, `seasonal` and `individual_contractor`. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun subtype(): Optional = subtype.getOptional("subtype") + @JvmSynthetic + internal fun from(customField: CustomField) = apply { + name = customField.name + value = customField.value + additionalProperties = customField.additionalProperties.toMutableMap() + } - /** - * The main employment type of the individual. - * - * @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") + fun name(name: String) = name(JsonField.of(name)) - /** - * Returns the raw JSON value of [subtype]. - * - * Unlike [subtype], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * 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 + fun value(value: Value?) = value(JsonField.ofNullable(value)) - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional) = value(value.getOrNull()) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } - fun toBuilder() = Builder().from(this) + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) - companion object { + /** Alias for calling [value] with `Value.ofJsonValues(jsonValues)`. */ + fun valueOfJsonValues(jsonValues: List) = + value(Value.ofJsonValues(jsonValues)) - /** Returns a mutable builder for constructing an instance of [Employment]. */ - @JvmStatic fun builder() = Builder() - } + /** Alias for calling [value] with `Value.ofJson(json)`. */ + fun value(json: JsonValue) = value(Value.ofJson(json)) - /** A builder for [Employment]. */ - class Builder internal constructor() { + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) - private var subtype: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) - @JvmSynthetic - internal fun from(employment: Employment) = apply { - subtype = employment.subtype - type = employment.type - additionalProperties = employment.additionalProperties.toMutableMap() + 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 [CustomField]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomField = + CustomField(name, value, additionalProperties.toMutableMap()) } - /** - * The secondary employment type of the individual. Options: `full_time`, `part_time`, - * `intern`, `temp`, `seasonal` and `individual_contractor`. - */ - fun subtype(subtype: Subtype?) = subtype(JsonField.ofNullable(subtype)) + private var validated: Boolean = false + + fun validate(): CustomField = apply { + if (validated) { + return@apply + } + + name() + value().ifPresent { it.validate() } + validated = true + } - /** Alias for calling [Builder.subtype] with `subtype.orElse(null)`. */ - fun subtype(subtype: Optional) = subtype(subtype.getOrNull()) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } /** - * Sets [Builder.subtype] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.subtype] with a well-typed [Subtype] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun subtype(subtype: JsonField) = apply { this.subtype = subtype } + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) - /** The main employment type of the individual. */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val jsonValues: List? = null, + private val json: JsonValue? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) + fun string(): Optional = Optional.ofNullable(string) - /** - * 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 jsonValues(): Optional> = Optional.ofNullable(jsonValues) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun json(): Optional = Optional.ofNullable(json) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun number(): Optional = Optional.ofNullable(number) - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun bool(): Optional = Optional.ofNullable(bool) - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun isString(): Boolean = string != null + + fun isJsonValues(): Boolean = jsonValues != null + + fun isJson(): Boolean = json != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValues(): List = jsonValues.getOrThrow("jsonValues") + + fun asJson(): JsonValue = json.getOrThrow("json") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + jsonValues != null -> visitor.visitJsonValues(jsonValues) + json != null -> visitor.visitJson(json) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitJsonValues(jsonValues: List) {} + + override fun visitJson(json: JsonValue) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + } + ) + 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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitJsonValues(jsonValues: List) = + jsonValues.size + + override fun visitJson(json: JsonValue) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Value && string == other.string && jsonValues == other.jsonValues && json == other.json && number == other.number && bool == other.bool /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, jsonValues, json, number, bool) /* spotless:on */ + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + jsonValues != null -> "Value{jsonValues=$jsonValues}" + json != null -> "Value{json=$json}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic + fun ofJsonValues(jsonValues: List) = Value(jsonValues = jsonValues) + + @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + } + + /** + * An interface that defines how to map each variant of [Value] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitJsonValues(jsonValues: List): T + + fun visitJson(json: JsonValue): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws FinchInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw FinchInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Value(jsonValues = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(json = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValues != null -> generator.writeObject(value.jsonValues) + value.json != null -> generator.writeObject(value.json) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CustomField && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, value, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomField{name=$name, value=$value, additionalProperties=$additionalProperties}" + } + + /** The department object. */ + class Department + private constructor( + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() + ) : this(name, mutableMapOf()) + + /** + * The name of the department associated with the individual. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Department]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Department]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(department: Department) = apply { + name = department.name + additionalProperties = department.additionalProperties.toMutableMap() + } + + /** The name of the department associated with the individual. */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Department]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Department = + Department(checkRequired("name", name), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Department = apply { + if (validated) { + return@apply + } + + name() + 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 (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Department && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Department{name=$name, additionalProperties=$additionalProperties}" + } + + /** The employment object. */ + class Employment + private constructor( + private val subtype: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("subtype") + @ExcludeMissing + subtype: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(subtype, type, mutableMapOf()) + + /** + * The secondary employment type of the individual. Options: `full_time`, `part_time`, + * `intern`, `temp`, `seasonal` and `individual_contractor`. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subtype(): Optional = subtype.getOptional("subtype") + + /** + * The main employment type of the individual. + * + * @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 [subtype]. + * + * Unlike [subtype], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype + + /** + * 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 [Employment]. + * + * The following fields are required: + * ```java + * .subtype() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Employment]. */ + class Builder internal constructor() { + + private var subtype: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(employment: Employment) = apply { + subtype = employment.subtype + type = employment.type + additionalProperties = employment.additionalProperties.toMutableMap() + } + + /** + * The secondary employment type of the individual. Options: `full_time`, + * `part_time`, `intern`, `temp`, `seasonal` and `individual_contractor`. + */ + fun subtype(subtype: Subtype?) = subtype(JsonField.ofNullable(subtype)) + + /** Alias for calling [Builder.subtype] with `subtype.orElse(null)`. */ + fun subtype(subtype: Optional) = subtype(subtype.getOrNull()) + + /** + * Sets [Builder.subtype] to an arbitrary JSON value. + * + * You should usually call [Builder.subtype] with a well-typed [Subtype] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subtype(subtype: JsonField) = apply { this.subtype = subtype } + + /** The main employment type of the individual. */ + fun type(type: Type?) = 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 [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 [Employment]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .subtype() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Employment = + Employment( + checkRequired("subtype", subtype), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Employment = apply { + if (validated) { + return@apply + } + + subtype().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 = + (subtype.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The secondary employment type of the individual. Options: `full_time`, `part_time`, + * `intern`, `temp`, `seasonal` and `individual_contractor`. + */ + class Subtype @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 FULL_TIME = of("full_time") + + @JvmField val INTERN = of("intern") + + @JvmField val PART_TIME = of("part_time") + + @JvmField val TEMP = of("temp") + + @JvmField val SEASONAL = of("seasonal") + + @JvmField val INDIVIDUAL_CONTRACTOR = of("individual_contractor") + + @JvmStatic fun of(value: String) = Subtype(JsonField.of(value)) + } + + /** An enum containing [Subtype]'s known values. */ + enum class Known { + FULL_TIME, + INTERN, + PART_TIME, + TEMP, + SEASONAL, + INDIVIDUAL_CONTRACTOR, + } + + /** + * An enum containing [Subtype]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Subtype] 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 { + FULL_TIME, + INTERN, + PART_TIME, + TEMP, + SEASONAL, + INDIVIDUAL_CONTRACTOR, + /** + * An enum member indicating that [Subtype] 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) { + FULL_TIME -> Value.FULL_TIME + INTERN -> Value.INTERN + PART_TIME -> Value.PART_TIME + TEMP -> Value.TEMP + SEASONAL -> Value.SEASONAL + INDIVIDUAL_CONTRACTOR -> Value.INDIVIDUAL_CONTRACTOR + 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) { + FULL_TIME -> Known.FULL_TIME + INTERN -> Known.INTERN + PART_TIME -> Known.PART_TIME + TEMP -> Known.TEMP + SEASONAL -> Known.SEASONAL + INDIVIDUAL_CONTRACTOR -> Known.INDIVIDUAL_CONTRACTOR + else -> throw FinchInvalidDataException("Unknown Subtype: $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 + + fun validate(): Subtype = 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 /* spotless:off */ other is Subtype && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The main employment type of the individual. */ + 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 EMPLOYEE = of("employee") + + @JvmField val CONTRACTOR = of("contractor") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + EMPLOYEE, + CONTRACTOR, + } + + /** + * 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 { + EMPLOYEE, + CONTRACTOR, + /** + * 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) { + EMPLOYEE -> Value.EMPLOYEE + CONTRACTOR -> Value.CONTRACTOR + 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) { + EMPLOYEE -> Known.EMPLOYEE + CONTRACTOR -> Known.CONTRACTOR + 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 + + 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 - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns an immutable instance of [Employment]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Employment = Employment(subtype, type, additionalProperties.toMutableMap()) - } + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } - private var validated: Boolean = false + override fun hashCode() = value.hashCode() - fun validate(): Employment = apply { - if (validated) { - return@apply + override fun toString() = value.toString() } - subtype().ifPresent { it.validate() } - type().ifPresent { it.validate() } - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false + return /* spotless:off */ other is Employment && subtype == other.subtype && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } - /** - * 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 = - (subtype.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(subtype, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Employment{subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" + } /** - * The secondary employment type of the individual. Options: `full_time`, `part_time`, - * `intern`, `temp`, `seasonal` and `individual_contractor`. + * The detailed employment status of the individual. Available options: `active`, + * `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. */ - class Subtype @JsonCreator private constructor(private val value: JsonField) : - Enum { + class EmploymentStatus + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -1421,49 +2326,55 @@ private constructor( companion object { - @JvmField val FULL_TIME = of("full_time") + @JvmField val ACTIVE = of("active") - @JvmField val INTERN = of("intern") + @JvmField val DECEASED = of("deceased") - @JvmField val PART_TIME = of("part_time") + @JvmField val LEAVE = of("leave") - @JvmField val TEMP = of("temp") + @JvmField val ONBOARDING = of("onboarding") - @JvmField val SEASONAL = of("seasonal") + @JvmField val PREHIRE = of("prehire") - @JvmField val INDIVIDUAL_CONTRACTOR = of("individual_contractor") + @JvmField val RETIRED = of("retired") - @JvmStatic fun of(value: String) = Subtype(JsonField.of(value)) + @JvmField val TERMINATED = of("terminated") + + @JvmStatic fun of(value: String) = EmploymentStatus(JsonField.of(value)) } - /** An enum containing [Subtype]'s known values. */ + /** An enum containing [EmploymentStatus]'s known values. */ enum class Known { - FULL_TIME, - INTERN, - PART_TIME, - TEMP, - SEASONAL, - INDIVIDUAL_CONTRACTOR, + ACTIVE, + DECEASED, + LEAVE, + ONBOARDING, + PREHIRE, + RETIRED, + TERMINATED, } /** - * An enum containing [Subtype]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [EmploymentStatus]'s known values, as well as an [_UNKNOWN] + * member. * - * An instance of [Subtype] can contain an unknown value in a couple of cases: + * An instance of [EmploymentStatus] 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 { - FULL_TIME, - INTERN, - PART_TIME, - TEMP, - SEASONAL, - INDIVIDUAL_CONTRACTOR, + ACTIVE, + DECEASED, + LEAVE, + ONBOARDING, + PREHIRE, + RETIRED, + TERMINATED, /** - * An enum member indicating that [Subtype] was instantiated with an unknown value. + * An enum member indicating that [EmploymentStatus] was instantiated with an + * unknown value. */ _UNKNOWN, } @@ -1477,12 +2388,13 @@ private constructor( */ fun value(): Value = when (this) { - FULL_TIME -> Value.FULL_TIME - INTERN -> Value.INTERN - PART_TIME -> Value.PART_TIME - TEMP -> Value.TEMP - SEASONAL -> Value.SEASONAL - INDIVIDUAL_CONTRACTOR -> Value.INDIVIDUAL_CONTRACTOR + ACTIVE -> Value.ACTIVE + DECEASED -> Value.DECEASED + LEAVE -> Value.LEAVE + ONBOARDING -> Value.ONBOARDING + PREHIRE -> Value.PREHIRE + RETIRED -> Value.RETIRED + TERMINATED -> Value.TERMINATED else -> Value._UNKNOWN } @@ -1497,13 +2409,14 @@ private constructor( */ fun known(): Known = when (this) { - FULL_TIME -> Known.FULL_TIME - INTERN -> Known.INTERN - PART_TIME -> Known.PART_TIME - TEMP -> Known.TEMP - SEASONAL -> Known.SEASONAL - INDIVIDUAL_CONTRACTOR -> Known.INDIVIDUAL_CONTRACTOR - else -> throw FinchInvalidDataException("Unknown Subtype: $value") + ACTIVE -> Known.ACTIVE + DECEASED -> Known.DECEASED + LEAVE -> Known.LEAVE + ONBOARDING -> Known.ONBOARDING + PREHIRE -> Known.PREHIRE + RETIRED -> Known.RETIRED + TERMINATED -> Known.TERMINATED + else -> throw FinchInvalidDataException("Unknown EmploymentStatus: $value") } /** @@ -1522,7 +2435,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Subtype = apply { + fun validate(): EmploymentStatus = apply { if (validated) { return@apply } @@ -1552,7 +2465,7 @@ private constructor( return true } - return /* spotless:off */ other is Subtype && value == other.value /* spotless:on */ + return /* spotless:off */ other is EmploymentStatus && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -1560,102 +2473,129 @@ private constructor( override fun toString() = value.toString() } - /** The main employment type of the individual. */ - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + /** The manager object representing the manager of the individual within the org. */ + class Manager + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) /** - * Returns this class instance's raw value. + * A stable Finch `id` (UUID v4) for an individual in the company. * - * 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. + * @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). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun id(): String = id.getRequired("id") - companion object { + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JvmField val EMPLOYEE = of("employee") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val CONTRACTOR = of("contractor") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + fun toBuilder() = Builder().from(this) - /** An enum containing [Type]'s known values. */ - enum class Known { - EMPLOYEE, - CONTRACTOR, - } + companion object { - /** - * 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 { - EMPLOYEE, - CONTRACTOR, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, + /** + * Returns a mutable builder for constructing an instance of [Manager]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() } - /** - * 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) { - EMPLOYEE -> Value.EMPLOYEE - CONTRACTOR -> Value.CONTRACTOR - else -> Value._UNKNOWN + /** A builder for [Manager]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(manager: Manager) = apply { + id = manager.id + additionalProperties = manager.additionalProperties.toMutableMap() } - /** - * 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) { - EMPLOYEE -> Known.EMPLOYEE - CONTRACTOR -> Known.CONTRACTOR - else -> throw FinchInvalidDataException("Unknown Type: $value") + /** A stable Finch `id` (UUID v4) for an individual in the company. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * 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") + 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 [Manager]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Manager = + Manager(checkRequired("id", id), additionalProperties.toMutableMap()) + } + private var validated: Boolean = false - fun validate(): Type = apply { + fun validate(): Manager = apply { if (validated) { return@apply } - known() + id() validated = true } @@ -1673,19 +2613,23 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + return /* spotless:off */ other is Manager && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode() = value.hashCode() + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + /* spotless:on */ - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = "Manager{id=$id, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1693,207 +2637,89 @@ private constructor( return true } - return /* spotless:off */ other is Employment && subtype == other.subtype && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnionMember0 && id == other.id && classCode == other.classCode && customFields == other.customFields && department == other.department && employment == other.employment && employmentStatus == other.employmentStatus && endDate == other.endDate && firstName == other.firstName && isActive == other.isActive && lastName == other.lastName && latestRehireDate == other.latestRehireDate && location == other.location && manager == other.manager && middleName == other.middleName && sourceId == other.sourceId && startDate == other.startDate && title == other.title && workId == other.workId && income == other.income && incomeHistory == other.incomeHistory && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(subtype, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, classCode, customFields, department, employment, employmentStatus, endDate, firstName, isActive, lastName, latestRehireDate, location, manager, middleName, sourceId, startDate, title, workId, income, incomeHistory, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Employment{subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" + "UnionMember0{id=$id, classCode=$classCode, customFields=$customFields, department=$department, employment=$employment, employmentStatus=$employmentStatus, endDate=$endDate, firstName=$firstName, isActive=$isActive, lastName=$lastName, latestRehireDate=$latestRehireDate, location=$location, manager=$manager, middleName=$middleName, sourceId=$sourceId, startDate=$startDate, title=$title, workId=$workId, income=$income, incomeHistory=$incomeHistory, additionalProperties=$additionalProperties}" } - /** - * The detailed employment status of the individual. Available options: `active`, `deceased`, - * `leave`, `onboarding`, `prehire`, `retired`, `terminated`. - */ - class EmploymentStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { + class BatchError + private constructor( + private val code: JsonField, + private val message: JsonField, + private val name: JsonField, + private val finchCode: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("finch_code") + @ExcludeMissing + finchCode: JsonField = JsonMissing.of(), + ) : this(code, message, name, finchCode, mutableMapOf()) /** - * 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. + * @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). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACTIVE = of("active") - - @JvmField val DECEASED = of("deceased") - - @JvmField val LEAVE = of("leave") - - @JvmField val ONBOARDING = of("onboarding") - - @JvmField val PREHIRE = of("prehire") - - @JvmField val RETIRED = of("retired") - - @JvmField val TERMINATED = of("terminated") - - @JvmStatic fun of(value: String) = EmploymentStatus(JsonField.of(value)) - } - - /** An enum containing [EmploymentStatus]'s known values. */ - enum class Known { - ACTIVE, - DECEASED, - LEAVE, - ONBOARDING, - PREHIRE, - RETIRED, - TERMINATED, - } + fun code(): Double = code.getRequired("code") /** - * An enum containing [EmploymentStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EmploymentStatus] 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. + * @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). */ - enum class Value { - ACTIVE, - DECEASED, - LEAVE, - ONBOARDING, - PREHIRE, - RETIRED, - TERMINATED, - /** - * An enum member indicating that [EmploymentStatus] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun message(): String = message.getRequired("message") /** - * 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. + * @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 value(): Value = - when (this) { - ACTIVE -> Value.ACTIVE - DECEASED -> Value.DECEASED - LEAVE -> Value.LEAVE - ONBOARDING -> Value.ONBOARDING - PREHIRE -> Value.PREHIRE - RETIRED -> Value.RETIRED - TERMINATED -> Value.TERMINATED - else -> Value._UNKNOWN - } + fun name(): String = name.getRequired("name") /** - * 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. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun known(): Known = - when (this) { - ACTIVE -> Known.ACTIVE - DECEASED -> Known.DECEASED - LEAVE -> Known.LEAVE - ONBOARDING -> Known.ONBOARDING - PREHIRE -> Known.PREHIRE - RETIRED -> Known.RETIRED - TERMINATED -> Known.TERMINATED - else -> throw FinchInvalidDataException("Unknown EmploymentStatus: $value") - } + fun finchCode(): Optional = finchCode.getOptional("finch_code") /** - * Returns this class instance's primitive wire representation. + * Returns the raw JSON value of [code]. * - * 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. + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. */ - fun asString(): String = - _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EmploymentStatus = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [message]. * - * Used for best match union deserialization. + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EmploymentStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The manager object representing the manager of the individual within the org. */ - class Manager - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message /** - * A stable Finch `id` (UUID v4) for an individual in the company. + * Returns the raw JSON value of [name]. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - fun id(): Optional = id.getOptional("id") + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [finchCode]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [finchCode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("finch_code") @ExcludeMissing fun _finchCode(): JsonField = finchCode @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1909,33 +2735,80 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Manager]. */ + /** + * Returns a mutable builder for constructing an instance of [BatchError]. + * + * The following fields are required: + * ```java + * .code() + * .message() + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Manager]. */ + /** A builder for [BatchError]. */ class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() + private var code: JsonField? = null + private var message: JsonField? = null + private var name: JsonField? = null + private var finchCode: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(manager: Manager) = apply { - id = manager.id - additionalProperties = manager.additionalProperties.toMutableMap() + internal fun from(batchError: BatchError) = apply { + code = batchError.code + message = batchError.message + name = batchError.name + finchCode = batchError.finchCode + additionalProperties = batchError.additionalProperties.toMutableMap() } - /** A stable Finch `id` (UUID v4) for an individual in the company. */ - fun id(id: String) = id(JsonField.of(id)) + fun code(code: Double) = code(JsonField.of(code)) /** - * Sets [Builder.id] to an arbitrary JSON value. + * Sets [Builder.code] to an arbitrary JSON value. * - * You should usually call [Builder.id] with a well-typed [String] value instead. This + * You should usually call [Builder.code] with a well-typed [Double] value instead. This * method is primarily for setting the field to an undocumented or not yet supported * value. */ - fun id(id: JsonField) = apply { this.id = id } + fun code(code: JsonField) = apply { this.code = code } + + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun finchCode(finchCode: String) = finchCode(JsonField.of(finchCode)) + + /** + * Sets [Builder.finchCode] to an arbitrary JSON value. + * + * You should usually call [Builder.finchCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun finchCode(finchCode: JsonField) = apply { this.finchCode = finchCode } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1957,21 +2830,40 @@ private constructor( } /** - * Returns an immutable instance of [Manager]. + * Returns an immutable instance of [BatchError]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .message() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Manager = Manager(id, additionalProperties.toMutableMap()) + fun build(): BatchError = + BatchError( + checkRequired("code", code), + checkRequired("message", message), + checkRequired("name", name), + finchCode, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): Manager = apply { + fun validate(): BatchError = apply { if (validated) { return@apply } - id() + code() + message() + name() + finchCode() validated = true } @@ -1989,39 +2881,28 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (finchCode.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Manager && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BatchError && code == other.code && message == other.message && name == other.name && finchCode == other.finchCode && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(code, message, name, finchCode, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = "Manager{id=$id, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EmploymentData && id == other.id && classCode == other.classCode && customFields == other.customFields && department == other.department && employment == other.employment && employmentStatus == other.employmentStatus && endDate == other.endDate && firstName == other.firstName && income == other.income && incomeHistory == other.incomeHistory && isActive == other.isActive && lastName == other.lastName && latestRehireDate == other.latestRehireDate && location == other.location && manager == other.manager && middleName == other.middleName && sourceId == other.sourceId && startDate == other.startDate && title == other.title && workId == other.workId && additionalProperties == other.additionalProperties /* spotless:on */ + override fun toString() = + "BatchError{code=$code, message=$message, name=$name, finchCode=$finchCode, additionalProperties=$additionalProperties}" } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, classCode, customFields, department, employment, employmentStatus, endDate, firstName, income, incomeHistory, isActive, lastName, latestRehireDate, location, manager, middleName, sourceId, startDate, title, workId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EmploymentData{id=$id, classCode=$classCode, customFields=$customFields, department=$department, employment=$employment, employmentStatus=$employmentStatus, endDate=$endDate, firstName=$firstName, income=$income, incomeHistory=$incomeHistory, isActive=$isActive, lastName=$lastName, latestRehireDate=$latestRehireDate, location=$location, manager=$manager, middleName=$middleName, sourceId=$sourceId, startDate=$startDate, title=$title, workId=$workId, additionalProperties=$additionalProperties}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentDataResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentDataResponse.kt index 4f8bcca8..5066700c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentDataResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentDataResponse.kt @@ -10,10 +10,10 @@ 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 -import java.util.Optional import kotlin.jvm.optionals.getOrNull class EmploymentDataResponse @@ -34,24 +34,24 @@ private constructor( ) : this(body, code, individualId, mutableMapOf()) /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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 body(): Optional = body.getOptional("body") + fun body(): EmploymentData = body.getRequired("body") /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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 code(): Optional = code.getOptional("code") + fun code(): Long = code.getRequired("code") /** * A stable Finch `id` (UUID v4) for an individual in the company. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @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 individualId(): Optional = individualId.getOptional("individual_id") + fun individualId(): String = individualId.getRequired("individual_id") /** * Returns the raw JSON value of [body]. @@ -90,16 +90,25 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [EmploymentDataResponse]. */ + /** + * Returns a mutable builder for constructing an instance of [EmploymentDataResponse]. + * + * The following fields are required: + * ```java + * .body() + * .code() + * .individualId() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [EmploymentDataResponse]. */ class Builder internal constructor() { - private var body: JsonField = JsonMissing.of() - private var code: JsonField = JsonMissing.of() - private var individualId: JsonField = JsonMissing.of() + private var body: JsonField? = null + private var code: JsonField? = null + private var individualId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -121,6 +130,14 @@ private constructor( */ fun body(body: JsonField) = apply { this.body = body } + /** Alias for calling [body] with `EmploymentData.ofUnionMember0(unionMember0)`. */ + fun body(unionMember0: EmploymentData.UnionMember0) = + body(EmploymentData.ofUnionMember0(unionMember0)) + + /** Alias for calling [body] with `EmploymentData.ofBatchError(batchError)`. */ + fun body(batchError: EmploymentData.BatchError) = + body(EmploymentData.ofBatchError(batchError)) + fun code(code: Long) = code(JsonField.of(code)) /** @@ -168,9 +185,23 @@ private constructor( * Returns an immutable instance of [EmploymentDataResponse]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * .code() + * .individualId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): EmploymentDataResponse = - EmploymentDataResponse(body, code, individualId, additionalProperties.toMutableMap()) + EmploymentDataResponse( + checkRequired("body", body), + checkRequired("code", code), + checkRequired("individualId", individualId), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -180,7 +211,7 @@ private constructor( return@apply } - body().ifPresent { it.validate() } + body().validate() code() individualId() validated = true diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Income.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Income.kt index 03ac872e..99e6b081 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Income.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Income.kt @@ -11,6 +11,7 @@ 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 @@ -118,17 +119,27 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Income]. */ + /** + * Returns a mutable builder for constructing an instance of [Income]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .effectiveDate() + * .unit() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Income]. */ class Builder internal constructor() { - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var effectiveDate: JsonField = JsonMissing.of() - private var unit: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var currency: JsonField? = null + private var effectiveDate: JsonField? = null + private var unit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -234,9 +245,25 @@ private constructor( * Returns an immutable instance of [Income]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .effectiveDate() + * .unit() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Income = - Income(amount, currency, effectiveDate, unit, additionalProperties.toMutableMap()) + Income( + checkRequired("amount", amount), + checkRequired("currency", currency), + checkRequired("effectiveDate", effectiveDate), + checkRequired("unit", unit), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt index 29114677..c113d875 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt @@ -3,7 +3,6 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,25 +14,52 @@ internal class EmploymentDataResponseTest { val employmentDataResponse = EmploymentDataResponse.builder() .body( - EmploymentData.builder() + EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") .addCustomField( - EmploymentData.CustomField.builder() + EmploymentData.UnionMember0.CustomField.builder() .name("name") - .value(JsonValue.from(mapOf())) + .value("string") .build() ) - .department(EmploymentData.Department.builder().name("name").build()) + .department( + EmploymentData.UnionMember0.Department.builder().name("name").build() + ) .employment( - EmploymentData.Employment.builder() - .subtype(EmploymentData.Employment.Subtype.FULL_TIME) - .type(EmploymentData.Employment.Type.EMPLOYEE) + EmploymentData.UnionMember0.Employment.builder() + .subtype(EmploymentData.UnionMember0.Employment.Subtype.FULL_TIME) + .type(EmploymentData.UnionMember0.Employment.Type.EMPLOYEE) .build() ) - .employmentStatus(EmploymentData.EmploymentStatus.ACTIVE) + .employmentStatus(EmploymentData.UnionMember0.EmploymentStatus.ACTIVE) .endDate("end_date") .firstName("first_name") + .isActive(true) + .lastName("last_name") + .latestRehireDate("latest_rehire_date") + .location( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .name("name") + .sourceId("source_id") + .build() + ) + .manager( + EmploymentData.UnionMember0.Manager.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .middleName("middle_name") + .sourceId("source_id") + .startDate("start_date") + .title("title") + .workId("work_id") .income( Income.builder() .amount(0L) @@ -50,6 +76,36 @@ internal class EmploymentDataResponseTest { .unit(Income.Unit.YEARLY) .build() ) + .build() + ) + .code(0L) + .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(employmentDataResponse.body()) + .isEqualTo( + EmploymentData.ofUnionMember0( + EmploymentData.UnionMember0.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .classCode("class_code") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) + .department( + EmploymentData.UnionMember0.Department.builder().name("name").build() + ) + .employment( + EmploymentData.UnionMember0.Employment.builder() + .subtype(EmploymentData.UnionMember0.Employment.Subtype.FULL_TIME) + .type(EmploymentData.UnionMember0.Employment.Type.EMPLOYEE) + .build() + ) + .employmentStatus(EmploymentData.UnionMember0.EmploymentStatus.ACTIVE) + .endDate("end_date") + .firstName("first_name") .isActive(true) .lastName("last_name") .latestRehireDate("latest_rehire_date") @@ -66,7 +122,7 @@ internal class EmploymentDataResponseTest { .build() ) .manager( - EmploymentData.Manager.builder() + EmploymentData.UnionMember0.Manager.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -75,79 +131,28 @@ internal class EmploymentDataResponseTest { .startDate("start_date") .title("title") .workId("work_id") + .income( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) .build() ) - .code(0L) - .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - assertThat(employmentDataResponse.body()) - .contains( - EmploymentData.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .classCode("class_code") - .addCustomField( - EmploymentData.CustomField.builder() - .name("name") - .value(JsonValue.from(mapOf())) - .build() - ) - .department(EmploymentData.Department.builder().name("name").build()) - .employment( - EmploymentData.Employment.builder() - .subtype(EmploymentData.Employment.Subtype.FULL_TIME) - .type(EmploymentData.Employment.Type.EMPLOYEE) - .build() - ) - .employmentStatus(EmploymentData.EmploymentStatus.ACTIVE) - .endDate("end_date") - .firstName("first_name") - .income( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) - .addIncomeHistory( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) - .isActive(true) - .lastName("last_name") - .latestRehireDate("latest_rehire_date") - .location( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .name("name") - .sourceId("source_id") - .build() - ) - .manager( - EmploymentData.Manager.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .middleName("middle_name") - .sourceId("source_id") - .startDate("start_date") - .title("title") - .workId("work_id") - .build() ) - assertThat(employmentDataResponse.code()).contains(0L) + assertThat(employmentDataResponse.code()).isEqualTo(0L) assertThat(employmentDataResponse.individualId()) - .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test @@ -156,41 +161,27 @@ internal class EmploymentDataResponseTest { val employmentDataResponse = EmploymentDataResponse.builder() .body( - EmploymentData.builder() + EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") .addCustomField( - EmploymentData.CustomField.builder() + EmploymentData.UnionMember0.CustomField.builder() .name("name") - .value(JsonValue.from(mapOf())) + .value("string") .build() ) - .department(EmploymentData.Department.builder().name("name").build()) + .department( + EmploymentData.UnionMember0.Department.builder().name("name").build() + ) .employment( - EmploymentData.Employment.builder() - .subtype(EmploymentData.Employment.Subtype.FULL_TIME) - .type(EmploymentData.Employment.Type.EMPLOYEE) + EmploymentData.UnionMember0.Employment.builder() + .subtype(EmploymentData.UnionMember0.Employment.Subtype.FULL_TIME) + .type(EmploymentData.UnionMember0.Employment.Type.EMPLOYEE) .build() ) - .employmentStatus(EmploymentData.EmploymentStatus.ACTIVE) + .employmentStatus(EmploymentData.UnionMember0.EmploymentStatus.ACTIVE) .endDate("end_date") .firstName("first_name") - .income( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) - .addIncomeHistory( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) .isActive(true) .lastName("last_name") .latestRehireDate("latest_rehire_date") @@ -207,7 +198,7 @@ internal class EmploymentDataResponseTest { .build() ) .manager( - EmploymentData.Manager.builder() + EmploymentData.UnionMember0.Manager.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -216,6 +207,22 @@ internal class EmploymentDataResponseTest { .startDate("start_date") .title("title") .workId("work_id") + .income( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) .build() ) .code(0L) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt index 8b2e1a52..740c8a9d 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt @@ -5,50 +5,37 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.jsonMapper -import kotlin.jvm.optionals.getOrNull +import com.tryfinch.api.errors.FinchInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource internal class EmploymentDataTest { @Test - fun create() { - val employmentData = - EmploymentData.builder() + fun ofUnionMember0() { + val unionMember0 = + EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") .addCustomField( - EmploymentData.CustomField.builder() + EmploymentData.UnionMember0.CustomField.builder() .name("name") - .value(JsonValue.from(mapOf())) + .value("string") .build() ) - .department(EmploymentData.Department.builder().name("name").build()) + .department(EmploymentData.UnionMember0.Department.builder().name("name").build()) .employment( - EmploymentData.Employment.builder() - .subtype(EmploymentData.Employment.Subtype.FULL_TIME) - .type(EmploymentData.Employment.Type.EMPLOYEE) + EmploymentData.UnionMember0.Employment.builder() + .subtype(EmploymentData.UnionMember0.Employment.Subtype.FULL_TIME) + .type(EmploymentData.UnionMember0.Employment.Type.EMPLOYEE) .build() ) - .employmentStatus(EmploymentData.EmploymentStatus.ACTIVE) + .employmentStatus(EmploymentData.UnionMember0.EmploymentStatus.ACTIVE) .endDate("end_date") .firstName("first_name") - .income( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) - .addIncomeHistory( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) .isActive(true) .lastName("last_name") .latestRehireDate("latest_rehire_date") @@ -65,7 +52,7 @@ internal class EmploymentDataTest { .build() ) .manager( - EmploymentData.Manager.builder() + EmploymentData.UnionMember0.Manager.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -74,98 +61,6 @@ internal class EmploymentDataTest { .startDate("start_date") .title("title") .workId("work_id") - .build() - - assertThat(employmentData.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(employmentData.classCode()).contains("class_code") - assertThat(employmentData.customFields().getOrNull()) - .containsExactly( - EmploymentData.CustomField.builder() - .name("name") - .value(JsonValue.from(mapOf())) - .build() - ) - assertThat(employmentData.department()) - .contains(EmploymentData.Department.builder().name("name").build()) - assertThat(employmentData.employment()) - .contains( - EmploymentData.Employment.builder() - .subtype(EmploymentData.Employment.Subtype.FULL_TIME) - .type(EmploymentData.Employment.Type.EMPLOYEE) - .build() - ) - assertThat(employmentData.employmentStatus()) - .contains(EmploymentData.EmploymentStatus.ACTIVE) - assertThat(employmentData.endDate()).contains("end_date") - assertThat(employmentData.firstName()).contains("first_name") - assertThat(employmentData.income()) - .contains( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) - assertThat(employmentData.incomeHistory().getOrNull()) - .containsExactly( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) - assertThat(employmentData.isActive()).contains(true) - assertThat(employmentData.lastName()).contains("last_name") - assertThat(employmentData.latestRehireDate()).contains("latest_rehire_date") - assertThat(employmentData.location()) - .contains( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .name("name") - .sourceId("source_id") - .build() - ) - assertThat(employmentData.manager()) - .contains( - EmploymentData.Manager.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() - ) - assertThat(employmentData.middleName()).contains("middle_name") - assertThat(employmentData.sourceId()).contains("source_id") - assertThat(employmentData.startDate()).contains("start_date") - assertThat(employmentData.title()).contains("title") - assertThat(employmentData.workId()).contains("work_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val employmentData = - EmploymentData.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .classCode("class_code") - .addCustomField( - EmploymentData.CustomField.builder() - .name("name") - .value(JsonValue.from(mapOf())) - .build() - ) - .department(EmploymentData.Department.builder().name("name").build()) - .employment( - EmploymentData.Employment.builder() - .subtype(EmploymentData.Employment.Subtype.FULL_TIME) - .type(EmploymentData.Employment.Type.EMPLOYEE) - .build() - ) - .employmentStatus(EmploymentData.EmploymentStatus.ACTIVE) - .endDate("end_date") - .firstName("first_name") .income( Income.builder() .amount(0L) @@ -182,33 +77,84 @@ internal class EmploymentDataTest { .unit(Income.Unit.YEARLY) .build() ) - .isActive(true) - .lastName("last_name") - .latestRehireDate("latest_rehire_date") - .location( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .postalCode("postal_code") - .state("state") - .name("name") - .sourceId("source_id") - .build() - ) - .manager( - EmploymentData.Manager.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - .middleName("middle_name") - .sourceId("source_id") - .startDate("start_date") - .title("title") - .workId("work_id") .build() + val employmentData = EmploymentData.ofUnionMember0(unionMember0) + + assertThat(employmentData.unionMember0()).contains(unionMember0) + assertThat(employmentData.batchError()).isEmpty + } + + @Test + fun ofUnionMember0Roundtrip() { + val jsonMapper = jsonMapper() + val employmentData = + EmploymentData.ofUnionMember0( + EmploymentData.UnionMember0.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .classCode("class_code") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) + .department( + EmploymentData.UnionMember0.Department.builder().name("name").build() + ) + .employment( + EmploymentData.UnionMember0.Employment.builder() + .subtype(EmploymentData.UnionMember0.Employment.Subtype.FULL_TIME) + .type(EmploymentData.UnionMember0.Employment.Type.EMPLOYEE) + .build() + ) + .employmentStatus(EmploymentData.UnionMember0.EmploymentStatus.ACTIVE) + .endDate("end_date") + .firstName("first_name") + .isActive(true) + .lastName("last_name") + .latestRehireDate("latest_rehire_date") + .location( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .postalCode("postal_code") + .state("state") + .name("name") + .sourceId("source_id") + .build() + ) + .manager( + EmploymentData.UnionMember0.Manager.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .middleName("middle_name") + .sourceId("source_id") + .startDate("start_date") + .title("title") + .workId("work_id") + .income( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .build() + ) + val roundtrippedEmploymentData = jsonMapper.readValue( jsonMapper.writeValueAsString(employmentData), @@ -217,4 +163,60 @@ internal class EmploymentDataTest { assertThat(roundtrippedEmploymentData).isEqualTo(employmentData) } + + @Test + fun ofBatchError() { + val batchError = + EmploymentData.BatchError.builder() + .code(0.0) + .message("message") + .name("name") + .finchCode("finch_code") + .build() + + val employmentData = EmploymentData.ofBatchError(batchError) + + assertThat(employmentData.unionMember0()).isEmpty + assertThat(employmentData.batchError()).contains(batchError) + } + + @Test + fun ofBatchErrorRoundtrip() { + val jsonMapper = jsonMapper() + val employmentData = + EmploymentData.ofBatchError( + EmploymentData.BatchError.builder() + .code(0.0) + .message("message") + .name("name") + .finchCode("finch_code") + .build() + ) + + val roundtrippedEmploymentData = + jsonMapper.readValue( + jsonMapper.writeValueAsString(employmentData), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEmploymentData).isEqualTo(employmentData) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val employmentData = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { employmentData.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt index 4feb1dbc..28f9e30b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt @@ -3,7 +3,6 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -17,43 +16,33 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .addResponse( EmploymentDataResponse.builder() .body( - EmploymentData.builder() + EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") .addCustomField( - EmploymentData.CustomField.builder() + EmploymentData.UnionMember0.CustomField.builder() .name("name") - .value(JsonValue.from(mapOf())) + .value("string") .build() ) .department( - EmploymentData.Department.builder().name("name").build() + EmploymentData.UnionMember0.Department.builder() + .name("name") + .build() ) .employment( - EmploymentData.Employment.builder() - .subtype(EmploymentData.Employment.Subtype.FULL_TIME) - .type(EmploymentData.Employment.Type.EMPLOYEE) + EmploymentData.UnionMember0.Employment.builder() + .subtype( + EmploymentData.UnionMember0.Employment.Subtype.FULL_TIME + ) + .type(EmploymentData.UnionMember0.Employment.Type.EMPLOYEE) .build() ) - .employmentStatus(EmploymentData.EmploymentStatus.ACTIVE) + .employmentStatus( + EmploymentData.UnionMember0.EmploymentStatus.ACTIVE + ) .endDate("end_date") .firstName("first_name") - .income( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) - .addIncomeHistory( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) .isActive(true) .lastName("last_name") .latestRehireDate("latest_rehire_date") @@ -70,7 +59,7 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .build() ) .manager( - EmploymentData.Manager.builder() + EmploymentData.UnionMember0.Manager.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -79,6 +68,22 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .startDate("start_date") .title("title") .workId("work_id") + .income( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) .build() ) .code(0L) @@ -91,41 +96,31 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .containsExactly( EmploymentDataResponse.builder() .body( - EmploymentData.builder() + EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") .addCustomField( - EmploymentData.CustomField.builder() + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) + .department( + EmploymentData.UnionMember0.Department.builder() .name("name") - .value(JsonValue.from(mapOf())) .build() ) - .department(EmploymentData.Department.builder().name("name").build()) .employment( - EmploymentData.Employment.builder() - .subtype(EmploymentData.Employment.Subtype.FULL_TIME) - .type(EmploymentData.Employment.Type.EMPLOYEE) + EmploymentData.UnionMember0.Employment.builder() + .subtype( + EmploymentData.UnionMember0.Employment.Subtype.FULL_TIME + ) + .type(EmploymentData.UnionMember0.Employment.Type.EMPLOYEE) .build() ) - .employmentStatus(EmploymentData.EmploymentStatus.ACTIVE) + .employmentStatus(EmploymentData.UnionMember0.EmploymentStatus.ACTIVE) .endDate("end_date") .firstName("first_name") - .income( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) - .addIncomeHistory( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) .isActive(true) .lastName("last_name") .latestRehireDate("latest_rehire_date") @@ -142,7 +137,7 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .build() ) .manager( - EmploymentData.Manager.builder() + EmploymentData.UnionMember0.Manager.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -151,6 +146,22 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .startDate("start_date") .title("title") .workId("work_id") + .income( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) .build() ) .code(0L) @@ -167,43 +178,33 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .addResponse( EmploymentDataResponse.builder() .body( - EmploymentData.builder() + EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") .addCustomField( - EmploymentData.CustomField.builder() + EmploymentData.UnionMember0.CustomField.builder() .name("name") - .value(JsonValue.from(mapOf())) + .value("string") .build() ) .department( - EmploymentData.Department.builder().name("name").build() + EmploymentData.UnionMember0.Department.builder() + .name("name") + .build() ) .employment( - EmploymentData.Employment.builder() - .subtype(EmploymentData.Employment.Subtype.FULL_TIME) - .type(EmploymentData.Employment.Type.EMPLOYEE) + EmploymentData.UnionMember0.Employment.builder() + .subtype( + EmploymentData.UnionMember0.Employment.Subtype.FULL_TIME + ) + .type(EmploymentData.UnionMember0.Employment.Type.EMPLOYEE) .build() ) - .employmentStatus(EmploymentData.EmploymentStatus.ACTIVE) + .employmentStatus( + EmploymentData.UnionMember0.EmploymentStatus.ACTIVE + ) .endDate("end_date") .firstName("first_name") - .income( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) - .addIncomeHistory( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) .isActive(true) .lastName("last_name") .latestRehireDate("latest_rehire_date") @@ -220,7 +221,7 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .build() ) .manager( - EmploymentData.Manager.builder() + EmploymentData.UnionMember0.Manager.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -229,6 +230,22 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .startDate("start_date") .title("title") .workId("work_id") + .income( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) .build() ) .code(0L) From f816b281bd01e85660f613f14431a43eb761a221 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 1 May 2025 17:04:02 +0000 Subject: [PATCH 19/27] feat(api): api update --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 209f18ee..81dcd962 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%2Ffinch-9810fd8ae1eed14c34c83de1ac110dbfb8cc23d2ac930b641cb0ad40f327ecb8.yml -openapi_spec_hash: e0d44a94626fd6208a0d585ce93d7e89 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-670346966a2922b17f8aeaa07166171719883a30abbc97ba62da2312c9979076.yml +openapi_spec_hash: 34c486a4a71a90b6fec4e7b5c6e48e70 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 From 02422720923c2ec5b5348b0c7e90657433015847 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 2 May 2025 00:18:09 +0000 Subject: [PATCH 20/27] chore(internal): update java toolchain --- buildSrc/src/main/kotlin/finch.java.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/finch.java.gradle.kts b/buildSrc/src/main/kotlin/finch.java.gradle.kts index e39d9ac6..dfbacb86 100644 --- a/buildSrc/src/main/kotlin/finch.java.gradle.kts +++ b/buildSrc/src/main/kotlin/finch.java.gradle.kts @@ -21,7 +21,7 @@ configure { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) } sourceCompatibility = JavaVersion.VERSION_1_8 From b98adb325de5d5b7220bbeac1f1e5fd56f7a0c13 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 2 May 2025 18:01:04 +0000 Subject: [PATCH 21/27] feat(api): api update --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 81dcd962..b48500da 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%2Ffinch-670346966a2922b17f8aeaa07166171719883a30abbc97ba62da2312c9979076.yml -openapi_spec_hash: 34c486a4a71a90b6fec4e7b5c6e48e70 +openapi_spec_hash: 9dae98ca7e7e2e3b848f70973767cde2 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 From 988e8348cd1d2e31f5e2aaa91adfc835ae973ba0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 14:20:29 +0000 Subject: [PATCH 22/27] feat(api): api update --- .stats.yml | 4 ++-- .../models/SandboxPaymentCreateParamsTest.kt | 24 +++++++++---------- .../async/sandbox/PaymentServiceAsyncTest.kt | 8 +++---- .../blocking/sandbox/PaymentServiceTest.kt | 8 +++---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.stats.yml b/.stats.yml index b48500da..4231ff2b 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%2Ffinch-670346966a2922b17f8aeaa07166171719883a30abbc97ba62da2312c9979076.yml -openapi_spec_hash: 9dae98ca7e7e2e3b848f70973767cde2 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-09c5188f5c6dd563b943cad60f5896331ef5fc06e4a699700578f0bc60bd62a1.yml +openapi_spec_hash: 9283951c1a0b3fd41a5e38b647649da6 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt index 68ea6c51..b5ffec03 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt @@ -48,7 +48,7 @@ internal class SandboxPaymentCreateParamsTest { ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) + .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Attributes .builder() @@ -74,8 +74,8 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("usd") - .name("401k test") + .currency("currency") + .name("name") .preTax(true) .type(BenefitType._401K) .build() @@ -115,7 +115,7 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") + .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( @@ -199,7 +199,7 @@ internal class SandboxPaymentCreateParamsTest { ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) + .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction .Attributes @@ -227,8 +227,8 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("usd") - .name("401k test") + .currency("currency") + .name("name") .preTax(true) .type(BenefitType._401K) .build() @@ -269,7 +269,7 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") + .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( @@ -349,7 +349,7 @@ internal class SandboxPaymentCreateParamsTest { ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) + .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Attributes .builder() @@ -375,8 +375,8 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("usd") - .name("401k test") + .currency("currency") + .name("name") .preTax(true) .type(BenefitType._401K) .build() @@ -416,7 +416,7 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") + .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt index 1faf4d8a..a10ebb3d 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt @@ -67,7 +67,7 @@ internal class PaymentServiceAsyncTest { ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) + .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction .Attributes @@ -95,8 +95,8 @@ internal class PaymentServiceAsyncTest { ) .build() ) - .currency("usd") - .name("401k test") + .currency("currency") + .name("name") .preTax(true) .type(BenefitType._401K) .build() @@ -138,7 +138,7 @@ internal class PaymentServiceAsyncTest { .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") + .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod( SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt index 3d67e68e..2ebd888d 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt @@ -67,7 +67,7 @@ internal class PaymentServiceTest { ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) + .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction .Attributes @@ -95,8 +95,8 @@ internal class PaymentServiceTest { ) .build() ) - .currency("usd") - .name("401k test") + .currency("currency") + .name("name") .preTax(true) .type(BenefitType._401K) .build() @@ -138,7 +138,7 @@ internal class PaymentServiceTest { .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") + .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod( SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK From 2aa8003c7dfeb9be0a15a57d1c46931a7f85ab3e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 5 May 2025 16:08:08 +0000 Subject: [PATCH 23/27] feat(api): api update --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4231ff2b..5b274f2f 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%2Ffinch-09c5188f5c6dd563b943cad60f5896331ef5fc06e4a699700578f0bc60bd62a1.yml -openapi_spec_hash: 9283951c1a0b3fd41a5e38b647649da6 +openapi_spec_hash: b1ba73565832de570a90329cb4aab18b config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 From 59c1d397d17589eec93f6c1dab760aaa1d548188 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 13:35:42 +0000 Subject: [PATCH 24/27] feat(api): api update --- .stats.yml | 4 +- ...ayStatementRetrieveManyPageResponseTest.kt | 48 +++++++++++---- .../models/PayStatementResponseBodyTest.kt | 24 ++++---- .../api/models/PayStatementResponseTest.kt | 40 +++++++++---- .../tryfinch/api/models/PayStatementTest.kt | 60 +++++++++++++++---- .../models/SandboxPaymentCreateParamsTest.kt | 48 +++++++-------- .../async/sandbox/PaymentServiceAsyncTest.kt | 16 ++--- .../blocking/sandbox/PaymentServiceTest.kt | 16 ++--- 8 files changed, 166 insertions(+), 90 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5b274f2f..d004027c 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%2Ffinch-09c5188f5c6dd563b943cad60f5896331ef5fc06e4a699700578f0bc60bd62a1.yml -openapi_spec_hash: b1ba73565832de570a90329cb4aab18b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-f09e5f2c555d7ee764478b7bc73e92cd21f403d6ec189be14574c8367bc131ce.yml +openapi_spec_hash: bd0a8e001f14132c105992d40149909a config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt index d9eb5615..21ccd032 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt @@ -36,7 +36,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -69,7 +71,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -103,7 +107,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -139,7 +145,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -188,7 +196,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -219,7 +229,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -251,7 +263,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -284,7 +298,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -337,7 +353,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -370,7 +388,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -404,7 +424,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -440,7 +462,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt index 637118d4..40b61151 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt @@ -31,7 +31,7 @@ internal class PayStatementResponseBodyTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -60,7 +60,7 @@ internal class PayStatementResponseBodyTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -89,7 +89,7 @@ internal class PayStatementResponseBodyTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -119,7 +119,7 @@ internal class PayStatementResponseBodyTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -157,7 +157,7 @@ internal class PayStatementResponseBodyTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -184,7 +184,7 @@ internal class PayStatementResponseBodyTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -213,7 +213,7 @@ internal class PayStatementResponseBodyTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -242,7 +242,7 @@ internal class PayStatementResponseBodyTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -283,7 +283,7 @@ internal class PayStatementResponseBodyTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -312,7 +312,7 @@ internal class PayStatementResponseBodyTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -341,7 +341,7 @@ internal class PayStatementResponseBodyTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -371,7 +371,7 @@ internal class PayStatementResponseBodyTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt index 217970d6..b436711a 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt @@ -33,7 +33,9 @@ internal class PayStatementResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -64,7 +66,9 @@ internal class PayStatementResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -95,7 +99,9 @@ internal class PayStatementResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -125,7 +131,9 @@ internal class PayStatementResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -168,7 +176,7 @@ internal class PayStatementResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -197,7 +205,7 @@ internal class PayStatementResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -227,7 +235,7 @@ internal class PayStatementResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -257,7 +265,7 @@ internal class PayStatementResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -305,7 +313,9 @@ internal class PayStatementResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -336,7 +346,9 @@ internal class PayStatementResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -367,7 +379,9 @@ internal class PayStatementResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) @@ -397,7 +411,9 @@ internal class PayStatementResponseTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from( + mapOf() + ), ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementTest.kt index db400830..3724bb43 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementTest.kt @@ -25,7 +25,10 @@ internal class PayStatementTest { .metadata( PayStatement.Earning.Attributes.Metadata.InnerMetadata .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) .build() ) .build() @@ -49,7 +52,10 @@ internal class PayStatementTest { PayStatement.EmployeeDeduction.Attributes.Metadata .InnerMetadata .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) .build() ) .build() @@ -73,7 +79,10 @@ internal class PayStatementTest { PayStatement.EmployerContribution.Attributes.Metadata .InnerMetadata .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) .build() ) .build() @@ -99,7 +108,10 @@ internal class PayStatementTest { .metadata( PayStatement.Tax.Attributes.Metadata.InnerMetadata .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) .build() ) .build() @@ -127,7 +139,10 @@ internal class PayStatementTest { .metadata( PayStatement.Earning.Attributes.Metadata.InnerMetadata .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) .build() ) .build() @@ -152,7 +167,10 @@ internal class PayStatementTest { PayStatement.EmployeeDeduction.Attributes.Metadata .InnerMetadata .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) .build() ) .build() @@ -177,7 +195,10 @@ internal class PayStatementTest { PayStatement.EmployerContribution.Attributes.Metadata .InnerMetadata .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) .build() ) .build() @@ -205,7 +226,10 @@ internal class PayStatementTest { PayStatement.Tax.Attributes.Metadata.builder() .metadata( PayStatement.Tax.Attributes.Metadata.InnerMetadata.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) .build() ) .build() @@ -237,7 +261,10 @@ internal class PayStatementTest { .metadata( PayStatement.Earning.Attributes.Metadata.InnerMetadata .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) .build() ) .build() @@ -261,7 +288,10 @@ internal class PayStatementTest { PayStatement.EmployeeDeduction.Attributes.Metadata .InnerMetadata .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) .build() ) .build() @@ -285,7 +315,10 @@ internal class PayStatementTest { PayStatement.EmployerContribution.Attributes.Metadata .InnerMetadata .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) .build() ) .build() @@ -311,7 +344,10 @@ internal class PayStatementTest { .metadata( PayStatement.Tax.Attributes.Metadata.InnerMetadata .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) .build() ) .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt index b5ffec03..0f9cfcf9 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt @@ -32,7 +32,7 @@ internal class SandboxPaymentCreateParamsTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -48,7 +48,7 @@ internal class SandboxPaymentCreateParamsTest { ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(0L) + .amount(2000L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Attributes .builder() @@ -66,7 +66,7 @@ internal class SandboxPaymentCreateParamsTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -74,8 +74,8 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("currency") - .name("name") + .currency("usd") + .name("401k test") .preTax(true) .type(BenefitType._401K) .build() @@ -101,7 +101,7 @@ internal class SandboxPaymentCreateParamsTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -115,7 +115,7 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") + .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( @@ -135,7 +135,7 @@ internal class SandboxPaymentCreateParamsTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -183,7 +183,7 @@ internal class SandboxPaymentCreateParamsTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -199,7 +199,7 @@ internal class SandboxPaymentCreateParamsTest { ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(0L) + .amount(2000L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction .Attributes @@ -219,7 +219,7 @@ internal class SandboxPaymentCreateParamsTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -227,8 +227,8 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("currency") - .name("name") + .currency("usd") + .name("401k test") .preTax(true) .type(BenefitType._401K) .build() @@ -255,7 +255,7 @@ internal class SandboxPaymentCreateParamsTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -269,7 +269,7 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") + .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( @@ -289,7 +289,7 @@ internal class SandboxPaymentCreateParamsTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -333,7 +333,7 @@ internal class SandboxPaymentCreateParamsTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -349,7 +349,7 @@ internal class SandboxPaymentCreateParamsTest { ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(0L) + .amount(2000L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Attributes .builder() @@ -367,7 +367,7 @@ internal class SandboxPaymentCreateParamsTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -375,8 +375,8 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("currency") - .name("name") + .currency("usd") + .name("401k test") .preTax(true) .type(BenefitType._401K) .build() @@ -402,7 +402,7 @@ internal class SandboxPaymentCreateParamsTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -416,7 +416,7 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") + .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( @@ -436,7 +436,7 @@ internal class SandboxPaymentCreateParamsTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt index a10ebb3d..fc235e7b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt @@ -49,7 +49,7 @@ internal class PaymentServiceAsyncTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -67,7 +67,7 @@ internal class PaymentServiceAsyncTest { ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(0L) + .amount(2000L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction .Attributes @@ -87,7 +87,7 @@ internal class PaymentServiceAsyncTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -95,8 +95,8 @@ internal class PaymentServiceAsyncTest { ) .build() ) - .currency("currency") - .name("name") + .currency("usd") + .name("401k test") .preTax(true) .type(BenefitType._401K) .build() @@ -124,7 +124,7 @@ internal class PaymentServiceAsyncTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -138,7 +138,7 @@ internal class PaymentServiceAsyncTest { .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") + .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod( SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK @@ -162,7 +162,7 @@ internal class PaymentServiceAsyncTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt index 2ebd888d..1a8dba8b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt @@ -49,7 +49,7 @@ internal class PaymentServiceTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -67,7 +67,7 @@ internal class PaymentServiceTest { ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(0L) + .amount(2000L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction .Attributes @@ -87,7 +87,7 @@ internal class PaymentServiceTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -95,8 +95,8 @@ internal class PaymentServiceTest { ) .build() ) - .currency("currency") - .name("name") + .currency("usd") + .name("401k test") .preTax(true) .type(BenefitType._401K) .build() @@ -124,7 +124,7 @@ internal class PaymentServiceTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) @@ -138,7 +138,7 @@ internal class PaymentServiceTest { .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") + .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod( SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK @@ -162,7 +162,7 @@ internal class PaymentServiceTest { .builder() .putAdditionalProperty( "foo", - JsonValue.from("bar"), + JsonValue.from(mapOf()), ) .build() ) From 4271051bb2d5b34d55418363f2e8f958a3688dd5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 18:07:04 +0000 Subject: [PATCH 25/27] chore(internal): remove flaky `-Xbackend-threads=0` option --- buildSrc/src/main/kotlin/finch.kotlin.gradle.kts | 2 -- 1 file changed, 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/finch.kotlin.gradle.kts b/buildSrc/src/main/kotlin/finch.kotlin.gradle.kts index f274b11f..f3f20e2b 100644 --- a/buildSrc/src/main/kotlin/finch.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/finch.kotlin.gradle.kts @@ -19,8 +19,6 @@ kotlin { // Suppress deprecation warnings because we may still reference and test deprecated members. // TODO: Replace with `-Xsuppress-warning=DEPRECATION` once we use Kotlin compiler 2.1.0+. "-nowarn", - // Use as many threads as there are CPU cores on the machine for compilation. - "-Xbackend-threads=0", ) jvmTarget.set(JvmTarget.JVM_1_8) languageVersion.set(KotlinVersion.KOTLIN_1_8) From 055d4597de3f260537ccfa65a8f094e9df39bebb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 8 May 2025 16:55:37 +0000 Subject: [PATCH 26/27] feat(client)!: don't require end-users to specify constants # Migration Builder methods that previously accepted a single possible value no longer need to be called. --- .../api/models/JobAutomatedCreateParams.kt | 509 ++---------------- .../models/JobAutomatedCreateParamsTest.kt | 26 +- .../async/jobs/AutomatedServiceAsyncTest.kt | 8 +- .../blocking/jobs/AutomatedServiceTest.kt | 10 +- 4 files changed, 56 insertions(+), 497 deletions(-) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedCreateParams.kt index ac13130c..939ba0bc 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedCreateParams.kt @@ -15,7 +15,6 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.BaseDeserializer import com.tryfinch.api.core.BaseSerializer -import com.tryfinch.api.core.Enum import com.tryfinch.api.core.ExcludeMissing import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing @@ -88,8 +87,8 @@ private constructor( /** Alias for calling [Builder.body] with `body.orElse(null)`. */ fun body(body: Optional) = body(body.getOrNull()) - /** Alias for calling [body] with `Body.ofDataSyncAll(dataSyncAll)`. */ - fun body(dataSyncAll: Body.DataSyncAll) = body(Body.ofDataSyncAll(dataSyncAll)) + /** Alias for calling [body] with `Body.ofDataSyncAll()`. */ + fun bodyDataSyncAll() = body(Body.ofDataSyncAll()) /** Alias for calling [body] with `Body.ofW4FormEmployeeSync(w4FormEmployeeSync)`. */ fun body(w4FormEmployeeSync: Body.W4FormEmployeeSync) = @@ -99,20 +98,12 @@ private constructor( * Alias for calling [body] with the following: * ```java * Body.W4FormEmployeeSync.builder() - * .type(JobAutomatedCreateParams.Body.W4FormEmployeeSync.Type.W4_FORM_EMPLOYEE_SYNC) * .params(params) * .build() * ``` */ fun w4FormEmployeeSyncBody(params: Body.W4FormEmployeeSync.Params) = - body( - Body.W4FormEmployeeSync.builder() - .type( - JobAutomatedCreateParams.Body.W4FormEmployeeSync.Type.W4_FORM_EMPLOYEE_SYNC - ) - .params(params) - .build() - ) + body(Body.W4FormEmployeeSync.builder().params(params).build()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -231,12 +222,12 @@ private constructor( @JsonSerialize(using = Body.Serializer::class) class Body private constructor( - private val dataSyncAll: DataSyncAll? = null, + private val dataSyncAll: JsonValue? = null, private val w4FormEmployeeSync: W4FormEmployeeSync? = null, private val _json: JsonValue? = null, ) { - fun dataSyncAll(): Optional = Optional.ofNullable(dataSyncAll) + fun dataSyncAll(): Optional = Optional.ofNullable(dataSyncAll) fun w4FormEmployeeSync(): Optional = Optional.ofNullable(w4FormEmployeeSync) @@ -245,7 +236,7 @@ private constructor( fun isW4FormEmployeeSync(): Boolean = w4FormEmployeeSync != null - fun asDataSyncAll(): DataSyncAll = dataSyncAll.getOrThrow("dataSyncAll") + fun asDataSyncAll(): JsonValue = dataSyncAll.getOrThrow("dataSyncAll") fun asW4FormEmployeeSync(): W4FormEmployeeSync = w4FormEmployeeSync.getOrThrow("w4FormEmployeeSync") @@ -268,8 +259,14 @@ private constructor( accept( object : Visitor { - override fun visitDataSyncAll(dataSyncAll: DataSyncAll) { - dataSyncAll.validate() + override fun visitDataSyncAll(dataSyncAll: JsonValue) { + dataSyncAll.let { + if (it != JsonValue.from(mapOf("type" to "data_sync_all"))) { + throw FinchInvalidDataException( + "'dataSyncAll' is invalid, received $it" + ) + } + } } override fun visitW4FormEmployeeSync(w4FormEmployeeSync: W4FormEmployeeSync) { @@ -298,7 +295,10 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitDataSyncAll(dataSyncAll: DataSyncAll) = dataSyncAll.validity() + override fun visitDataSyncAll(dataSyncAll: JsonValue) = + dataSyncAll.let { + if (it == JsonValue.from(mapOf("type" to "data_sync_all"))) 1 else 0 + } override fun visitW4FormEmployeeSync(w4FormEmployeeSync: W4FormEmployeeSync) = w4FormEmployeeSync.validity() @@ -327,7 +327,9 @@ private constructor( companion object { - @JvmStatic fun ofDataSyncAll(dataSyncAll: DataSyncAll) = Body(dataSyncAll = dataSyncAll) + @JvmStatic + fun ofDataSyncAll() = + Body(dataSyncAll = JsonValue.from(mapOf("type" to "data_sync_all"))) @JvmStatic fun ofW4FormEmployeeSync(w4FormEmployeeSync: W4FormEmployeeSync) = @@ -337,7 +339,7 @@ private constructor( /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ interface Visitor { - fun visitDataSyncAll(dataSyncAll: DataSyncAll): T + fun visitDataSyncAll(dataSyncAll: JsonValue): T fun visitW4FormEmployeeSync(w4FormEmployeeSync: W4FormEmployeeSync): T @@ -363,9 +365,9 @@ private constructor( when (type) { "data_sync_all" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(dataSyncAll = it, _json = json) - } ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(dataSyncAll = it, _json = json) } + ?.takeIf { it.isValid() } ?: Body(_json = json) } "w4_form_employee_sync" -> { return tryDeserialize(node, jacksonTypeRef())?.let { @@ -395,295 +397,10 @@ private constructor( } } - class DataSyncAll - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() - ) : this(type, mutableMapOf()) - - /** - * The type of job to start. - * - * @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 type(): Type = type.getRequired("type") - - /** - * 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 [DataSyncAll]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DataSyncAll]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(dataSyncAll: DataSyncAll) = apply { - type = dataSyncAll.type - additionalProperties = dataSyncAll.additionalProperties.toMutableMap() - } - - /** The type of job to start. */ - 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 [DataSyncAll]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): DataSyncAll = - DataSyncAll(checkRequired("type", type), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): DataSyncAll = apply { - if (validated) { - return@apply - } - - type().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 = (type.asKnown().getOrNull()?.validity() ?: 0) - - /** The type of job to start. */ - 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 DATA_SYNC_ALL = of("data_sync_all") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - DATA_SYNC_ALL - } - - /** - * 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 { - DATA_SYNC_ALL, - /** - * 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) { - DATA_SYNC_ALL -> Value.DATA_SYNC_ALL - 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) { - DATA_SYNC_ALL -> Known.DATA_SYNC_ALL - 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 - - 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DataSyncAll && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DataSyncAll{type=$type, additionalProperties=$additionalProperties}" - } - class W4FormEmployeeSync private constructor( private val params: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -692,7 +409,7 @@ private constructor( @JsonProperty("params") @ExcludeMissing params: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(params, type, mutableMapOf()) /** @@ -705,11 +422,15 @@ private constructor( /** * The type of job to start. * - * @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). + * Expected to always return the following: + * ```java + * JsonValue.from("w4_form_employee_sync") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [params]. @@ -718,13 +439,6 @@ private constructor( */ @JsonProperty("params") @ExcludeMissing fun _params(): JsonField = params - /** - * 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) @@ -745,7 +459,6 @@ private constructor( * The following fields are required: * ```java * .params() - * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -755,7 +468,7 @@ private constructor( class Builder internal constructor() { private var params: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("w4_form_employee_sync") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -776,17 +489,19 @@ private constructor( */ fun params(params: JsonField) = apply { this.params = params } - /** The type of job to start. */ - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("w4_form_employee_sync") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -818,7 +533,6 @@ private constructor( * The following fields are required: * ```java * .params() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -826,7 +540,7 @@ private constructor( fun build(): W4FormEmployeeSync = W4FormEmployeeSync( checkRequired("params", params), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } @@ -839,7 +553,11 @@ private constructor( } params().validate() - type().validate() + _type().let { + if (it != JsonValue.from("w4_form_employee_sync")) { + throw FinchInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -860,7 +578,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (params.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + type.let { if (it == JsonValue.from("w4_form_employee_sync")) 1 else 0 } class Params private constructor( @@ -1033,131 +751,6 @@ private constructor( "Params{individualId=$individualId, additionalProperties=$additionalProperties}" } - /** The type of job to start. */ - 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 W4_FORM_EMPLOYEE_SYNC = of("w4_form_employee_sync") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - W4_FORM_EMPLOYEE_SYNC - } - - /** - * 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 { - W4_FORM_EMPLOYEE_SYNC, - /** - * 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) { - W4_FORM_EMPLOYEE_SYNC -> Value.W4_FORM_EMPLOYEE_SYNC - 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) { - W4_FORM_EMPLOYEE_SYNC -> Known.W4_FORM_EMPLOYEE_SYNC - 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 - - 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedCreateParamsTest.kt index 8221c7e1..05ceffa7 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedCreateParamsTest.kt @@ -10,36 +10,16 @@ internal class JobAutomatedCreateParamsTest { @Test fun create() { - JobAutomatedCreateParams.builder() - .body( - JobAutomatedCreateParams.Body.DataSyncAll.builder() - .type(JobAutomatedCreateParams.Body.DataSyncAll.Type.DATA_SYNC_ALL) - .build() - ) - .build() + JobAutomatedCreateParams.builder().bodyDataSyncAll().build() } @Test fun body() { - val params = - JobAutomatedCreateParams.builder() - .body( - JobAutomatedCreateParams.Body.DataSyncAll.builder() - .type(JobAutomatedCreateParams.Body.DataSyncAll.Type.DATA_SYNC_ALL) - .build() - ) - .build() + val params = JobAutomatedCreateParams.builder().bodyDataSyncAll().build() val body = params._body().getOrNull() - assertThat(body) - .isEqualTo( - JobAutomatedCreateParams.Body.ofDataSyncAll( - JobAutomatedCreateParams.Body.DataSyncAll.builder() - .type(JobAutomatedCreateParams.Body.DataSyncAll.Type.DATA_SYNC_ALL) - .build() - ) - ) + assertThat(body).isEqualTo(JobAutomatedCreateParams.Body.ofDataSyncAll()) } @Test diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncTest.kt index 8eea4c25..ac39efe6 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncTest.kt @@ -24,13 +24,7 @@ internal class AutomatedServiceAsyncTest { val automatedFuture = automatedServiceAsync.create( - JobAutomatedCreateParams.builder() - .body( - JobAutomatedCreateParams.Body.DataSyncAll.builder() - .type(JobAutomatedCreateParams.Body.DataSyncAll.Type.DATA_SYNC_ALL) - .build() - ) - .build() + JobAutomatedCreateParams.builder().bodyDataSyncAll().build() ) val automated = automatedFuture.get() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceTest.kt index 226173ab..e6ff60ac 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceTest.kt @@ -23,15 +23,7 @@ internal class AutomatedServiceTest { val automatedService = client.jobs().automated() val automated = - automatedService.create( - JobAutomatedCreateParams.builder() - .body( - JobAutomatedCreateParams.Body.DataSyncAll.builder() - .type(JobAutomatedCreateParams.Body.DataSyncAll.Type.DATA_SYNC_ALL) - .build() - ) - .build() - ) + automatedService.create(JobAutomatedCreateParams.builder().bodyDataSyncAll().build()) automated.validate() } From 7fcb054f22d6effe36c1ea40f46435e6aca7b97e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 8 May 2025 16:56:20 +0000 Subject: [PATCH 27/27] release: 6.0.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 36 +++++++++++++++++++++++++++++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f425d970..112e32b3 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "5.5.0" + ".": "6.0.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dae2b9c..38ebf293 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,41 @@ # Changelog +## 6.0.0 (2025-05-08) + +Full Changelog: [v5.5.0...v6.0.0](https://github.com/Finch-API/finch-api-java/compare/v5.5.0...v6.0.0) + +### ⚠ BREAKING CHANGES + +* **client:** don't require end-users to specify constants +* **client:** **Migration:** Builder methods that previously accepted a single possible value no longer need to be called. + +### Features + +* **api:** api update ([59c1d39](https://github.com/Finch-API/finch-api-java/commit/59c1d397d17589eec93f6c1dab760aaa1d548188)) +* **api:** api update ([2aa8003](https://github.com/Finch-API/finch-api-java/commit/2aa8003c7dfeb9be0a15a57d1c46931a7f85ab3e)) +* **api:** api update ([988e834](https://github.com/Finch-API/finch-api-java/commit/988e8348cd1d2e31f5e2aaa91adfc835ae973ba0)) +* **api:** api update ([b98adb3](https://github.com/Finch-API/finch-api-java/commit/b98adb325de5d5b7220bbeac1f1e5fd56f7a0c13)) +* **api:** api update ([f816b28](https://github.com/Finch-API/finch-api-java/commit/f816b281bd01e85660f613f14431a43eb761a221)) +* **api:** api update ([d399e4f](https://github.com/Finch-API/finch-api-java/commit/d399e4f9395f2e84f6a97399ae6f0fdcbc34d7cd)) +* **api:** api update ([cc2b828](https://github.com/Finch-API/finch-api-java/commit/cc2b8288f7c3ce5bc62e7ca074fd53fc6f05e253)) +* **api:** api update ([a9fefbc](https://github.com/Finch-API/finch-api-java/commit/a9fefbc485cfa35d7c34aa409333a7b2e244f26a)) +* **api:** api update ([9e451d0](https://github.com/Finch-API/finch-api-java/commit/9e451d0ea744078d1c4f10c878a950ca3719237b)) +* **api:** api update ([f45fb21](https://github.com/Finch-API/finch-api-java/commit/f45fb2151509dd96e2630b94ed4b3a1f3f711439)) +* **api:** api update ([43c21f7](https://github.com/Finch-API/finch-api-java/commit/43c21f75d63053a888c4ba99dd63847b145bf360)) +* **api:** api update ([35e522b](https://github.com/Finch-API/finch-api-java/commit/35e522ba3ad911b49f41ad4b62f1ddc3257dbcd2)) +* **api:** api update ([70708d7](https://github.com/Finch-API/finch-api-java/commit/70708d78bc704b34f936e835b614e54c87c2db03)) +* **api:** api update ([f8988d7](https://github.com/Finch-API/finch-api-java/commit/f8988d7fc959241b683da19b068c95a8ac023e24)) +* **api:** api update ([53c3147](https://github.com/Finch-API/finch-api-java/commit/53c31470ca6f0cf5985f8ebd60446f8f08e84913)) +* **api:** api update ([30df955](https://github.com/Finch-API/finch-api-java/commit/30df955523928c30ef0e29f1154ff5fee88d80d1)) +* **api:** api update ([79e067e](https://github.com/Finch-API/finch-api-java/commit/79e067e9790c16095a9a81cea65fb500c6f4aea6)) +* **client:** don't require end-users to specify constants ([055d459](https://github.com/Finch-API/finch-api-java/commit/055d4597de3f260537ccfa65a8f094e9df39bebb)) + + +### Chores + +* **internal:** remove flaky `-Xbackend-threads=0` option ([4271051](https://github.com/Finch-API/finch-api-java/commit/4271051bb2d5b34d55418363f2e8f958a3688dd5)) +* **internal:** update java toolchain ([0242272](https://github.com/Finch-API/finch-api-java/commit/02422720923c2ec5b5348b0c7e90657433015847)) + ## 5.5.0 (2025-04-23) Full Changelog: [v5.4.0...v5.5.0](https://github.com/Finch-API/finch-api-java/compare/v5.4.0...v5.5.0) diff --git a/README.md b/README.md index fc5a3b6f..fe0a5e8d 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/5.5.0) -[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-java/5.5.0/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-java/5.5.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/6.0.0) +[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-java/6.0.0/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-java/6.0.0) @@ -15,7 +15,7 @@ It is generated with [Stainless](https://www.stainless.com/). -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/5.5.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/6.0.0). @@ -26,7 +26,7 @@ The REST API documentation can be found on [developer.tryfinch.com](https://deve ### Gradle ```kotlin -implementation("com.tryfinch.api:finch-java:5.5.0") +implementation("com.tryfinch.api:finch-java:6.0.0") ``` ### Maven @@ -35,7 +35,7 @@ implementation("com.tryfinch.api:finch-java:5.5.0") com.tryfinch.api finch-java - 5.5.0 + 6.0.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index c8fe62a1..dcfcd84d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.tryfinch.api" - version = "5.5.0" // x-release-please-version + version = "6.0.0" // x-release-please-version } subprojects {