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/.stats.yml b/.stats.yml
index 1629f07d..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-05a1c7485ea6dd75ad2fb1a0628570d88a3e7c4f1e1ecad433711c78deae50e6.yml
-openapi_spec_hash: 6d6014d50e18c98219b496bb2a5dab1d
+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/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 @@
-[](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/5.5.0)
-[](https://javadoc.io/doc/com.tryfinch.api/finch-java/5.5.0)
+[](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/6.0.0)
+[](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 {
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
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)
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/CompanyBenefit.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyBenefit.kt
index bc621dbe..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
@@ -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,515 @@ 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: 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(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/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