diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 2499cfae..042993b7 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -22,7 +22,7 @@ jobs: distribution: temurin java-version: | 8 - 17 + 21 cache: gradle - name: Set up Gradle @@ -33,7 +33,7 @@ jobs: export -- GPG_SIGNING_KEY_ID printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" - ./gradlew publishAndReleaseToMavenCentral -Dorg.gradle.jvmargs="-Xmx8g" --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache + ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache env: SONATYPE_USERNAME: ${{ secrets.FINCH_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.FINCH_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json index e49be765..8e11baae 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "7.5.2" + ".": "7.6.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 019c8e66..ba35cc4a 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-e8b684dbd61d1724b5e516a573a952bb6906d63840e27ebda7731a2f71061aff.yml -openapi_spec_hash: 8baff9577d4e721d0494ff315da267ca -config_hash: 5146b12344dae76238940989dac1e8a0 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-199a2fd8b7387b0648e88b5942a8248895373a561aff663389982073e55c8eb5.yml +openapi_spec_hash: 7415c1faca5f2e873824893b140650f1 +config_hash: 6d3585c0032e08d723d077d660fc8448 diff --git a/CHANGELOG.md b/CHANGELOG.md index c5503aa0..1f9e083b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,43 @@ # Changelog +## 7.6.0 (2025-10-09) + +Full Changelog: [v7.5.2...v7.6.0](https://github.com/Finch-API/finch-api-java/compare/v7.5.2...v7.6.0) + +### Features + +* **api:** api update ([ad4e392](https://github.com/Finch-API/finch-api-java/commit/ad4e39250d4c3c675e7eec402176c12c6146bf8c)) +* **api:** api update ([44864b7](https://github.com/Finch-API/finch-api-java/commit/44864b7f26c318600f0e7544109430a8c5112a1d)) +* **api:** api update ([71bc2ee](https://github.com/Finch-API/finch-api-java/commit/71bc2eea611486a4f156f76f8a6a4f68483bb078)) +* **api:** api update ([5751ee1](https://github.com/Finch-API/finch-api-java/commit/5751ee17299c6a67354b6f7e16baed691a62e560)) +* **api:** api update ([11e8385](https://github.com/Finch-API/finch-api-java/commit/11e83851d62b489718c81440b16734def25c07bf)) +* **api:** api update ([ff49b09](https://github.com/Finch-API/finch-api-java/commit/ff49b09be8b1d99fd939600a128c733a45586417)) +* **api:** api update ([0f28b13](https://github.com/Finch-API/finch-api-java/commit/0f28b13c3cbb994557ed019c2020939a7e0476e1)) +* **api:** make client id, client secret optional again ([6119020](https://github.com/Finch-API/finch-api-java/commit/61190204ca49d06cfd445baa0792b29d2a41d738)) +* **client:** add convenience overloads for some methods ([ac75f13](https://github.com/Finch-API/finch-api-java/commit/ac75f134bce62861ce3d2c9d9a8dc91bc16e8b83)) +* **client:** expose sleeper option ([6eb8e0f](https://github.com/Finch-API/finch-api-java/commit/6eb8e0f744b399b8a056c481b5d35850eaca0ced)) + + +### Bug Fixes + +* **ci:** use java-version 21 for publish step ([7d2e9d7](https://github.com/Finch-API/finch-api-java/commit/7d2e9d77738fef412fc7606230877cdb3befca7f)) +* **client:** deserialization of empty objects ([bb6d18b](https://github.com/Finch-API/finch-api-java/commit/bb6d18b4c4c47e1efea7aa7ab716f2414afb4870)) +* **client:** ensure single timer is created per client ([6eb8e0f](https://github.com/Finch-API/finch-api-java/commit/6eb8e0f744b399b8a056c481b5d35850eaca0ced)) +* **client:** incorrect `getPackageVersion` impl ([a7638ae](https://github.com/Finch-API/finch-api-java/commit/a7638ae702e08f124b717a78ed90a6b7347ee92c)) +* fix casing issue ([a493f5f](https://github.com/Finch-API/finch-api-java/commit/a493f5f1779c5af85ea3122a3bcba407eb0b1099)) +* update singularization rules ([270e376](https://github.com/Finch-API/finch-api-java/commit/270e37692dcb7314ec7ff88debd588642615533d)) + + +### Chores + +* **ci:** reduce log noise ([b7eee64](https://github.com/Finch-API/finch-api-java/commit/b7eee641c7c531117813d3400955373a1268e495)) +* improve formatter performance ([ebb6206](https://github.com/Finch-API/finch-api-java/commit/ebb6206eaecf268ccd3a251dc5a4159333bbe6af)) +* **internal:** change some comment formatting ([235dfbc](https://github.com/Finch-API/finch-api-java/commit/235dfbc5ffb151fde9d608b7fb3db4f1d25bf0ef)) +* **internal:** codegen related update ([5623e2d](https://github.com/Finch-API/finch-api-java/commit/5623e2d992fe5352d55f6ddec923e2b0239fef30)) +* **internal:** codegen related update ([e87c1f4](https://github.com/Finch-API/finch-api-java/commit/e87c1f421dd2e0f4805187b928a2ae54b963535b)) +* **internal:** codegen related update ([4f33876](https://github.com/Finch-API/finch-api-java/commit/4f3387637ddad2287835d764441a75e1a42ac216)) +* remove memory upper bound from publishing step ([c1d1685](https://github.com/Finch-API/finch-api-java/commit/c1d16852bef0a7a7177e3619cce87d754f391edc)) + ## 7.5.2 (2025-08-20) Full Changelog: [v7.5.1...v7.5.2](https://github.com/Finch-API/finch-api-java/compare/v7.5.1...v7.5.2) diff --git a/README.md b/README.md index 99f7362a..ee25f2f8 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/7.5.2) -[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-java/7.5.2/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.5.2) +[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/7.6.0) +[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-java/7.6.0/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.6.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/7.5.2). +The REST API documentation can be found on [developer.tryfinch.com](https://developer.tryfinch.com/). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.6.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:7.5.2") +implementation("com.tryfinch.api:finch-java:7.6.0") ``` ### Maven @@ -35,7 +35,7 @@ implementation("com.tryfinch.api:finch-java:7.5.2") com.tryfinch.api finch-java - 7.5.2 + 7.6.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 7c4ec2b8..f21b0c40 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.tryfinch.api" - version = "7.5.2" // x-release-please-version + version = "7.6.0" // x-release-please-version } subprojects { diff --git a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClient.kt b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClient.kt index 68859894..81d8813e 100644 --- a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClient.kt +++ b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClient.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.tryfinch.api.client.FinchClient import com.tryfinch.api.client.FinchClientImpl import com.tryfinch.api.core.ClientOptions +import com.tryfinch.api.core.Sleeper import com.tryfinch.api.core.Timeout import com.tryfinch.api.core.http.AsyncStreamResponse import com.tryfinch.api.core.http.Headers @@ -133,6 +134,17 @@ class FinchOkHttpClient private constructor() { clientOptions.streamHandlerExecutor(streamHandlerExecutor) } + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) } + /** * The clock to use for operations that require timing, like retries. * diff --git a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClientAsync.kt b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClientAsync.kt index 668500aa..1987a24d 100644 --- a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClientAsync.kt +++ b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClientAsync.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.tryfinch.api.client.FinchClientAsync import com.tryfinch.api.client.FinchClientAsyncImpl import com.tryfinch.api.core.ClientOptions +import com.tryfinch.api.core.Sleeper import com.tryfinch.api.core.Timeout import com.tryfinch.api.core.http.AsyncStreamResponse import com.tryfinch.api.core.http.Headers @@ -133,6 +134,17 @@ class FinchOkHttpClientAsync private constructor() { clientOptions.streamHandlerExecutor(streamHandlerExecutor) } + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) } + /** * The clock to use for operations that require timing, like retries. * diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/ClientOptions.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/ClientOptions.kt index 42a6c1e2..8d6c2ad0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/ClientOptions.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/ClientOptions.kt @@ -55,6 +55,16 @@ private constructor( * This class takes ownership of the executor and shuts it down, if possible, when closed. */ @get:JvmName("streamHandlerExecutor") val streamHandlerExecutor: Executor, + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + @get:JvmName("sleeper") val sleeper: Sleeper, /** * The clock to use for operations that require timing, like retries. * @@ -156,6 +166,7 @@ private constructor( private var checkJacksonVersionCompatibility: Boolean = true private var jsonMapper: JsonMapper = jsonMapper() private var streamHandlerExecutor: Executor? = null + private var sleeper: Sleeper? = null private var clock: Clock = Clock.systemUTC() private var baseUrl: String? = null private var headers: Headers.Builder = Headers.builder() @@ -174,6 +185,7 @@ private constructor( checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility jsonMapper = clientOptions.jsonMapper streamHandlerExecutor = clientOptions.streamHandlerExecutor + sleeper = clientOptions.sleeper clock = clientOptions.clock baseUrl = clientOptions.baseUrl headers = clientOptions.headers.toBuilder() @@ -231,6 +243,17 @@ private constructor( else streamHandlerExecutor } + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { this.sleeper = PhantomReachableSleeper(sleeper) } + /** * The clock to use for operations that require timing, like retries. * @@ -438,6 +461,25 @@ private constructor( */ fun build(): ClientOptions { val httpClient = checkRequired("httpClient", httpClient) + val streamHandlerExecutor = + streamHandlerExecutor + ?: PhantomReachableExecutorService( + Executors.newCachedThreadPool( + object : ThreadFactory { + + private val threadFactory: ThreadFactory = + Executors.defaultThreadFactory() + private val count = AtomicLong(0) + + override fun newThread(runnable: Runnable): Thread = + threadFactory.newThread(runnable).also { + it.name = + "finch-stream-handler-thread-${count.getAndIncrement()}" + } + } + ) + ) + val sleeper = sleeper ?: PhantomReachableSleeper(DefaultSleeper()) val headers = Headers.builder() val queryParams = QueryParams.builder() @@ -471,26 +513,14 @@ private constructor( httpClient, RetryingHttpClient.builder() .httpClient(httpClient) + .sleeper(sleeper) .clock(clock) .maxRetries(maxRetries) .build(), checkJacksonVersionCompatibility, jsonMapper, - streamHandlerExecutor - ?: Executors.newCachedThreadPool( - object : ThreadFactory { - - private val threadFactory: ThreadFactory = - Executors.defaultThreadFactory() - private val count = AtomicLong(0) - - override fun newThread(runnable: Runnable): Thread = - threadFactory.newThread(runnable).also { - it.name = - "finch-stream-handler-thread-${count.getAndIncrement()}" - } - } - ), + streamHandlerExecutor, + sleeper, clock, baseUrl, headers.build(), @@ -519,5 +549,6 @@ private constructor( fun close() { httpClient.close() (streamHandlerExecutor as? ExecutorService)?.shutdown() + sleeper.close() } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/DefaultSleeper.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/DefaultSleeper.kt new file mode 100644 index 00000000..005c6f8c --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/DefaultSleeper.kt @@ -0,0 +1,28 @@ +package com.tryfinch.api.core + +import java.time.Duration +import java.util.Timer +import java.util.TimerTask +import java.util.concurrent.CompletableFuture + +class DefaultSleeper : Sleeper { + + private val timer = Timer("DefaultSleeper", true) + + override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) + + override fun sleepAsync(duration: Duration): CompletableFuture { + val future = CompletableFuture() + timer.schedule( + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + duration.toMillis(), + ) + return future + } + + override fun close() = timer.cancel() +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/PhantomReachableSleeper.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/PhantomReachableSleeper.kt new file mode 100644 index 00000000..0b0e21bb --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/PhantomReachableSleeper.kt @@ -0,0 +1,23 @@ +package com.tryfinch.api.core + +import java.time.Duration +import java.util.concurrent.CompletableFuture + +/** + * A delegating wrapper around a [Sleeper] that closes it once it's only phantom reachable. + * + * This class ensures the [Sleeper] is closed even if the user forgets to do it. + */ +internal class PhantomReachableSleeper(private val sleeper: Sleeper) : Sleeper { + + init { + closeWhenPhantomReachable(this, sleeper) + } + + override fun sleep(duration: Duration) = sleeper.sleep(duration) + + override fun sleepAsync(duration: Duration): CompletableFuture = + sleeper.sleepAsync(duration) + + override fun close() = sleeper.close() +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Properties.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Properties.kt index cc7e7158..29bb4994 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Properties.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Properties.kt @@ -2,7 +2,7 @@ package com.tryfinch.api.core -import java.util.Properties +import com.tryfinch.api.client.FinchClient fun getOsArch(): String { val osArch = System.getProperty("os.arch") @@ -16,7 +16,7 @@ fun getOsArch(): String { "x86_64" -> "x64" "arm" -> "arm" "aarch64" -> "arm64" - else -> "other:${osArch}" + else -> "other:$osArch" } } @@ -30,13 +30,13 @@ fun getOsName(): String { osName.startsWith("Linux") -> "Linux" osName.startsWith("Mac OS") -> "MacOS" osName.startsWith("Windows") -> "Windows" - else -> "Other:${osName}" + else -> "Other:$osName" } } fun getOsVersion(): String = System.getProperty("os.version", "unknown") fun getPackageVersion(): String = - Properties::class.java.`package`.implementationVersion ?: "unknown" + FinchClient::class.java.`package`.implementationVersion ?: "unknown" fun getJavaVersion(): String = System.getProperty("java.version", "unknown") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Sleeper.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Sleeper.kt new file mode 100644 index 00000000..b027f47d --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Sleeper.kt @@ -0,0 +1,21 @@ +package com.tryfinch.api.core + +import java.time.Duration +import java.util.concurrent.CompletableFuture + +/** + * An interface for delaying execution for a specified amount of time. + * + * Useful for testing and cleaning up resources. + */ +interface Sleeper : AutoCloseable { + + /** Synchronously pauses execution for the given [duration]. */ + fun sleep(duration: Duration) + + /** Asynchronously pauses execution for the given [duration]. */ + fun sleepAsync(duration: Duration): CompletableFuture + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/RetryingHttpClient.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/RetryingHttpClient.kt index d4cb1e78..b1d9b083 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/RetryingHttpClient.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/RetryingHttpClient.kt @@ -1,6 +1,8 @@ package com.tryfinch.api.core.http +import com.tryfinch.api.core.DefaultSleeper import com.tryfinch.api.core.RequestOptions +import com.tryfinch.api.core.Sleeper import com.tryfinch.api.core.checkRequired import com.tryfinch.api.errors.FinchIoException import com.tryfinch.api.errors.FinchRetryableException @@ -11,8 +13,6 @@ import java.time.OffsetDateTime import java.time.format.DateTimeFormatter import java.time.format.DateTimeParseException import java.time.temporal.ChronoUnit -import java.util.Timer -import java.util.TimerTask import java.util.UUID import java.util.concurrent.CompletableFuture import java.util.concurrent.ThreadLocalRandom @@ -130,7 +130,10 @@ private constructor( return executeWithRetries(modifiedRequest, requestOptions) } - override fun close() = httpClient.close() + override fun close() { + httpClient.close() + sleeper.close() + } private fun isRetryable(request: HttpRequest): Boolean = // Some requests, such as when a request body is being streamed, cannot be retried because @@ -235,33 +238,14 @@ private constructor( class Builder internal constructor() { private var httpClient: HttpClient? = null - private var sleeper: Sleeper = - object : Sleeper { - - private val timer = Timer("RetryingHttpClient", true) - - override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) - - override fun sleepAsync(duration: Duration): CompletableFuture { - val future = CompletableFuture() - timer.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - duration.toMillis(), - ) - return future - } - } + private var sleeper: Sleeper? = null private var clock: Clock = Clock.systemUTC() private var maxRetries: Int = 2 private var idempotencyHeader: String? = null fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } - @JvmSynthetic internal fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } + fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } fun clock(clock: Clock) = apply { this.clock = clock } @@ -272,17 +256,10 @@ private constructor( fun build(): HttpClient = RetryingHttpClient( checkRequired("httpClient", httpClient), - sleeper, + sleeper ?: DefaultSleeper(), clock, maxRetries, idempotencyHeader, ) } - - internal interface Sleeper { - - fun sleep(duration: Duration) - - fun sleepAsync(duration: Duration): CompletableFuture - } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccessTokenCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccessTokenCreateParams.kt index 2d1e6f32..75ba86fd 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccessTokenCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccessTokenCreateParams.kt @@ -22,30 +22,38 @@ import java.util.Optional /** Exchange the authorization code for an access token */ class AccessTokenCreateParams private constructor( - private val body: Body, + private val body: CreateAccessTokenRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { /** + * The authorization code received from the authorization server + * * @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(): String = body.code() /** + * The client ID for your application + * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun clientId(): Optional = body.clientId() /** + * The client secret for your application + * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun clientSecret(): Optional = body.clientSecret() /** + * The redirect URI used in the authorization request (optional) + * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -105,7 +113,7 @@ private constructor( /** A builder for [AccessTokenCreateParams]. */ class Builder internal constructor() { - private var body: Body.Builder = Body.builder() + private var body: CreateAccessTokenRequest.Builder = CreateAccessTokenRequest.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -126,8 +134,9 @@ private constructor( * - [clientSecret] * - [redirectUri] */ - fun body(body: Body) = apply { this.body = body.toBuilder() } + fun body(body: CreateAccessTokenRequest) = apply { this.body = body.toBuilder() } + /** The authorization code received from the authorization server */ fun code(code: String) = apply { body.code(code) } /** @@ -138,6 +147,7 @@ private constructor( */ fun code(code: JsonField) = apply { body.code(code) } + /** The client ID for your application */ fun clientId(clientId: String) = apply { body.clientId(clientId) } /** @@ -148,6 +158,7 @@ private constructor( */ fun clientId(clientId: JsonField) = apply { body.clientId(clientId) } + /** The client secret for your application */ fun clientSecret(clientSecret: String) = apply { body.clientSecret(clientSecret) } /** @@ -161,6 +172,7 @@ private constructor( body.clientSecret(clientSecret) } + /** The redirect URI used in the authorization request (optional) */ fun redirectUri(redirectUri: String) = apply { body.redirectUri(redirectUri) } /** @@ -309,13 +321,14 @@ private constructor( ) } - fun _body(): Body = body + fun _body(): CreateAccessTokenRequest = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - class Body + class CreateAccessTokenRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val code: JsonField, private val clientId: JsonField, @@ -339,24 +352,32 @@ private constructor( ) : this(code, clientId, clientSecret, redirectUri, mutableMapOf()) /** + * The authorization code received from the authorization server + * * @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(): String = code.getRequired("code") /** + * The client ID for your application + * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun clientId(): Optional = clientId.getOptional("client_id") /** + * The client secret for your application + * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun clientSecret(): Optional = clientSecret.getOptional("client_secret") /** + * The redirect URI used in the authorization request (optional) + * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -410,7 +431,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Body]. + * Returns a mutable builder for constructing an instance of [CreateAccessTokenRequest]. * * The following fields are required: * ```java @@ -420,7 +441,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [Body]. */ + /** A builder for [CreateAccessTokenRequest]. */ class Builder internal constructor() { private var code: JsonField? = null @@ -430,14 +451,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - code = body.code - clientId = body.clientId - clientSecret = body.clientSecret - redirectUri = body.redirectUri - additionalProperties = body.additionalProperties.toMutableMap() + internal fun from(createAccessTokenRequest: CreateAccessTokenRequest) = apply { + code = createAccessTokenRequest.code + clientId = createAccessTokenRequest.clientId + clientSecret = createAccessTokenRequest.clientSecret + redirectUri = createAccessTokenRequest.redirectUri + additionalProperties = createAccessTokenRequest.additionalProperties.toMutableMap() } + /** The authorization code received from the authorization server */ fun code(code: String) = code(JsonField.of(code)) /** @@ -449,6 +471,7 @@ private constructor( */ fun code(code: JsonField) = apply { this.code = code } + /** The client ID for your application */ fun clientId(clientId: String) = clientId(JsonField.of(clientId)) /** @@ -460,6 +483,7 @@ private constructor( */ fun clientId(clientId: JsonField) = apply { this.clientId = clientId } + /** The client secret for your application */ fun clientSecret(clientSecret: String) = clientSecret(JsonField.of(clientSecret)) /** @@ -473,6 +497,7 @@ private constructor( this.clientSecret = clientSecret } + /** The redirect URI used in the authorization request (optional) */ fun redirectUri(redirectUri: String) = redirectUri(JsonField.of(redirectUri)) /** @@ -506,7 +531,7 @@ private constructor( } /** - * Returns an immutable instance of [Body]. + * Returns an immutable instance of [CreateAccessTokenRequest]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -517,8 +542,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): Body = - Body( + fun build(): CreateAccessTokenRequest = + CreateAccessTokenRequest( checkRequired("code", code), clientId, clientSecret, @@ -529,7 +554,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { + fun validate(): CreateAccessTokenRequest = apply { if (validated) { return@apply } @@ -567,7 +592,7 @@ private constructor( return true } - return other is Body && + return other is CreateAccessTokenRequest && code == other.code && clientId == other.clientId && clientSecret == other.clientSecret && @@ -582,7 +607,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{code=$code, clientId=$clientId, clientSecret=$clientSecret, redirectUri=$redirectUri, additionalProperties=$additionalProperties}" + "CreateAccessTokenRequest{code=$code, clientId=$clientId, clientSecret=$clientSecret, redirectUri=$redirectUri, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountCreateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountCreateResponse.kt index 053aae24..f74f28af 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountCreateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountCreateResponse.kt @@ -20,6 +20,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class AccountCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accessToken: JsonField, private val accountId: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateEvent.kt index cb5a9c86..1faf0298 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateEvent.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class AccountUpdateEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountId: JsonField, private val companyId: JsonField, @@ -324,6 +325,7 @@ private constructor( (eventType.asKnown().getOrNull()?.validity() ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val authenticationMethod: JsonField, private val status: JsonField, @@ -510,6 +512,7 @@ private constructor( (status.asKnown().getOrNull()?.validity() ?: 0) class AuthenticationMethod + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val benefitsSupport: JsonField, private val supportedFields: JsonField, @@ -746,6 +749,7 @@ private constructor( /** The supported data fields returned by our HR and payroll endpoints */ class SupportedFields + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val company: JsonField, private val directory: JsonField, @@ -1131,6 +1135,7 @@ private constructor( (payment.asKnown().getOrNull()?.validity() ?: 0) class SupportedCompanyFields + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val accounts: JsonField, @@ -1582,6 +1587,7 @@ private constructor( (if (primaryPhoneNumber.asKnown().isPresent) 1 else 0) class Accounts + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountName: JsonField, private val accountNumber: JsonField, @@ -1921,6 +1927,7 @@ private constructor( } class Departments + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val parent: JsonField, @@ -2090,6 +2097,7 @@ private constructor( (parent.asKnown().getOrNull()?.validity() ?: 0) class Parent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val additionalProperties: MutableMap, @@ -2267,6 +2275,7 @@ private constructor( } class Entity + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val subtype: JsonField, private val type: JsonField, @@ -2457,6 +2466,7 @@ private constructor( } class Locations + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val city: JsonField, private val country: JsonField, @@ -2850,6 +2860,7 @@ private constructor( } class SupportedDirectoryFields + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val individuals: JsonField, private val paging: JsonField, @@ -3029,6 +3040,7 @@ private constructor( (paging.asKnown().getOrNull()?.validity() ?: 0) class Individuals + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val department: JsonField, @@ -3405,6 +3417,7 @@ private constructor( (if (middleName.asKnown().isPresent) 1 else 0) class Manager + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, @@ -3594,6 +3607,7 @@ private constructor( } class Paging + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val count: JsonField, private val offset: JsonField, @@ -3805,6 +3819,7 @@ private constructor( } class SupportedEmploymentFields + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val classCode: JsonField, @@ -4567,6 +4582,7 @@ private constructor( (if (title.asKnown().isPresent) 1 else 0) class Department + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val additionalProperties: MutableMap, @@ -4720,6 +4736,7 @@ private constructor( } class Employment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val subtype: JsonField, private val type: JsonField, @@ -4912,6 +4929,7 @@ private constructor( } class Income + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val currency: JsonField, @@ -5138,6 +5156,7 @@ private constructor( } class Location + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val city: JsonField, private val country: JsonField, @@ -5491,6 +5510,7 @@ private constructor( } class Manager + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, @@ -5694,6 +5714,7 @@ private constructor( } class SupportedIndividualFields + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val dob: JsonField, @@ -6296,6 +6317,7 @@ private constructor( (if (ssn.asKnown().isPresent) 1 else 0) class Emails + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, private val type: JsonField, @@ -6482,6 +6504,7 @@ private constructor( } class PhoneNumbers + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, private val type: JsonField, @@ -6670,6 +6693,7 @@ private constructor( } class Residence + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val city: JsonField, private val country: JsonField, @@ -7071,6 +7095,7 @@ private constructor( } class SupportedPayGroupFields + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val individualIds: JsonField, @@ -7345,6 +7370,7 @@ private constructor( } class SupportedPayStatementFields + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val paging: JsonField, private val payStatements: JsonField, @@ -7525,6 +7551,7 @@ private constructor( (payStatements.asKnown().getOrNull()?.validity() ?: 0) class Paging + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val count: JsonField, private val offset: JsonField, @@ -7735,6 +7762,7 @@ private constructor( } class PayStatements + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val earnings: JsonField, private val employeeDeductions: JsonField, @@ -8239,6 +8267,7 @@ private constructor( (if (type.asKnown().isPresent) 1 else 0) class Earnings + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val currency: JsonField, @@ -8514,6 +8543,7 @@ private constructor( } class EmployeeDeductions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val currency: JsonField, @@ -8835,6 +8865,7 @@ private constructor( } class EmployerContributions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val currency: JsonField, @@ -9075,6 +9106,7 @@ private constructor( } class Taxes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val currency: JsonField, @@ -9457,6 +9489,7 @@ private constructor( } class SupportedPaymentFields + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val companyDebit: JsonField, @@ -10032,6 +10065,7 @@ private constructor( (payPeriod.asKnown().getOrNull()?.validity() ?: 0) class PayPeriod + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val endDate: JsonField, private val startDate: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateResponse.kt index 1a6dadca..d76a464b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateResponse.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class AccountUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountId: JsonField, private val authenticationType: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedAsyncJob.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedAsyncJob.kt index 00b3d3a8..cdcb6c77 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedAsyncJob.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedAsyncJob.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class AutomatedAsyncJob +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val completedAt: JsonField, private val createdAt: JsonField, @@ -499,6 +500,7 @@ private constructor( /** The input parameters for the job. */ class Params + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val individualId: JsonField, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedCreateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedCreateResponse.kt index 4d246ec3..a01a4d5c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedCreateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedCreateResponse.kt @@ -17,6 +17,7 @@ import java.util.Objects import java.util.Optional class AutomatedCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allowedRefreshes: JsonField, private val remainingRefreshes: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedListResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedListResponse.kt index 512ce448..b9a02fdc 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedListResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedListResponse.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class AutomatedListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, private val meta: JsonField, @@ -206,6 +207,7 @@ private constructor( (meta.asKnown().getOrNull()?.validity() ?: 0) class Meta + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val quotas: JsonField, private val additionalProperties: MutableMap, @@ -339,6 +341,7 @@ private constructor( * contact a Finch representative for more details. */ class Quotas + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dataSyncAll: JsonField, private val additionalProperties: MutableMap, @@ -469,6 +472,7 @@ private constructor( internal fun validity(): Int = (dataSyncAll.asKnown().getOrNull()?.validity() ?: 0) class DataSyncAll + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allowedRefreshes: JsonField, private val remainingRefreshes: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BaseWebhookEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BaseWebhookEvent.kt index 5b8d2c6d..a3c5d0cd 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BaseWebhookEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BaseWebhookEvent.kt @@ -17,6 +17,7 @@ import java.util.Objects import java.util.Optional class BaseWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountId: JsonField, private val companyId: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitContribution.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitContribution.kt index 17245a56..ad2b5911 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitContribution.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitContribution.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class BenefitContribution +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val type: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperations.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperations.kt index 8eca9722..665a11a5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperations.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperations.kt @@ -17,6 +17,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class BenefitFeaturesAndOperations +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val supportedFeatures: JsonField, private val supportedOperations: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitsSupport.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitsSupport.kt index bd48977c..afd9845f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitsSupport.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitsSupport.kt @@ -21,6 +21,7 @@ import kotlin.jvm.optionals.getOrNull * property will be null */ class BenefitsSupport +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val commuter: JsonField, private val customPostTax: JsonField, 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 e045475f..96420583 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 @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class Company +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val accounts: JsonField>, @@ -555,6 +556,7 @@ private constructor( (if (primaryPhoneNumber.asKnown().isPresent) 1 else 0) class Account + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountName: JsonField, private val accountNumber: JsonField, @@ -1070,6 +1072,7 @@ private constructor( } class Department + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val parent: JsonField, @@ -1255,6 +1258,7 @@ private constructor( /** The parent department, if present. */ class Parent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val additionalProperties: MutableMap, @@ -1436,6 +1440,7 @@ private constructor( /** The entity type object. */ class Entity + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val subtype: JsonField, private val type: JsonField, 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 34a008e9..911be02d 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 @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CompanyBenefit +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val benefitId: JsonField, private val description: JsonField, @@ -334,6 +335,7 @@ private constructor( /** The company match for this benefit. */ class BenefitCompanyMatchContribution + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val type: JsonField, @@ -523,6 +525,7 @@ private constructor( (type.asKnown().getOrNull()?.validity() ?: 0) class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val match: JsonField, private val threshold: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyEvent.kt index f5ac8559..e7b74a60 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyEvent.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CompanyEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountId: JsonField, private val companyId: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyUpdateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyUpdateResponse.kt index e2e427f3..96ed910c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyUpdateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyUpdateResponse.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CompanyUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accounts: JsonField>, private val departments: JsonField>, @@ -519,6 +520,7 @@ private constructor( (if (primaryPhoneNumber.asKnown().isPresent) 1 else 0) class Account + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountName: JsonField, private val accountNumber: JsonField, @@ -1012,6 +1014,7 @@ private constructor( } class Department + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val parent: JsonField, @@ -1176,6 +1179,7 @@ private constructor( /** The parent department, if present. */ class Parent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val additionalProperties: MutableMap, @@ -1342,6 +1346,7 @@ private constructor( /** The entity type object. */ class Entity + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val subtype: JsonField, private val type: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionNewParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionNewParams.kt index 7c557b64..70b0dc76 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionNewParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionNewParams.kt @@ -500,6 +500,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val customerId: JsonField, private val customerName: JsonField, @@ -1218,6 +1219,7 @@ private constructor( } class Integration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val authMethod: JsonField, private val provider: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionReauthenticateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionReauthenticateParams.kt index 8d695b3c..a13a3bdb 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionReauthenticateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionReauthenticateParams.kt @@ -367,6 +367,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val connectionId: JsonField, private val minutesToExpire: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectionCreateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectionCreateResponse.kt index 0049ee7b..b18e334d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectionCreateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectionCreateResponse.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class ConnectionCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accessToken: JsonField, private val accountId: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateAccessTokenResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateAccessTokenResponse.kt index 1815b149..33c41add 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateAccessTokenResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateAccessTokenResponse.kt @@ -21,17 +21,18 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class CreateAccessTokenResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accessToken: JsonField, - private val accountId: JsonField, private val clientType: JsonField, - private val companyId: JsonField, private val connectionId: JsonField, private val connectionType: JsonField, private val products: JsonField>, private val providerId: JsonField, - private val customerId: JsonField, private val tokenType: JsonField, + private val accountId: JsonField, + private val companyId: JsonField, + private val customerId: JsonField, private val additionalProperties: MutableMap, ) { @@ -40,11 +41,9 @@ private constructor( @JsonProperty("access_token") @ExcludeMissing accessToken: JsonField = JsonMissing.of(), - @JsonProperty("account_id") @ExcludeMissing accountId: JsonField = JsonMissing.of(), @JsonProperty("client_type") @ExcludeMissing clientType: JsonField = JsonMissing.of(), - @JsonProperty("company_id") @ExcludeMissing companyId: JsonField = JsonMissing.of(), @JsonProperty("connection_id") @ExcludeMissing connectionId: JsonField = JsonMissing.of(), @@ -57,26 +56,28 @@ private constructor( @JsonProperty("provider_id") @ExcludeMissing providerId: JsonField = JsonMissing.of(), + @JsonProperty("token_type") @ExcludeMissing tokenType: JsonField = JsonMissing.of(), + @JsonProperty("account_id") @ExcludeMissing accountId: JsonField = JsonMissing.of(), + @JsonProperty("company_id") @ExcludeMissing companyId: JsonField = JsonMissing.of(), @JsonProperty("customer_id") @ExcludeMissing customerId: JsonField = JsonMissing.of(), - @JsonProperty("token_type") @ExcludeMissing tokenType: JsonField = JsonMissing.of(), ) : this( accessToken, - accountId, clientType, - companyId, connectionId, connectionType, products, providerId, - customerId, tokenType, + accountId, + companyId, + customerId, mutableMapOf(), ) /** - * The access token for the connection. + * The access token for the connection * * @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). @@ -84,79 +85,81 @@ private constructor( fun accessToken(): String = accessToken.getRequired("access_token") /** - * [DEPRECATED] Use `connection_id` to identify the connection instead of this account ID. + * The type of application associated with a token. * * @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). */ - @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") + fun clientType(): ClientType = clientType.getRequired("client_type") /** - * The type of application associated with a token. + * The Finch UUID of the connection associated with the `access_token` * * @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 clientType(): ClientType = clientType.getRequired("client_type") + fun connectionId(): String = connectionId.getRequired("connection_id") /** - * [DEPRECATED] Use `connection_id` to identify the connection instead of this company ID. + * The type of the connection associated with the token. + * - `provider` - connection to an external provider + * - `finch` - finch-generated data. * * @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). */ - @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") + fun connectionType(): ConnectionType = connectionType.getRequired("connection_type") /** - * The Finch UUID of the connection associated with the `access_token`. + * An array of the authorized products associated with the `access_token` * * @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 connectionId(): String = connectionId.getRequired("connection_id") + fun products(): List = products.getRequired("products") /** - * The type of the connection associated with the token. - * - `provider` - connection to an external provider - * - `finch` - finch-generated data. + * The ID of the provider associated with the `access_token` * * @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 connectionType(): ConnectionType = connectionType.getRequired("connection_type") + fun providerId(): String = providerId.getRequired("provider_id") /** - * An array of the authorized products associated with the `access_token`. + * The RFC 8693 token type (Finch uses `bearer` tokens) * * @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 products(): List = products.getRequired("products") + fun tokenType(): String = tokenType.getRequired("token_type") /** - * The ID of the provider associated with the `access_token`. + * [DEPRECATED] Use `connection_id` to identify the connection instead of this account ID * - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun providerId(): String = providerId.getRequired("provider_id") + @Deprecated("deprecated") + fun accountId(): Optional = accountId.getOptional("account_id") /** - * The ID of your customer you provided to Finch when a connect session was created for this - * connection. + * [DEPRECATED] Use `connection_id` to identify the connection instead of this company ID * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun customerId(): Optional = customerId.getOptional("customer_id") + @Deprecated("deprecated") + fun companyId(): Optional = companyId.getOptional("company_id") /** - * The RFC 8693 token type (Finch uses `bearer` tokens) + * The ID of your customer you provided to Finch when a connect session was created for this + * connection * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun tokenType(): Optional = tokenType.getOptional("token_type") + fun customerId(): Optional = customerId.getOptional("customer_id") /** * Returns the raw JSON value of [accessToken]. @@ -167,16 +170,6 @@ private constructor( @ExcludeMissing fun _accessToken(): JsonField = accessToken - /** - * Returns the raw JSON value of [accountId]. - * - * Unlike [accountId], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("account_id") - @ExcludeMissing - fun _accountId(): JsonField = accountId - /** * Returns the raw JSON value of [clientType]. * @@ -186,16 +179,6 @@ private constructor( @ExcludeMissing fun _clientType(): JsonField = clientType - /** - * Returns the raw JSON value of [companyId]. - * - * Unlike [companyId], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("company_id") - @ExcludeMissing - fun _companyId(): JsonField = companyId - /** * Returns the raw JSON value of [connectionId]. * @@ -229,18 +212,38 @@ private constructor( @JsonProperty("provider_id") @ExcludeMissing fun _providerId(): JsonField = providerId /** - * Returns the raw JSON value of [customerId]. + * Returns the raw JSON value of [tokenType]. * - * Unlike [customerId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [tokenType], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField = customerId + @JsonProperty("token_type") @ExcludeMissing fun _tokenType(): JsonField = tokenType /** - * Returns the raw JSON value of [tokenType]. + * Returns the raw JSON value of [accountId]. * - * Unlike [tokenType], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [accountId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("token_type") @ExcludeMissing fun _tokenType(): JsonField = tokenType + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId + + /** + * Returns the raw JSON value of [companyId]. + * + * Unlike [companyId], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId + + /** + * Returns the raw JSON value of [customerId]. + * + * Unlike [customerId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField = customerId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -262,13 +265,12 @@ private constructor( * The following fields are required: * ```java * .accessToken() - * .accountId() * .clientType() - * .companyId() * .connectionId() * .connectionType() * .products() * .providerId() + * .tokenType() * ``` */ @JvmStatic fun builder() = Builder() @@ -278,33 +280,33 @@ private constructor( class Builder internal constructor() { private var accessToken: JsonField? = null - private var accountId: JsonField? = null private var clientType: JsonField? = null - private var companyId: JsonField? = null private var connectionId: JsonField? = null private var connectionType: JsonField? = null private var products: JsonField>? = null private var providerId: JsonField? = null + private var tokenType: JsonField? = null + private var accountId: JsonField = JsonMissing.of() + private var companyId: JsonField = JsonMissing.of() private var customerId: JsonField = JsonMissing.of() - private var tokenType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(createAccessTokenResponse: CreateAccessTokenResponse) = apply { accessToken = createAccessTokenResponse.accessToken - accountId = createAccessTokenResponse.accountId clientType = createAccessTokenResponse.clientType - companyId = createAccessTokenResponse.companyId connectionId = createAccessTokenResponse.connectionId connectionType = createAccessTokenResponse.connectionType products = createAccessTokenResponse.products.map { it.toMutableList() } providerId = createAccessTokenResponse.providerId - customerId = createAccessTokenResponse.customerId tokenType = createAccessTokenResponse.tokenType + accountId = createAccessTokenResponse.accountId + companyId = createAccessTokenResponse.companyId + customerId = createAccessTokenResponse.customerId additionalProperties = createAccessTokenResponse.additionalProperties.toMutableMap() } - /** The access token for the connection. */ + /** The access token for the connection */ fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken)) /** @@ -316,22 +318,6 @@ private constructor( */ fun accessToken(accessToken: JsonField) = apply { this.accessToken = accessToken } - /** - * [DEPRECATED] Use `connection_id` to identify the connection instead of this account ID. - */ - @Deprecated("deprecated") - fun accountId(accountId: String) = accountId(JsonField.of(accountId)) - - /** - * Sets [Builder.accountId] to an arbitrary JSON value. - * - * You should usually call [Builder.accountId] 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 accountId(accountId: JsonField) = apply { this.accountId = accountId } - /** The type of application associated with a token. */ fun clientType(clientType: ClientType) = clientType(JsonField.of(clientType)) @@ -344,23 +330,7 @@ private constructor( */ fun clientType(clientType: JsonField) = apply { this.clientType = clientType } - /** - * [DEPRECATED] Use `connection_id` to identify the connection instead of this company ID. - */ - @Deprecated("deprecated") - fun companyId(companyId: String) = companyId(JsonField.of(companyId)) - - /** - * Sets [Builder.companyId] to an arbitrary JSON value. - * - * You should usually call [Builder.companyId] 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 companyId(companyId: JsonField) = apply { this.companyId = companyId } - - /** The Finch UUID of the connection associated with the `access_token`. */ + /** The Finch UUID of the connection associated with the `access_token` */ fun connectionId(connectionId: String) = connectionId(JsonField.of(connectionId)) /** @@ -393,7 +363,7 @@ private constructor( this.connectionType = connectionType } - /** An array of the authorized products associated with the `access_token`. */ + /** An array of the authorized products associated with the `access_token` */ fun products(products: List) = products(JsonField.of(products)) /** @@ -419,7 +389,7 @@ private constructor( } } - /** The ID of the provider associated with the `access_token`. */ + /** The ID of the provider associated with the `access_token` */ fun providerId(providerId: String) = providerId(JsonField.of(providerId)) /** @@ -431,35 +401,67 @@ private constructor( */ fun providerId(providerId: JsonField) = apply { this.providerId = providerId } + /** The RFC 8693 token type (Finch uses `bearer` tokens) */ + fun tokenType(tokenType: String) = tokenType(JsonField.of(tokenType)) + /** - * The ID of your customer you provided to Finch when a connect session was created for this - * connection. + * Sets [Builder.tokenType] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenType] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) + fun tokenType(tokenType: JsonField) = apply { this.tokenType = tokenType } - /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ - fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) + /** + * [DEPRECATED] Use `connection_id` to identify the connection instead of this account ID + */ + @Deprecated("deprecated") + fun accountId(accountId: String) = accountId(JsonField.of(accountId)) /** - * Sets [Builder.customerId] to an arbitrary JSON value. + * Sets [Builder.accountId] to an arbitrary JSON value. * - * You should usually call [Builder.customerId] with a well-typed [String] value instead. + * You should usually call [Builder.accountId] with a well-typed [String] value instead. * This method is primarily for setting the field to an undocumented or not yet supported * value. */ - fun customerId(customerId: JsonField) = apply { this.customerId = customerId } + @Deprecated("deprecated") + fun accountId(accountId: JsonField) = apply { this.accountId = accountId } - /** The RFC 8693 token type (Finch uses `bearer` tokens) */ - fun tokenType(tokenType: String) = tokenType(JsonField.of(tokenType)) + /** + * [DEPRECATED] Use `connection_id` to identify the connection instead of this company ID + */ + @Deprecated("deprecated") + fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** - * Sets [Builder.tokenType] to an arbitrary JSON value. + * Sets [Builder.companyId] to an arbitrary JSON value. * - * You should usually call [Builder.tokenType] with a well-typed [String] value instead. + * You should usually call [Builder.companyId] with a well-typed [String] value instead. * This method is primarily for setting the field to an undocumented or not yet supported * value. */ - fun tokenType(tokenType: JsonField) = apply { this.tokenType = tokenType } + @Deprecated("deprecated") + fun companyId(companyId: JsonField) = apply { this.companyId = companyId } + + /** + * The ID of your customer you provided to Finch when a connect session was created for this + * connection + */ + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) + + /** + * Sets [Builder.customerId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun customerId(customerId: JsonField) = apply { this.customerId = customerId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -488,13 +490,12 @@ private constructor( * The following fields are required: * ```java * .accessToken() - * .accountId() * .clientType() - * .companyId() * .connectionId() * .connectionType() * .products() * .providerId() + * .tokenType() * ``` * * @throws IllegalStateException if any required field is unset. @@ -502,15 +503,15 @@ private constructor( fun build(): CreateAccessTokenResponse = CreateAccessTokenResponse( checkRequired("accessToken", accessToken), - checkRequired("accountId", accountId), checkRequired("clientType", clientType), - checkRequired("companyId", companyId), checkRequired("connectionId", connectionId), checkRequired("connectionType", connectionType), checkRequired("products", products).map { it.toImmutable() }, checkRequired("providerId", providerId), + checkRequired("tokenType", tokenType), + accountId, + companyId, customerId, - tokenType, additionalProperties.toMutableMap(), ) } @@ -523,15 +524,15 @@ private constructor( } accessToken() - accountId() clientType().validate() - companyId() connectionId() connectionType().validate() products() providerId() - customerId() tokenType() + accountId() + companyId() + customerId() validated = true } @@ -551,15 +552,15 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (accessToken.asKnown().isPresent) 1 else 0) + - (if (accountId.asKnown().isPresent) 1 else 0) + (clientType.asKnown().getOrNull()?.validity() ?: 0) + - (if (companyId.asKnown().isPresent) 1 else 0) + (if (connectionId.asKnown().isPresent) 1 else 0) + (connectionType.asKnown().getOrNull()?.validity() ?: 0) + (products.asKnown().getOrNull()?.size ?: 0) + (if (providerId.asKnown().isPresent) 1 else 0) + - (if (customerId.asKnown().isPresent) 1 else 0) + - (if (tokenType.asKnown().isPresent) 1 else 0) + (if (tokenType.asKnown().isPresent) 1 else 0) + + (if (accountId.asKnown().isPresent) 1 else 0) + + (if (companyId.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) /** The type of application associated with a token. */ class ClientType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -576,10 +577,10 @@ private constructor( companion object { - @JvmField val PRODUCTION = of("production") - @JvmField val DEVELOPMENT = of("development") + @JvmField val PRODUCTION = of("production") + @JvmField val SANDBOX = of("sandbox") @JvmStatic fun of(value: String) = ClientType(JsonField.of(value)) @@ -587,8 +588,8 @@ private constructor( /** An enum containing [ClientType]'s known values. */ enum class Known { - PRODUCTION, DEVELOPMENT, + PRODUCTION, SANDBOX, } @@ -602,8 +603,8 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - PRODUCTION, DEVELOPMENT, + PRODUCTION, SANDBOX, /** * An enum member indicating that [ClientType] was instantiated with an unknown value. @@ -620,8 +621,8 @@ private constructor( */ fun value(): Value = when (this) { - PRODUCTION -> Value.PRODUCTION DEVELOPMENT -> Value.DEVELOPMENT + PRODUCTION -> Value.PRODUCTION SANDBOX -> Value.SANDBOX else -> Value._UNKNOWN } @@ -636,8 +637,8 @@ private constructor( */ fun known(): Known = when (this) { - PRODUCTION -> Known.PRODUCTION DEVELOPMENT -> Known.DEVELOPMENT + PRODUCTION -> Known.PRODUCTION SANDBOX -> Known.SANDBOX else -> throw FinchInvalidDataException("Unknown ClientType: $value") } @@ -714,17 +715,17 @@ private constructor( companion object { - @JvmField val PROVIDER = of("provider") - @JvmField val FINCH = of("finch") + @JvmField val PROVIDER = of("provider") + @JvmStatic fun of(value: String) = ConnectionType(JsonField.of(value)) } /** An enum containing [ConnectionType]'s known values. */ enum class Known { - PROVIDER, FINCH, + PROVIDER, } /** @@ -737,8 +738,8 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - PROVIDER, FINCH, + PROVIDER, /** * An enum member indicating that [ConnectionType] was instantiated with an unknown * value. @@ -755,8 +756,8 @@ private constructor( */ fun value(): Value = when (this) { - PROVIDER -> Value.PROVIDER FINCH -> Value.FINCH + PROVIDER -> Value.PROVIDER else -> Value._UNKNOWN } @@ -770,8 +771,8 @@ private constructor( */ fun known(): Known = when (this) { - PROVIDER -> Known.PROVIDER FINCH -> Known.FINCH + PROVIDER -> Known.PROVIDER else -> throw FinchInvalidDataException("Unknown ConnectionType: $value") } @@ -834,30 +835,30 @@ private constructor( return other is CreateAccessTokenResponse && accessToken == other.accessToken && - accountId == other.accountId && clientType == other.clientType && - companyId == other.companyId && connectionId == other.connectionId && connectionType == other.connectionType && products == other.products && providerId == other.providerId && - customerId == other.customerId && tokenType == other.tokenType && + accountId == other.accountId && + companyId == other.companyId && + customerId == other.customerId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( accessToken, - accountId, clientType, - companyId, connectionId, connectionType, products, providerId, - customerId, tokenType, + accountId, + companyId, + customerId, additionalProperties, ) } @@ -865,5 +866,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CreateAccessTokenResponse{accessToken=$accessToken, accountId=$accountId, clientType=$clientType, companyId=$companyId, connectionId=$connectionId, connectionType=$connectionType, products=$products, providerId=$providerId, customerId=$customerId, tokenType=$tokenType, additionalProperties=$additionalProperties}" + "CreateAccessTokenResponse{accessToken=$accessToken, clientType=$clientType, connectionId=$connectionId, connectionType=$connectionType, products=$products, providerId=$providerId, tokenType=$tokenType, accountId=$accountId, companyId=$companyId, customerId=$customerId, additionalProperties=$additionalProperties}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateCompanyBenefitsResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateCompanyBenefitsResponse.kt index 7a86b89a..5e4f0d48 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateCompanyBenefitsResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateCompanyBenefitsResponse.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class CreateCompanyBenefitsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val benefitId: JsonField, private val jobId: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryCreateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryCreateResponse.kt index 0a8f737b..f5c0cf3c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryCreateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryCreateResponse.kt @@ -12,6 +12,7 @@ import java.util.Collections import java.util.Objects class DirectoryCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor(private val additionalProperties: MutableMap) { @JsonCreator private constructor() : this(mutableMapOf()) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryEvent.kt index 352176bc..66fa1cc2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryEvent.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class DirectoryEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountId: JsonField, private val companyId: JsonField, @@ -324,6 +325,7 @@ private constructor( (eventType.asKnown().getOrNull()?.validity() ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val individualId: JsonField, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DisconnectResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DisconnectResponse.kt index 4f5ae616..4115c896 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DisconnectResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DisconnectResponse.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class DisconnectResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val status: JsonField, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentListResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentListResponse.kt index 2fbb4668..a4d67b18 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentListResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentListResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class DocumentListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val documents: JsonField>, private val paging: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentResponse.kt index cb4e0b34..7e702560 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentResponse.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 @@ -18,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class DocumentResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val individualId: JsonField, @@ -41,10 +43,10 @@ private constructor( /** * A stable Finch id for the document. * - * @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 ID of the individual associated with the document. This will be null for employer-level @@ -58,27 +60,27 @@ private constructor( /** * The type of document. * - * @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 type(): Optional = type.getOptional("type") + fun type(): Type = type.getRequired("type") /** * A URL to access the document. Format: * `https://api.tryfinch.com/employer/documents/:document_id`. * - * @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 url(): Optional = url.getOptional("url") + fun url(): String = url.getRequired("url") /** * The year the document applies to, if available. * - * @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 year(): Optional = year.getOptional("year") + fun year(): Double = year.getRequired("year") /** * Returns the raw JSON value of [id]. @@ -131,18 +133,29 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [DocumentResponse]. */ + /** + * Returns a mutable builder for constructing an instance of [DocumentResponse]. + * + * The following fields are required: + * ```java + * .id() + * .individualId() + * .type() + * .url() + * .year() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [DocumentResponse]. */ class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var individualId: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var individualId: JsonField? = null + private var type: JsonField? = null + private var url: JsonField? = null + private var year: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -212,17 +225,7 @@ private constructor( fun url(url: JsonField) = apply { this.url = url } /** The year the document applies to, if available. */ - fun year(year: Double?) = year(JsonField.ofNullable(year)) - - /** - * Alias for [Builder.year]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun year(year: Double) = year(year as Double?) - - /** Alias for calling [Builder.year] with `year.orElse(null)`. */ - fun year(year: Optional) = year(year.getOrNull()) + fun year(year: Double) = year(JsonField.of(year)) /** * Sets [Builder.year] to an arbitrary JSON value. @@ -255,9 +258,27 @@ private constructor( * Returns an immutable instance of [DocumentResponse]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .individualId() + * .type() + * .url() + * .year() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): DocumentResponse = - DocumentResponse(id, individualId, type, url, year, additionalProperties.toMutableMap()) + DocumentResponse( + checkRequired("id", id), + checkRequired("individualId", individualId), + checkRequired("type", type), + checkRequired("url", url), + checkRequired("year", year), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -269,7 +290,7 @@ private constructor( id() individualId() - type().ifPresent { it.validate() } + type().validate() url() year() validated = true 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 de4b32f7..f8365f31 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 @@ -206,6 +206,7 @@ private constructor( } class UnionMember0 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val classCode: JsonField, @@ -1214,6 +1215,7 @@ private constructor( /** The department object. */ class Department + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val additionalProperties: MutableMap, @@ -1376,6 +1378,7 @@ private constructor( /** The employment object. */ class Employment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val subtype: JsonField, private val type: JsonField, @@ -2046,6 +2049,7 @@ private constructor( /** The manager object representing the manager of the individual within the org. */ class Manager + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, @@ -2204,6 +2208,7 @@ private constructor( } class CustomField + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val value: JsonField, @@ -2702,6 +2707,7 @@ private constructor( } class BatchError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val code: JsonField, private val message: JsonField, 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 9377fbd7..1c125044 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 @@ -17,6 +17,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class EmploymentDataResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val body: JsonField, private val code: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentEvent.kt index 2c8835dc..b09dd927 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentEvent.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class EmploymentEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountId: JsonField, private val companyId: JsonField, @@ -324,6 +325,7 @@ private constructor( (eventType.asKnown().getOrNull()?.validity() ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val individualId: JsonField, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentUpdateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentUpdateResponse.kt index 8ffeb93d..2c4adaad 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentUpdateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentUpdateResponse.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class EmploymentUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val classCode: JsonField, @@ -905,6 +906,7 @@ private constructor( (if (title.asKnown().isPresent) 1 else 0) class CustomField + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val value: JsonValue, @@ -1055,6 +1057,7 @@ private constructor( /** The department object. */ class Department + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val additionalProperties: MutableMap, @@ -1199,6 +1202,7 @@ private constructor( /** The employment object. */ class Employment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val subtype: JsonField, private val type: JsonField, @@ -1834,6 +1838,7 @@ private constructor( /** The manager object representing the manager of the individual within the org. */ class Manager + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponse.kt index 545ee234..145930fb 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponse.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class EnrolledIndividualBenefitResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val jobId: JsonField, private val additionalProperties: MutableMap, 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 7de25e89..add092aa 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 @@ -347,6 +347,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val companyContribution: JsonField, private val description: JsonField, @@ -642,6 +643,7 @@ private constructor( /** The company match for this benefit. */ class BenefitCompanyMatchContribution + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val tiers: JsonField>, private val type: JsonField, @@ -831,6 +833,7 @@ private constructor( (type.asKnown().getOrNull()?.validity() ?: 0) class Tier + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val match: JsonField, private val threshold: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyParams.kt index 275d6e6e..9709e6c3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyParams.kt @@ -267,6 +267,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val individualIds: JsonField>, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitUpdateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitUpdateParams.kt index 4467dc6c..8ce56a10 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitUpdateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitUpdateParams.kt @@ -249,6 +249,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val description: JsonField, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponse.kt index 553caea4..73349505 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class HrisCompanyPayStatementItemListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val responses: JsonField>, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleCreateParams.kt index 27d4947d..e7e95e2d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleCreateParams.kt @@ -387,6 +387,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class CreateRuleRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val attributes: JsonField, private val conditions: JsonField>, @@ -748,6 +749,7 @@ private constructor( /** Specifies the fields to be applied when the condition is met. */ class Attributes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val metadata: JsonField, private val additionalProperties: MutableMap, @@ -1001,6 +1003,7 @@ private constructor( } class Condition + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val field: JsonField, private val operator: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageResponse.kt index ede28f61..0c2ad095 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class HrisCompanyPayStatementItemRuleListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val responses: JsonField>, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleUpdateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleUpdateParams.kt index 445daa28..d47f814a 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleUpdateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleUpdateParams.kt @@ -237,6 +237,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class UpdateRuleRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val optionalProperty: JsonValue, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponse.kt index 6b2a3b03..f8b75a64 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class HrisDirectoryListIndividualsPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val individuals: JsonField>, private val paging: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponse.kt index af7df61a..6371534c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class HrisDirectoryListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val individuals: JsonField>, private val paging: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponse.kt index ec1d9609..60b69820 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class HrisEmploymentRetrieveManyPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val responses: JsonField>, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyParams.kt index 3d62def4..35a51d61 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyParams.kt @@ -257,6 +257,7 @@ private constructor( /** Individual Ids Request Body */ class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val requests: JsonField>, private val additionalProperties: MutableMap, @@ -435,6 +436,7 @@ private constructor( } class Request + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val individualId: JsonField, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponse.kt index 2cbae8fb..19a231b8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class HrisIndividualRetrieveManyPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val responses: JsonField>, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyParams.kt index bff72033..d908df87 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyParams.kt @@ -270,6 +270,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val options: JsonField, private val requests: JsonField>, @@ -466,6 +467,7 @@ private constructor( } class Options + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val include: JsonField>, private val additionalProperties: MutableMap, @@ -623,6 +625,7 @@ private constructor( } class Request + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val individualId: JsonField, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponse.kt index 38881bd8..2825d346 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class HrisPayStatementRetrieveManyPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val responses: JsonField>, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyParams.kt index 96ae877e..fd72512b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyParams.kt @@ -261,6 +261,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val requests: JsonField>, private val additionalProperties: MutableMap, @@ -439,6 +440,7 @@ private constructor( } class Request + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val paymentId: JsonField, private val limit: JsonField, 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 2e011a1b..0e9abdc2 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 @@ -25,6 +25,7 @@ import kotlin.jvm.optionals.getOrNull * provider returns. */ class Income +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val currency: JsonField, 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 d5f4f5a8..c9ee65cf 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 @@ -202,6 +202,7 @@ private constructor( } class UnionMember0 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val dob: JsonField, @@ -1202,6 +1203,7 @@ private constructor( } class PhoneNumber + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, private val type: JsonField, @@ -1532,6 +1534,7 @@ private constructor( } class Email + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, private val type: JsonField, @@ -1907,6 +1910,7 @@ private constructor( } class BatchError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val code: JsonField, private val message: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualBenefit.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualBenefit.kt index 7dd74a4c..f9816cbc 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualBenefit.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualBenefit.kt @@ -30,6 +30,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class IndividualBenefit +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val body: JsonField, private val code: JsonField, @@ -417,6 +418,7 @@ private constructor( } class UnionMember0 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val annualMaximum: JsonField, private val catchUp: JsonField, @@ -959,6 +961,7 @@ private constructor( } class BatchError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val code: JsonField, private val message: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEnrolledIdsResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEnrolledIdsResponse.kt index 1c36e8b8..ddac4d7d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEnrolledIdsResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEnrolledIdsResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class IndividualEnrolledIdsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val benefitId: JsonField, private val individualIds: JsonField>, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEvent.kt index bc19e6e2..ef09dcaa 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEvent.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class IndividualEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountId: JsonField, private val companyId: JsonField, @@ -324,6 +325,7 @@ private constructor( (eventType.asKnown().getOrNull()?.validity() ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val individualId: JsonField, private val additionalProperties: MutableMap, 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 32c1178b..a58d43d9 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 @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class IndividualInDirectory +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val department: JsonField, @@ -404,6 +405,7 @@ private constructor( /** The department object. */ class Department + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val additionalProperties: MutableMap, @@ -548,6 +550,7 @@ private constructor( /** The manager object. */ class Manager + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, 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 f163f91a..772b0bda 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 @@ -17,6 +17,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class IndividualResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val body: JsonField, private val code: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUpdateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUpdateResponse.kt index 4c8a0f90..216506ec 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUpdateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUpdateResponse.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class IndividualUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val dob: JsonField, @@ -655,6 +656,7 @@ private constructor( (if (ssn.asKnown().isPresent) 1 else 0) class Email + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, private val type: JsonField, @@ -1255,6 +1257,7 @@ private constructor( } class PhoneNumber + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, private val type: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Introspection.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Introspection.kt index 104f3045..02163ef2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Introspection.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Introspection.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.time.OffsetDateTime @@ -22,23 +33,24 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class Introspection +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, - private val accountId: JsonField, - private val authenticationMethods: JsonField>, private val clientId: JsonField, private val clientType: JsonField, - private val companyId: JsonField, private val connectionId: JsonField, - private val connectionStatus: JsonField, + private val connectionStatus: JsonField, private val connectionType: JsonField, + private val products: JsonField>, + private val providerId: JsonField, + private val accountId: JsonField, + private val authenticationMethods: JsonField>, + private val companyId: JsonField, private val customerEmail: JsonField, private val customerId: JsonField, private val customerName: JsonField, private val manual: JsonField, private val payrollProviderId: JsonField, - private val products: JsonField>, - private val providerId: JsonField, private val username: JsonField, private val additionalProperties: MutableMap, ) { @@ -46,24 +58,30 @@ private constructor( @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("account_id") @ExcludeMissing accountId: JsonField = JsonMissing.of(), - @JsonProperty("authentication_methods") - @ExcludeMissing - authenticationMethods: JsonField> = JsonMissing.of(), @JsonProperty("client_id") @ExcludeMissing clientId: JsonField = JsonMissing.of(), @JsonProperty("client_type") @ExcludeMissing clientType: JsonField = JsonMissing.of(), - @JsonProperty("company_id") @ExcludeMissing companyId: JsonField = JsonMissing.of(), @JsonProperty("connection_id") @ExcludeMissing connectionId: JsonField = JsonMissing.of(), @JsonProperty("connection_status") @ExcludeMissing - connectionStatus: JsonField = JsonMissing.of(), + connectionStatus: JsonField = JsonMissing.of(), @JsonProperty("connection_type") @ExcludeMissing connectionType: JsonField = JsonMissing.of(), + @JsonProperty("products") + @ExcludeMissing + products: JsonField> = JsonMissing.of(), + @JsonProperty("provider_id") + @ExcludeMissing + providerId: JsonField = JsonMissing.of(), + @JsonProperty("account_id") @ExcludeMissing accountId: JsonField = JsonMissing.of(), + @JsonProperty("authentication_methods") + @ExcludeMissing + authenticationMethods: JsonField> = JsonMissing.of(), + @JsonProperty("company_id") @ExcludeMissing companyId: JsonField = JsonMissing.of(), @JsonProperty("customer_email") @ExcludeMissing customerEmail: JsonField = JsonMissing.of(), @@ -77,36 +95,30 @@ private constructor( @JsonProperty("payroll_provider_id") @ExcludeMissing payrollProviderId: JsonField = JsonMissing.of(), - @JsonProperty("products") - @ExcludeMissing - products: JsonField> = JsonMissing.of(), - @JsonProperty("provider_id") - @ExcludeMissing - providerId: JsonField = JsonMissing.of(), @JsonProperty("username") @ExcludeMissing username: JsonField = JsonMissing.of(), ) : this( id, - accountId, - authenticationMethods, clientId, clientType, - companyId, connectionId, connectionStatus, connectionType, + products, + providerId, + accountId, + authenticationMethods, + companyId, customerEmail, customerId, customerName, manual, payrollProviderId, - products, - providerId, username, mutableMapOf(), ) /** - * The Finch UUID of the token being introspected. + * The Finch UUID of the token being introspected * * @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). @@ -114,73 +126,92 @@ private constructor( fun id(): String = id.getRequired("id") /** - * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of this - * account ID. + * The client ID of the application associated with the `access_token` * * @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). */ - @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") + fun clientId(): String = clientId.getRequired("client_id") /** + * The type of application associated with a token. + * * @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 authenticationMethods(): List = - authenticationMethods.getRequired("authentication_methods") + fun clientType(): ClientType = clientType.getRequired("client_type") /** - * The client ID of the application associated with the `access_token`. + * The Finch UUID of the connection associated with the `access_token` * * @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 clientId(): String = clientId.getRequired("client_id") + fun connectionId(): String = connectionId.getRequired("connection_id") /** - * The type of application associated with a token. - * * @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 clientType(): ClientType = clientType.getRequired("client_type") + fun connectionStatus(): ConnectionStatusDetail = + connectionStatus.getRequired("connection_status") /** - * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of this - * company ID. + * The type of the connection associated with the token. + * - `provider` - connection to an external provider + * - `finch` - finch-generated data. * * @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). */ - @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") + fun connectionType(): ConnectionType = connectionType.getRequired("connection_type") /** - * The Finch UUID of the connection associated with the `access_token`. + * An array of the authorized products associated with the `access_token`. * * @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 connectionId(): String = connectionId.getRequired("connection_id") + fun products(): List = products.getRequired("products") /** + * The ID of the provider associated with the `access_token`. + * * @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 connectionStatus(): ConnectionStatus = connectionStatus.getRequired("connection_status") + fun providerId(): String = providerId.getRequired("provider_id") /** - * The type of the connection associated with the token. - * - `provider` - connection to an external provider - * - `finch` - finch-generated data. + * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of this + * account ID * - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun connectionType(): ConnectionType = connectionType.getRequired("connection_type") + @Deprecated("deprecated") + fun accountId(): Optional = accountId.getOptional("account_id") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun authenticationMethods(): Optional> = + authenticationMethods.getOptional("authentication_methods") + + /** + * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of this + * company ID + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun companyId(): Optional = companyId.getOptional("company_id") /** * The email of your customer you provided to Finch when a connect session was created for this - * connection. + * connection * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -189,7 +220,7 @@ private constructor( /** * The ID of your customer you provided to Finch when a connect session was created for this - * connection. + * connection * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -198,7 +229,7 @@ private constructor( /** * The name of your customer you provided to Finch when a connect session was created for this - * connection. + * connection * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -209,43 +240,27 @@ private constructor( * Whether the connection associated with the `access_token` uses the Assisted Connect Flow. * (`true` if using Assisted Connect, `false` if connection is automated) * - * @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). + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun manual(): Boolean = manual.getRequired("manual") + fun manual(): Optional = manual.getOptional("manual") /** * [DEPRECATED] Use `provider_id` to identify the provider instead of this payroll provider ID. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly - * missing or null (e.g. if the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ @Deprecated("deprecated") - fun payrollProviderId(): String = payrollProviderId.getRequired("payroll_provider_id") - - /** - * An array of the authorized products associated with the `access_token`. - * - * @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 products(): List = products.getRequired("products") - - /** - * The ID of the provider associated with the `access_token`. - * - * @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 providerId(): String = providerId.getRequired("provider_id") + fun payrollProviderId(): Optional = payrollProviderId.getOptional("payroll_provider_id") /** * The account username used for login associated with the `access_token`. * - * @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). + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun username(): String = username.getRequired("username") + fun username(): Optional = username.getOptional("username") /** * Returns the raw JSON value of [id]. @@ -254,26 +269,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [accountId]. - * - * Unlike [accountId], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("account_id") - @ExcludeMissing - fun _accountId(): JsonField = accountId - - /** - * Returns the raw JSON value of [authenticationMethods]. - * - * Unlike [authenticationMethods], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("authentication_methods") - @ExcludeMissing - fun _authenticationMethods(): JsonField> = authenticationMethods - /** * Returns the raw JSON value of [clientId]. * @@ -290,16 +285,6 @@ private constructor( @ExcludeMissing fun _clientType(): JsonField = clientType - /** - * Returns the raw JSON value of [companyId]. - * - * Unlike [companyId], this method doesn't throw if the JSON field has an unexpected type. - */ - @Deprecated("deprecated") - @JsonProperty("company_id") - @ExcludeMissing - fun _companyId(): JsonField = companyId - /** * Returns the raw JSON value of [connectionId]. * @@ -317,7 +302,7 @@ private constructor( */ @JsonProperty("connection_status") @ExcludeMissing - fun _connectionStatus(): JsonField = connectionStatus + fun _connectionStatus(): JsonField = connectionStatus /** * Returns the raw JSON value of [connectionType]. @@ -328,6 +313,51 @@ private constructor( @ExcludeMissing fun _connectionType(): JsonField = connectionType + /** + * Returns the raw JSON value of [products]. + * + * Unlike [products], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("products") @ExcludeMissing fun _products(): JsonField> = products + + /** + * Returns the raw JSON value of [providerId]. + * + * Unlike [providerId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("provider_id") @ExcludeMissing fun _providerId(): JsonField = providerId + + /** + * Returns the raw JSON value of [accountId]. + * + * Unlike [accountId], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId + + /** + * Returns the raw JSON value of [authenticationMethods]. + * + * Unlike [authenticationMethods], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authentication_methods") + @ExcludeMissing + fun _authenticationMethods(): JsonField> = + authenticationMethods + + /** + * Returns the raw JSON value of [companyId]. + * + * Unlike [companyId], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId + /** * Returns the raw JSON value of [customerEmail]. * @@ -371,20 +401,6 @@ private constructor( @ExcludeMissing fun _payrollProviderId(): JsonField = payrollProviderId - /** - * Returns the raw JSON value of [products]. - * - * Unlike [products], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("products") @ExcludeMissing fun _products(): JsonField> = products - - /** - * Returns the raw JSON value of [providerId]. - * - * Unlike [providerId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("provider_id") @ExcludeMissing fun _providerId(): JsonField = providerId - /** * Returns the raw JSON value of [username]. * @@ -412,22 +428,13 @@ private constructor( * The following fields are required: * ```java * .id() - * .accountId() - * .authenticationMethods() * .clientId() * .clientType() - * .companyId() * .connectionId() * .connectionStatus() * .connectionType() - * .customerEmail() - * .customerId() - * .customerName() - * .manual() - * .payrollProviderId() * .products() * .providerId() - * .username() * ``` */ @JvmStatic fun builder() = Builder() @@ -437,47 +444,48 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null - private var accountId: JsonField? = null - private var authenticationMethods: JsonField>? = null private var clientId: JsonField? = null private var clientType: JsonField? = null - private var companyId: JsonField? = null private var connectionId: JsonField? = null - private var connectionStatus: JsonField? = null + private var connectionStatus: JsonField? = null private var connectionType: JsonField? = null - private var customerEmail: JsonField? = null - private var customerId: JsonField? = null - private var customerName: JsonField? = null - private var manual: JsonField? = null - private var payrollProviderId: JsonField? = null private var products: JsonField>? = null private var providerId: JsonField? = null - private var username: JsonField? = null + private var accountId: JsonField = JsonMissing.of() + private var authenticationMethods: JsonField>? = + null + private var companyId: JsonField = JsonMissing.of() + private var customerEmail: JsonField = JsonMissing.of() + private var customerId: JsonField = JsonMissing.of() + private var customerName: JsonField = JsonMissing.of() + private var manual: JsonField = JsonMissing.of() + private var payrollProviderId: JsonField = JsonMissing.of() + private var username: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(introspection: Introspection) = apply { id = introspection.id - accountId = introspection.accountId - authenticationMethods = introspection.authenticationMethods.map { it.toMutableList() } clientId = introspection.clientId clientType = introspection.clientType - companyId = introspection.companyId connectionId = introspection.connectionId connectionStatus = introspection.connectionStatus connectionType = introspection.connectionType + products = introspection.products.map { it.toMutableList() } + providerId = introspection.providerId + accountId = introspection.accountId + authenticationMethods = introspection.authenticationMethods.map { it.toMutableList() } + companyId = introspection.companyId customerEmail = introspection.customerEmail customerId = introspection.customerId customerName = introspection.customerName manual = introspection.manual payrollProviderId = introspection.payrollProviderId - products = introspection.products.map { it.toMutableList() } - providerId = introspection.providerId username = introspection.username additionalProperties = introspection.additionalProperties.toMutableMap() } - /** The Finch UUID of the token being introspected. */ + /** The Finch UUID of the token being introspected */ fun id(id: String) = id(JsonField.of(id)) /** @@ -488,51 +496,7 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - /** - * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of - * this account ID. - */ - @Deprecated("deprecated") - fun accountId(accountId: String) = accountId(JsonField.of(accountId)) - - /** - * Sets [Builder.accountId] to an arbitrary JSON value. - * - * You should usually call [Builder.accountId] 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 accountId(accountId: JsonField) = apply { this.accountId = accountId } - - fun authenticationMethods(authenticationMethods: List) = - authenticationMethods(JsonField.of(authenticationMethods)) - - /** - * Sets [Builder.authenticationMethods] to an arbitrary JSON value. - * - * You should usually call [Builder.authenticationMethods] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun authenticationMethods(authenticationMethods: JsonField>) = - apply { - this.authenticationMethods = authenticationMethods.map { it.toMutableList() } - } - - /** - * Adds a single [AuthenticationMethod] to [authenticationMethods]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addAuthenticationMethod(authenticationMethod: AuthenticationMethod) = apply { - authenticationMethods = - (authenticationMethods ?: JsonField.of(mutableListOf())).also { - checkKnown("authenticationMethods", it).add(authenticationMethod) - } - } - - /** The client ID of the application associated with the `access_token`. */ + /** The client ID of the application associated with the `access_token` */ fun clientId(clientId: String) = clientId(JsonField.of(clientId)) /** @@ -555,48 +519,31 @@ private constructor( */ fun clientType(clientType: JsonField) = apply { this.clientType = clientType } - /** - * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of - * this company ID. - */ - @Deprecated("deprecated") - fun companyId(companyId: String) = companyId(JsonField.of(companyId)) + /** The Finch UUID of the connection associated with the `access_token` */ + fun connectionId(connectionId: String) = connectionId(JsonField.of(connectionId)) /** - * Sets [Builder.companyId] to an arbitrary JSON value. + * Sets [Builder.connectionId] to an arbitrary JSON value. * - * You should usually call [Builder.companyId] with a well-typed [String] value instead. + * You should usually call [Builder.connectionId] 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 companyId(companyId: JsonField) = apply { this.companyId = companyId } + fun connectionId(connectionId: JsonField) = apply { + this.connectionId = connectionId + } - /** The Finch UUID of the connection associated with the `access_token`. */ - fun connectionId(connectionId: String) = connectionId(JsonField.of(connectionId)) - - /** - * Sets [Builder.connectionId] to an arbitrary JSON value. - * - * You should usually call [Builder.connectionId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun connectionId(connectionId: JsonField) = apply { - this.connectionId = connectionId - } - - fun connectionStatus(connectionStatus: ConnectionStatus) = + fun connectionStatus(connectionStatus: ConnectionStatusDetail) = connectionStatus(JsonField.of(connectionStatus)) /** * Sets [Builder.connectionStatus] to an arbitrary JSON value. * - * You should usually call [Builder.connectionStatus] with a well-typed [ConnectionStatus] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.connectionStatus] with a well-typed + * [ConnectionStatusDetail] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun connectionStatus(connectionStatus: JsonField) = apply { + fun connectionStatus(connectionStatus: JsonField) = apply { this.connectionStatus = connectionStatus } @@ -619,9 +566,107 @@ private constructor( this.connectionType = connectionType } + /** An array of the authorized products associated with the `access_token`. */ + fun products(products: List) = products(JsonField.of(products)) + + /** + * Sets [Builder.products] to an arbitrary JSON value. + * + * You should usually call [Builder.products] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [products]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addProduct(product: String) = apply { + products = + (products ?: JsonField.of(mutableListOf())).also { + checkKnown("products", it).add(product) + } + } + + /** The ID of the provider associated with the `access_token`. */ + fun providerId(providerId: String) = providerId(JsonField.of(providerId)) + + /** + * Sets [Builder.providerId] to an arbitrary JSON value. + * + * You should usually call [Builder.providerId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun providerId(providerId: JsonField) = apply { this.providerId = providerId } + + /** + * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of + * this account ID + */ + @Deprecated("deprecated") + fun accountId(accountId: String) = accountId(JsonField.of(accountId)) + + /** + * Sets [Builder.accountId] to an arbitrary JSON value. + * + * You should usually call [Builder.accountId] 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 accountId(accountId: JsonField) = apply { this.accountId = accountId } + + fun authenticationMethods(authenticationMethods: List) = + authenticationMethods(JsonField.of(authenticationMethods)) + + /** + * Sets [Builder.authenticationMethods] to an arbitrary JSON value. + * + * You should usually call [Builder.authenticationMethods] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun authenticationMethods( + authenticationMethods: JsonField> + ) = apply { this.authenticationMethods = authenticationMethods.map { it.toMutableList() } } + + /** + * Adds a single [AuthenticationMethodDetail] to [authenticationMethods]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAuthenticationMethod(authenticationMethod: AuthenticationMethodDetail) = apply { + authenticationMethods = + (authenticationMethods ?: JsonField.of(mutableListOf())).also { + checkKnown("authenticationMethods", it).add(authenticationMethod) + } + } + + /** + * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of + * this company ID + */ + @Deprecated("deprecated") + fun companyId(companyId: String) = companyId(JsonField.of(companyId)) + + /** + * Sets [Builder.companyId] to an arbitrary JSON value. + * + * You should usually call [Builder.companyId] 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 companyId(companyId: JsonField) = apply { this.companyId = companyId } + /** * The email of your customer you provided to Finch when a connect session was created for - * this connection. + * this connection */ fun customerEmail(customerEmail: String?) = customerEmail(JsonField.ofNullable(customerEmail)) @@ -643,7 +688,7 @@ private constructor( /** * The ID of your customer you provided to Finch when a connect session was created for this - * connection. + * connection */ fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) @@ -661,7 +706,7 @@ private constructor( /** * The name of your customer you provided to Finch when a connect session was created for - * this connection. + * this connection */ fun customerName(customerName: String?) = customerName(JsonField.ofNullable(customerName)) @@ -713,46 +758,11 @@ private constructor( this.payrollProviderId = payrollProviderId } - /** An array of the authorized products associated with the `access_token`. */ - fun products(products: List) = products(JsonField.of(products)) - - /** - * Sets [Builder.products] to an arbitrary JSON value. - * - * You should usually call [Builder.products] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun products(products: JsonField>) = apply { - this.products = products.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [products]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addProduct(product: String) = apply { - products = - (products ?: JsonField.of(mutableListOf())).also { - checkKnown("products", it).add(product) - } - } - - /** The ID of the provider associated with the `access_token`. */ - fun providerId(providerId: String) = providerId(JsonField.of(providerId)) - - /** - * Sets [Builder.providerId] to an arbitrary JSON value. - * - * You should usually call [Builder.providerId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun providerId(providerId: JsonField) = apply { this.providerId = providerId } - /** The account username used for login associated with the `access_token`. */ - fun username(username: String) = username(JsonField.of(username)) + fun username(username: String?) = username(JsonField.ofNullable(username)) + + /** Alias for calling [Builder.username] with `username.orElse(null)`. */ + fun username(username: Optional) = username(username.getOrNull()) /** * Sets [Builder.username] to an arbitrary JSON value. @@ -789,22 +799,13 @@ private constructor( * The following fields are required: * ```java * .id() - * .accountId() - * .authenticationMethods() * .clientId() * .clientType() - * .companyId() * .connectionId() * .connectionStatus() * .connectionType() - * .customerEmail() - * .customerId() - * .customerName() - * .manual() - * .payrollProviderId() * .products() * .providerId() - * .username() * ``` * * @throws IllegalStateException if any required field is unset. @@ -812,24 +813,22 @@ private constructor( fun build(): Introspection = Introspection( checkRequired("id", id), - checkRequired("accountId", accountId), - checkRequired("authenticationMethods", authenticationMethods).map { - it.toImmutable() - }, checkRequired("clientId", clientId), checkRequired("clientType", clientType), - checkRequired("companyId", companyId), checkRequired("connectionId", connectionId), checkRequired("connectionStatus", connectionStatus), checkRequired("connectionType", connectionType), - checkRequired("customerEmail", customerEmail), - checkRequired("customerId", customerId), - checkRequired("customerName", customerName), - checkRequired("manual", manual), - checkRequired("payrollProviderId", payrollProviderId), checkRequired("products", products).map { it.toImmutable() }, checkRequired("providerId", providerId), - checkRequired("username", username), + accountId, + (authenticationMethods ?: JsonMissing.of()).map { it.toImmutable() }, + companyId, + customerEmail, + customerId, + customerName, + manual, + payrollProviderId, + username, additionalProperties.toMutableMap(), ) } @@ -842,21 +841,21 @@ private constructor( } id() - accountId() - authenticationMethods().forEach { it.validate() } clientId() clientType().validate() - companyId() connectionId() connectionStatus().validate() connectionType().validate() + products() + providerId() + accountId() + authenticationMethods().ifPresent { it.forEach { it.validate() } } + companyId() customerEmail() customerId() customerName() manual() payrollProviderId() - products() - providerId() username() validated = true } @@ -877,90 +876,222 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (if (accountId.asKnown().isPresent) 1 else 0) + - (authenticationMethods.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (clientId.asKnown().isPresent) 1 else 0) + (clientType.asKnown().getOrNull()?.validity() ?: 0) + - (if (companyId.asKnown().isPresent) 1 else 0) + (if (connectionId.asKnown().isPresent) 1 else 0) + (connectionStatus.asKnown().getOrNull()?.validity() ?: 0) + (connectionType.asKnown().getOrNull()?.validity() ?: 0) + + (products.asKnown().getOrNull()?.size ?: 0) + + (if (providerId.asKnown().isPresent) 1 else 0) + + (if (accountId.asKnown().isPresent) 1 else 0) + + (authenticationMethods.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (companyId.asKnown().isPresent) 1 else 0) + (if (customerEmail.asKnown().isPresent) 1 else 0) + (if (customerId.asKnown().isPresent) 1 else 0) + (if (customerName.asKnown().isPresent) 1 else 0) + (if (manual.asKnown().isPresent) 1 else 0) + (if (payrollProviderId.asKnown().isPresent) 1 else 0) + - (products.asKnown().getOrNull()?.size ?: 0) + - (if (providerId.asKnown().isPresent) 1 else 0) + (if (username.asKnown().isPresent) 1 else 0) - class AuthenticationMethod - private constructor( - private val connectionStatus: JsonField, - private val products: JsonField>, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("connection_status") - @ExcludeMissing - connectionStatus: JsonField = JsonMissing.of(), - @JsonProperty("products") - @ExcludeMissing - products: JsonField> = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(connectionStatus, products, type, mutableMapOf()) + /** The type of application associated with a token. */ + class ClientType @JsonCreator private constructor(private val value: JsonField) : Enum { /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected 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. */ - fun connectionStatus(): Optional = - connectionStatus.getOptional("connection_status") + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DEVELOPMENT = of("development") + + @JvmField val PRODUCTION = of("production") + + @JvmField val SANDBOX = of("sandbox") + + @JvmStatic fun of(value: String) = ClientType(JsonField.of(value)) + } + + /** An enum containing [ClientType]'s known values. */ + enum class Known { + DEVELOPMENT, + PRODUCTION, + SANDBOX, + } /** - * An array of the authorized products associated with the `access_token`. + * An enum containing [ClientType]'s known values, as well as an [_UNKNOWN] member. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * An instance of [ClientType] 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. */ - fun products(): Optional> = products.getOptional("products") + enum class Value { + DEVELOPMENT, + PRODUCTION, + SANDBOX, + /** + * An enum member indicating that [ClientType] was instantiated with an unknown value. + */ + _UNKNOWN, + } /** - * The type of authentication method. + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected 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 type(): Optional = type.getOptional("type") + fun value(): Value = + when (this) { + DEVELOPMENT -> Value.DEVELOPMENT + PRODUCTION -> Value.PRODUCTION + SANDBOX -> Value.SANDBOX + else -> Value._UNKNOWN + } /** - * Returns the raw JSON value of [connectionStatus]. + * Returns an enum member corresponding to this class instance's value. * - * Unlike [connectionStatus], this method doesn't throw if the JSON field has an unexpected - * type. + * 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. */ - @JsonProperty("connection_status") - @ExcludeMissing - fun _connectionStatus(): JsonField = connectionStatus + fun known(): Known = + when (this) { + DEVELOPMENT -> Known.DEVELOPMENT + PRODUCTION -> Known.PRODUCTION + SANDBOX -> Known.SANDBOX + else -> throw FinchInvalidDataException("Unknown ClientType: $value") + } /** - * Returns the raw JSON value of [products]. + * Returns this class instance's primitive wire representation. * - * Unlike [products], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("products") - @ExcludeMissing - fun _products(): JsonField> = products + * 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(): ClientType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } /** - * Returns the raw JSON value of [type]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = 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 other is ClientType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ConnectionStatusDetail + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val status: JsonField, + private val lastSuccessfulSync: JsonField, + private val message: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("last_successful_sync") + @ExcludeMissing + lastSuccessfulSync: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + ) : this(status, lastSuccessfulSync, message, 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 status(): ConnectionStatusType = status.getRequired("status") + + /** + * The datetime when the connection was last successfully synced + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastSuccessfulSync(): Optional = + lastSuccessfulSync.getOptional("last_successful_sync") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun message(): Optional = message.getOptional("message") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [lastSuccessfulSync]. + * + * Unlike [lastSuccessfulSync], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("last_successful_sync") + @ExcludeMissing + fun _lastSuccessfulSync(): JsonField = lastSuccessfulSync + + /** + * 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 @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -976,77 +1107,89 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [AuthenticationMethod]. */ + /** + * Returns a mutable builder for constructing an instance of [ConnectionStatusDetail]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [AuthenticationMethod]. */ + /** A builder for [ConnectionStatusDetail]. */ class Builder internal constructor() { - private var connectionStatus: JsonField = JsonMissing.of() - private var products: JsonField>? = null - private var type: JsonField = JsonMissing.of() + private var status: JsonField? = null + private var lastSuccessfulSync: JsonField = JsonMissing.of() + private var message: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(authenticationMethod: AuthenticationMethod) = apply { - connectionStatus = authenticationMethod.connectionStatus - products = authenticationMethod.products.map { it.toMutableList() } - type = authenticationMethod.type - additionalProperties = authenticationMethod.additionalProperties.toMutableMap() + internal fun from(connectionStatusDetail: ConnectionStatusDetail) = apply { + status = connectionStatusDetail.status + lastSuccessfulSync = connectionStatusDetail.lastSuccessfulSync + message = connectionStatusDetail.message + additionalProperties = connectionStatusDetail.additionalProperties.toMutableMap() } - fun connectionStatus(connectionStatus: ConnectionStatus) = - connectionStatus(JsonField.of(connectionStatus)) + fun status(status: ConnectionStatusType) = status(JsonField.of(status)) /** - * Sets [Builder.connectionStatus] to an arbitrary JSON value. + * Sets [Builder.status] to an arbitrary JSON value. * - * You should usually call [Builder.connectionStatus] with a well-typed - * [ConnectionStatus] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * You should usually call [Builder.status] with a well-typed [ConnectionStatusType] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun connectionStatus(connectionStatus: JsonField) = apply { - this.connectionStatus = connectionStatus - } + fun status(status: JsonField) = apply { this.status = status } - /** An array of the authorized products associated with the `access_token`. */ - fun products(products: List) = products(JsonField.of(products)) + /** The datetime when the connection was last successfully synced */ + fun lastSuccessfulSync(lastSuccessfulSync: LastSuccessfulSync?) = + lastSuccessfulSync(JsonField.ofNullable(lastSuccessfulSync)) /** - * Sets [Builder.products] to an arbitrary JSON value. - * - * You should usually call [Builder.products] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Alias for calling [Builder.lastSuccessfulSync] with + * `lastSuccessfulSync.orElse(null)`. */ - fun products(products: JsonField>) = apply { - this.products = products.map { it.toMutableList() } - } + fun lastSuccessfulSync(lastSuccessfulSync: Optional) = + lastSuccessfulSync(lastSuccessfulSync.getOrNull()) /** - * Adds a single [String] to [products]. + * Sets [Builder.lastSuccessfulSync] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.lastSuccessfulSync] with a well-typed + * [LastSuccessfulSync] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun addProduct(product: String) = apply { - products = - (products ?: JsonField.of(mutableListOf())).also { - checkKnown("products", it).add(product) - } + fun lastSuccessfulSync(lastSuccessfulSync: JsonField) = apply { + this.lastSuccessfulSync = lastSuccessfulSync } - /** The type of authentication method. */ - fun type(type: Type) = type(JsonField.of(type)) + /** + * Alias for calling [lastSuccessfulSync] with + * `LastSuccessfulSync.ofOffsetDateTime(offsetDateTime)`. + */ + fun lastSuccessfulSync(offsetDateTime: OffsetDateTime) = + lastSuccessfulSync(LastSuccessfulSync.ofOffsetDateTime(offsetDateTime)) /** - * Sets [Builder.type] to an arbitrary JSON value. + * Alias for calling [lastSuccessfulSync] with `LastSuccessfulSync.ofString(string)`. + */ + fun lastSuccessfulSync(string: String) = + lastSuccessfulSync(LastSuccessfulSync.ofString(string)) + + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] 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. + * 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 type(type: JsonField) = apply { this.type = type } + fun message(message: JsonField) = apply { this.message = message } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1068,29 +1211,36 @@ private constructor( } /** - * Returns an immutable instance of [AuthenticationMethod]. + * Returns an immutable instance of [ConnectionStatusDetail]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): AuthenticationMethod = - AuthenticationMethod( - connectionStatus, - (products ?: JsonMissing.of()).map { it.toImmutable() }, - type, + fun build(): ConnectionStatusDetail = + ConnectionStatusDetail( + checkRequired("status", status), + lastSuccessfulSync, + message, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): AuthenticationMethod = apply { + fun validate(): ConnectionStatusDetail = apply { if (validated) { return@apply } - connectionStatus().ifPresent { it.validate() } - products() - type().ifPresent { it.validate() } + status().validate() + lastSuccessfulSync().ifPresent { it.validate() } + message() validated = true } @@ -1110,336 +1260,185 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (connectionStatus.asKnown().getOrNull()?.validity() ?: 0) + - (products.asKnown().getOrNull()?.size ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class ConnectionStatus + (status.asKnown().getOrNull()?.validity() ?: 0) + + (lastSuccessfulSync.asKnown().getOrNull()?.validity() ?: 0) + + (if (message.asKnown().isPresent) 1 else 0) + + /** The datetime when the connection was last successfully synced */ + @JsonDeserialize(using = LastSuccessfulSync.Deserializer::class) + @JsonSerialize(using = LastSuccessfulSync.Serializer::class) + class LastSuccessfulSync private constructor( - private val message: JsonField, - private val status: JsonField, - private val additionalProperties: MutableMap, + private val offsetDateTime: OffsetDateTime? = null, + private val string: String? = null, + private val _json: JsonValue? = null, ) { - @JsonCreator - private constructor( - @JsonProperty("message") - @ExcludeMissing - message: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - status: JsonField = JsonMissing.of(), - ) : this(message, status, mutableMapOf()) + fun offsetDateTime(): Optional = Optional.ofNullable(offsetDateTime) - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun message(): Optional = message.getOptional("message") + fun string(): Optional = Optional.ofNullable(string) - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun status(): Optional = status.getOptional("status") + fun isOffsetDateTime(): Boolean = offsetDateTime != null - /** - * 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 + fun isString(): Boolean = string != null + + fun asOffsetDateTime(): OffsetDateTime = offsetDateTime.getOrThrow("offsetDateTime") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): LastSuccessfulSync = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } /** - * Returns the raw JSON value of [status]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("status") - @ExcludeMissing - fun _status(): JsonField = status + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) = 1 - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LastSuccessfulSync && + offsetDateTime == other.offsetDateTime && + string == other.string } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun hashCode(): Int = Objects.hash(offsetDateTime, string) - fun toBuilder() = Builder().from(this) + override fun toString(): String = + when { + offsetDateTime != null -> "LastSuccessfulSync{offsetDateTime=$offsetDateTime}" + string != null -> "LastSuccessfulSync{string=$string}" + _json != null -> "LastSuccessfulSync{_unknown=$_json}" + else -> throw IllegalStateException("Invalid LastSuccessfulSync") + } companion object { - /** Returns a mutable builder for constructing an instance of [ConnectionStatus]. */ - @JvmStatic fun builder() = Builder() + @JvmStatic + fun ofOffsetDateTime(offsetDateTime: OffsetDateTime) = + LastSuccessfulSync(offsetDateTime = offsetDateTime) + + @JvmStatic fun ofString(string: String) = LastSuccessfulSync(string = string) } - /** A builder for [ConnectionStatus]. */ - class Builder internal constructor() { + /** + * An interface that defines how to map each variant of [LastSuccessfulSync] to a value + * of type [T]. + */ + interface Visitor { - private var message: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + fun visitOffsetDateTime(offsetDateTime: OffsetDateTime): T - @JvmSynthetic - internal fun from(connectionStatus: ConnectionStatus) = apply { - message = connectionStatus.message - status = connectionStatus.status - additionalProperties = connectionStatus.additionalProperties.toMutableMap() - } - - 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 status(status: ConnectionStatusType) = status(JsonField.of(status)) + fun visitString(string: String): T /** - * Sets [Builder.status] to an arbitrary JSON value. + * Maps an unknown variant of [LastSuccessfulSync] to a value of type [T]. * - * You should usually call [Builder.status] with a well-typed [ConnectionStatusType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ConnectionStatus]. + * An instance of [LastSuccessfulSync] 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. * - * Further updates to this [Builder] will not mutate the returned instance. + * @throws FinchInvalidDataException in the default implementation. */ - fun build(): ConnectionStatus = - ConnectionStatus(message, status, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): ConnectionStatus = apply { - if (validated) { - return@apply - } - - message() - status().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false + fun unknown(json: JsonValue?): T { + throw FinchInvalidDataException("Unknown LastSuccessfulSync: $json") } - - /** - * 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 (message.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ConnectionStatus && - message == other.message && - status == other.status && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(message, status, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ConnectionStatus{message=$message, status=$status, additionalProperties=$additionalProperties}" - } - - /** The type of authentication method. */ - 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 ASSISTED = of("assisted") - - @JvmField val CREDENTIAL = of("credential") - - @JvmField val API_TOKEN = of("api_token") - - @JvmField val API_CREDENTIAL = of("api_credential") - - @JvmField val OAUTH = of("oauth") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - ASSISTED, - CREDENTIAL, - API_TOKEN, - API_CREDENTIAL, - OAUTH, - } - - /** - * 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 { - ASSISTED, - CREDENTIAL, - API_TOKEN, - API_CREDENTIAL, - OAUTH, - /** 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) { - ASSISTED -> Value.ASSISTED - CREDENTIAL -> Value.CREDENTIAL - API_TOKEN -> Value.API_TOKEN - API_CREDENTIAL -> Value.API_CREDENTIAL - OAUTH -> Value.OAUTH - 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) { - ASSISTED -> Known.ASSISTED - CREDENTIAL -> Known.CREDENTIAL - API_TOKEN -> Known.API_TOKEN - API_CREDENTIAL -> Known.API_CREDENTIAL - OAUTH -> Known.OAUTH - 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 + internal class Deserializer : + BaseDeserializer(LastSuccessfulSync::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): LastSuccessfulSync { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + LastSuccessfulSync(offsetDateTime = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + LastSuccessfulSync(string = 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 object). + 0 -> LastSuccessfulSync(_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() + } } - - 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 + internal class Serializer : + BaseSerializer(LastSuccessfulSync::class) { + + override fun serialize( + value: LastSuccessfulSync, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.offsetDateTime != null -> generator.writeObject(value.offsetDateTime) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid LastSuccessfulSync") + } } - - return other is Type && value == other.value } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -1447,25 +1446,30 @@ private constructor( return true } - return other is AuthenticationMethod && - connectionStatus == other.connectionStatus && - products == other.products && - type == other.type && + return other is ConnectionStatusDetail && + status == other.status && + lastSuccessfulSync == other.lastSuccessfulSync && + message == other.message && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(connectionStatus, products, type, additionalProperties) + Objects.hash(status, lastSuccessfulSync, message, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AuthenticationMethod{connectionStatus=$connectionStatus, products=$products, type=$type, additionalProperties=$additionalProperties}" + "ConnectionStatusDetail{status=$status, lastSuccessfulSync=$lastSuccessfulSync, message=$message, additionalProperties=$additionalProperties}" } - /** The type of application associated with a token. */ - class ClientType @JsonCreator private constructor(private val value: JsonField) : Enum { + /** + * The type of the connection associated with the token. + * - `provider` - connection to an external provider + * - `finch` - finch-generated data. + */ + class ConnectionType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1479,37 +1483,34 @@ private constructor( companion object { - @JvmField val PRODUCTION = of("production") - - @JvmField val DEVELOPMENT = of("development") + @JvmField val FINCH = of("finch") - @JvmField val SANDBOX = of("sandbox") + @JvmField val PROVIDER = of("provider") - @JvmStatic fun of(value: String) = ClientType(JsonField.of(value)) + @JvmStatic fun of(value: String) = ConnectionType(JsonField.of(value)) } - /** An enum containing [ClientType]'s known values. */ + /** An enum containing [ConnectionType]'s known values. */ enum class Known { - PRODUCTION, - DEVELOPMENT, - SANDBOX, + FINCH, + PROVIDER, } /** - * An enum containing [ClientType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [ConnectionType]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [ClientType] can contain an unknown value in a couple of cases: + * An instance of [ConnectionType] 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 { - PRODUCTION, - DEVELOPMENT, - SANDBOX, + FINCH, + PROVIDER, /** - * An enum member indicating that [ClientType] was instantiated with an unknown value. + * An enum member indicating that [ConnectionType] was instantiated with an unknown + * value. */ _UNKNOWN, } @@ -1523,9 +1524,8 @@ private constructor( */ fun value(): Value = when (this) { - PRODUCTION -> Value.PRODUCTION - DEVELOPMENT -> Value.DEVELOPMENT - SANDBOX -> Value.SANDBOX + FINCH -> Value.FINCH + PROVIDER -> Value.PROVIDER else -> Value._UNKNOWN } @@ -1539,10 +1539,9 @@ private constructor( */ fun known(): Known = when (this) { - PRODUCTION -> Known.PRODUCTION - DEVELOPMENT -> Known.DEVELOPMENT - SANDBOX -> Known.SANDBOX - else -> throw FinchInvalidDataException("Unknown ClientType: $value") + FINCH -> Known.FINCH + PROVIDER -> Known.PROVIDER + else -> throw FinchInvalidDataException("Unknown ConnectionType: $value") } /** @@ -1559,7 +1558,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ClientType = apply { + fun validate(): ConnectionType = apply { if (validated) { return@apply } @@ -1589,7 +1588,7 @@ private constructor( return true } - return other is ClientType && value == other.value + return other is ConnectionType && value == other.value } override fun hashCode() = value.hashCode() @@ -1597,71 +1596,74 @@ private constructor( override fun toString() = value.toString() } - class ConnectionStatus + class AuthenticationMethodDetail + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val lastSuccessfulSync: JsonField, - private val message: JsonField, - private val status: JsonField, + private val type: JsonField, + private val connectionStatus: JsonField, + private val products: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("last_successful_sync") + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("connection_status") @ExcludeMissing - lastSuccessfulSync: JsonField = JsonMissing.of(), - @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), - @JsonProperty("status") + connectionStatus: JsonField = JsonMissing.of(), + @JsonProperty("products") @ExcludeMissing - status: JsonField = JsonMissing.of(), - ) : this(lastSuccessfulSync, message, status, mutableMapOf()) + products: JsonField> = JsonMissing.of(), + ) : this(type, connectionStatus, products, mutableMapOf()) /** - * The datetime when the connection was last successfully synced. + * The type of authentication method * - * @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 lastSuccessfulSync(): Optional = - lastSuccessfulSync.getOptional("last_successful_sync") + fun type(): Type = type.getRequired("type") /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun message(): Optional = message.getOptional("message") + fun connectionStatus(): Optional = + connectionStatus.getOptional("connection_status") /** + * An array of the authorized products associated with the `access_token` + * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun status(): Optional = status.getOptional("status") + fun products(): Optional> = products.getOptional("products") /** - * Returns the raw JSON value of [lastSuccessfulSync]. + * Returns the raw JSON value of [type]. * - * Unlike [lastSuccessfulSync], this method doesn't throw if the JSON field has an - * unexpected type. + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("last_successful_sync") - @ExcludeMissing - fun _lastSuccessfulSync(): JsonField = lastSuccessfulSync + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** - * Returns the raw JSON value of [message]. + * Returns the raw JSON value of [connectionStatus]. * - * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [connectionStatus], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + @JsonProperty("connection_status") + @ExcludeMissing + fun _connectionStatus(): JsonField = connectionStatus /** - * Returns the raw JSON value of [status]. + * Returns the raw JSON value of [products]. * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [products], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("status") + @JsonProperty("products") @ExcludeMissing - fun _status(): JsonField = status + fun _products(): JsonField> = products @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1677,282 +1679,775 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [ConnectionStatus]. */ + /** + * Returns a mutable builder for constructing an instance of + * [AuthenticationMethodDetail]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [ConnectionStatus]. */ + /** A builder for [AuthenticationMethodDetail]. */ class Builder internal constructor() { - private var lastSuccessfulSync: JsonField = JsonMissing.of() - private var message: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() + private var type: JsonField? = null + private var connectionStatus: JsonField = JsonMissing.of() + private var products: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(connectionStatus: ConnectionStatus) = apply { - lastSuccessfulSync = connectionStatus.lastSuccessfulSync - message = connectionStatus.message - status = connectionStatus.status - additionalProperties = connectionStatus.additionalProperties.toMutableMap() + internal fun from(authenticationMethodDetail: AuthenticationMethodDetail) = apply { + type = authenticationMethodDetail.type + connectionStatus = authenticationMethodDetail.connectionStatus + products = authenticationMethodDetail.products.map { it.toMutableList() } + additionalProperties = + authenticationMethodDetail.additionalProperties.toMutableMap() } - /** The datetime when the connection was last successfully synced. */ - fun lastSuccessfulSync(lastSuccessfulSync: OffsetDateTime) = - lastSuccessfulSync(JsonField.of(lastSuccessfulSync)) + /** The type of authentication method */ + fun type(type: Type) = type(JsonField.of(type)) /** - * Sets [Builder.lastSuccessfulSync] to an arbitrary JSON value. + * Sets [Builder.type] to an arbitrary JSON value. * - * You should usually call [Builder.lastSuccessfulSync] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported 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 lastSuccessfulSync(lastSuccessfulSync: JsonField) = apply { - this.lastSuccessfulSync = lastSuccessfulSync + fun type(type: JsonField) = apply { this.type = type } + + fun connectionStatus(connectionStatus: ConnectionStatusDetail) = + connectionStatus(JsonField.of(connectionStatus)) + + /** + * Sets [Builder.connectionStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.connectionStatus] with a well-typed + * [ConnectionStatusDetail] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun connectionStatus(connectionStatus: JsonField) = apply { + this.connectionStatus = connectionStatus } - fun message(message: String) = message(JsonField.of(message)) + /** An array of the authorized products associated with the `access_token` */ + fun products(products: List) = products(JsonField.of(products)) /** - * Sets [Builder.message] to an arbitrary JSON value. + * Sets [Builder.products] 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 + * You should usually call [Builder.products] with a well-typed `List` 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 products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } + } - fun status(status: ConnectionStatusType) = status(JsonField.of(status)) + /** + * Adds a single [String] to [products]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addProduct(product: String) = apply { + products = + (products ?: JsonField.of(mutableListOf())).also { + checkKnown("products", it).add(product) + } + } + + 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) + } /** - * Sets [Builder.status] to an arbitrary JSON value. + * Returns an immutable instance of [AuthenticationMethodDetail]. * - * You should usually call [Builder.status] with a well-typed [ConnectionStatusType] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * 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 status(status: JsonField) = apply { this.status = status } + fun build(): AuthenticationMethodDetail = + AuthenticationMethodDetail( + checkRequired("type", type), + connectionStatus, + (products ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AuthenticationMethodDetail = apply { + if (validated) { + return@apply + } + + type().validate() + connectionStatus().ifPresent { it.validate() } + products() + 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) + + (connectionStatus.asKnown().getOrNull()?.validity() ?: 0) + + (products.asKnown().getOrNull()?.size ?: 0) + + /** The type of authentication method */ + 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 ASSISTED = of("assisted") + + @JvmField val CREDENTIAL = of("credential") + + @JvmField val API_TOKEN = of("api_token") + + @JvmField val API_CREDENTIAL = of("api_credential") + + @JvmField val OAUTH = of("oauth") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ASSISTED, + CREDENTIAL, + API_TOKEN, + API_CREDENTIAL, + OAUTH, + } + + /** + * 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 { + ASSISTED, + CREDENTIAL, + API_TOKEN, + API_CREDENTIAL, + OAUTH, + /** 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) { + ASSISTED -> Value.ASSISTED + CREDENTIAL -> Value.CREDENTIAL + API_TOKEN -> Value.API_TOKEN + API_CREDENTIAL -> Value.API_CREDENTIAL + OAUTH -> Value.OAUTH + 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) { + ASSISTED -> Known.ASSISTED + CREDENTIAL -> Known.CREDENTIAL + API_TOKEN -> Known.API_TOKEN + API_CREDENTIAL -> Known.API_CREDENTIAL + OAUTH -> Known.OAUTH + 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 other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ConnectionStatusDetail + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val status: JsonField, + private val lastSuccessfulSync: JsonField, + private val message: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("last_successful_sync") + @ExcludeMissing + lastSuccessfulSync: JsonField = JsonMissing.of(), + @JsonProperty("message") + @ExcludeMissing + message: JsonField = JsonMissing.of(), + ) : this(status, lastSuccessfulSync, message, 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 status(): ConnectionStatusType = status.getRequired("status") + + /** + * The datetime when the connection was last successfully synced + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastSuccessfulSync(): Optional = + lastSuccessfulSync.getOptional("last_successful_sync") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun message(): Optional = message.getOptional("message") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [lastSuccessfulSync]. + * + * Unlike [lastSuccessfulSync], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("last_successful_sync") + @ExcludeMissing + fun _lastSuccessfulSync(): JsonField = lastSuccessfulSync + + /** + * 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 + + @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 + * [ConnectionStatusDetail]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConnectionStatusDetail]. */ + class Builder internal constructor() { + + private var status: JsonField? = null + private var lastSuccessfulSync: JsonField = JsonMissing.of() + private var message: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(connectionStatusDetail: ConnectionStatusDetail) = apply { + status = connectionStatusDetail.status + lastSuccessfulSync = connectionStatusDetail.lastSuccessfulSync + message = connectionStatusDetail.message + additionalProperties = + connectionStatusDetail.additionalProperties.toMutableMap() + } + + fun status(status: ConnectionStatusType) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [ConnectionStatusType] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The datetime when the connection was last successfully synced */ + fun lastSuccessfulSync(lastSuccessfulSync: LastSuccessfulSync?) = + lastSuccessfulSync(JsonField.ofNullable(lastSuccessfulSync)) + + /** + * Alias for calling [Builder.lastSuccessfulSync] with + * `lastSuccessfulSync.orElse(null)`. + */ + fun lastSuccessfulSync(lastSuccessfulSync: Optional) = + lastSuccessfulSync(lastSuccessfulSync.getOrNull()) + + /** + * Sets [Builder.lastSuccessfulSync] to an arbitrary JSON value. + * + * You should usually call [Builder.lastSuccessfulSync] with a well-typed + * [LastSuccessfulSync] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lastSuccessfulSync(lastSuccessfulSync: JsonField) = apply { + this.lastSuccessfulSync = lastSuccessfulSync + } + + /** + * Alias for calling [lastSuccessfulSync] with + * `LastSuccessfulSync.ofOffsetDateTime(offsetDateTime)`. + */ + fun lastSuccessfulSync(offsetDateTime: OffsetDateTime) = + lastSuccessfulSync(LastSuccessfulSync.ofOffsetDateTime(offsetDateTime)) + + /** + * Alias for calling [lastSuccessfulSync] with + * `LastSuccessfulSync.ofString(string)`. + */ + fun lastSuccessfulSync(string: String) = + lastSuccessfulSync(LastSuccessfulSync.ofString(string)) + + 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 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 additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Returns an immutable instance of [ConnectionStatusDetail]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConnectionStatusDetail = + ConnectionStatusDetail( + checkRequired("status", status), + lastSuccessfulSync, + message, + additionalProperties.toMutableMap(), + ) } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + private var validated: Boolean = false - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun validate(): ConnectionStatusDetail = apply { + if (validated) { + return@apply + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + status().validate() + lastSuccessfulSync().ifPresent { it.validate() } + message() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + /** - * Returns an immutable instance of [ConnectionStatus]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): ConnectionStatus = - ConnectionStatus( - lastSuccessfulSync, - message, - status, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = + (status.asKnown().getOrNull()?.validity() ?: 0) + + (lastSuccessfulSync.asKnown().getOrNull()?.validity() ?: 0) + + (if (message.asKnown().isPresent) 1 else 0) + + /** The datetime when the connection was last successfully synced */ + @JsonDeserialize(using = LastSuccessfulSync.Deserializer::class) + @JsonSerialize(using = LastSuccessfulSync.Serializer::class) + class LastSuccessfulSync + private constructor( + private val offsetDateTime: OffsetDateTime? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - private var validated: Boolean = false + fun offsetDateTime(): Optional = Optional.ofNullable(offsetDateTime) - fun validate(): ConnectionStatus = apply { - if (validated) { - return@apply - } + fun string(): Optional = Optional.ofNullable(string) - lastSuccessfulSync() - message() - status().ifPresent { it.validate() } - validated = true - } + fun isOffsetDateTime(): Boolean = offsetDateTime != null - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + fun isString(): Boolean = string != null - /** - * 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 (lastSuccessfulSync.asKnown().isPresent) 1 else 0) + - (if (message.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + fun asOffsetDateTime(): OffsetDateTime = offsetDateTime.getOrThrow("offsetDateTime") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun asString(): String = string.getOrThrow("string") - return other is ConnectionStatus && - lastSuccessfulSync == other.lastSuccessfulSync && - message == other.message && - status == other.status && - additionalProperties == other.additionalProperties - } + fun _json(): Optional = Optional.ofNullable(_json) - private val hashCode: Int by lazy { - Objects.hash(lastSuccessfulSync, message, status, additionalProperties) - } + fun accept(visitor: Visitor): T = + when { + offsetDateTime != null -> visitor.visitOffsetDateTime(offsetDateTime) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } - override fun hashCode(): Int = hashCode + private var validated: Boolean = false - override fun toString() = - "ConnectionStatus{lastSuccessfulSync=$lastSuccessfulSync, message=$message, status=$status, additionalProperties=$additionalProperties}" - } + fun validate(): LastSuccessfulSync = apply { + if (validated) { + return@apply + } - /** - * The type of the connection associated with the token. - * - `provider` - connection to an external provider - * - `finch` - finch-generated data. - */ - class ConnectionType @JsonCreator private constructor(private val value: JsonField) : - Enum { + accept( + object : Visitor { + override fun visitOffsetDateTime(offsetDateTime: OffsetDateTime) {} - /** - * 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 visitString(string: String) {} + } + ) + validated = true + } - companion object { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } - @JvmField val PROVIDER = of("provider") + /** + * 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 visitOffsetDateTime(offsetDateTime: OffsetDateTime) = 1 - @JvmField val FINCH = of("finch") + override fun visitString(string: String) = 1 - @JvmStatic fun of(value: String) = ConnectionType(JsonField.of(value)) - } + override fun unknown(json: JsonValue?) = 0 + } + ) - /** An enum containing [ConnectionType]'s known values. */ - enum class Known { - PROVIDER, - FINCH, - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * An enum containing [ConnectionType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ConnectionType] 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 { - PROVIDER, - FINCH, - /** - * An enum member indicating that [ConnectionType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + return other is LastSuccessfulSync && + offsetDateTime == other.offsetDateTime && + string == other.string + } - /** - * 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) { - PROVIDER -> Value.PROVIDER - FINCH -> Value.FINCH - else -> Value._UNKNOWN - } + override fun hashCode(): Int = Objects.hash(offsetDateTime, string) - /** - * 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) { - PROVIDER -> Known.PROVIDER - FINCH -> Known.FINCH - else -> throw FinchInvalidDataException("Unknown ConnectionType: $value") - } + override fun toString(): String = + when { + offsetDateTime != null -> + "LastSuccessfulSync{offsetDateTime=$offsetDateTime}" + string != null -> "LastSuccessfulSync{string=$string}" + _json != null -> "LastSuccessfulSync{_unknown=$_json}" + else -> throw IllegalStateException("Invalid LastSuccessfulSync") + } - /** - * 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") } + companion object { - private var validated: Boolean = false + @JvmStatic + fun ofOffsetDateTime(offsetDateTime: OffsetDateTime) = + LastSuccessfulSync(offsetDateTime = offsetDateTime) - fun validate(): ConnectionType = apply { - if (validated) { - return@apply + @JvmStatic fun ofString(string: String) = LastSuccessfulSync(string = string) + } + + /** + * An interface that defines how to map each variant of [LastSuccessfulSync] to a + * value of type [T]. + */ + interface Visitor { + + fun visitOffsetDateTime(offsetDateTime: OffsetDateTime): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [LastSuccessfulSync] to a value of type [T]. + * + * An instance of [LastSuccessfulSync] 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 LastSuccessfulSync: $json") + } + } + + internal class Deserializer : + BaseDeserializer(LastSuccessfulSync::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): LastSuccessfulSync { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + LastSuccessfulSync(offsetDateTime = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + LastSuccessfulSync(string = 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 + // object). + 0 -> LastSuccessfulSync(_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(LastSuccessfulSync::class) { + + override fun serialize( + value: LastSuccessfulSync, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.offsetDateTime != null -> + generator.writeObject(value.offsetDateTime) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid LastSuccessfulSync") + } + } + } } - known() - validated = true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false + return other is ConnectionStatusDetail && + status == other.status && + lastSuccessfulSync == other.lastSuccessfulSync && + message == other.message && + additionalProperties == other.additionalProperties } - /** - * 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 + private val hashCode: Int by lazy { + Objects.hash(status, lastSuccessfulSync, message, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConnectionStatusDetail{status=$status, lastSuccessfulSync=$lastSuccessfulSync, message=$message, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ConnectionType && value == other.value + return other is AuthenticationMethodDetail && + type == other.type && + connectionStatus == other.connectionStatus && + products == other.products && + additionalProperties == other.additionalProperties } - override fun hashCode() = value.hashCode() + private val hashCode: Int by lazy { + Objects.hash(type, connectionStatus, products, additionalProperties) + } - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "AuthenticationMethodDetail{type=$type, connectionStatus=$connectionStatus, products=$products, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1962,21 +2457,21 @@ private constructor( return other is Introspection && id == other.id && - accountId == other.accountId && - authenticationMethods == other.authenticationMethods && clientId == other.clientId && clientType == other.clientType && - companyId == other.companyId && connectionId == other.connectionId && connectionStatus == other.connectionStatus && connectionType == other.connectionType && + products == other.products && + providerId == other.providerId && + accountId == other.accountId && + authenticationMethods == other.authenticationMethods && + companyId == other.companyId && customerEmail == other.customerEmail && customerId == other.customerId && customerName == other.customerName && manual == other.manual && payrollProviderId == other.payrollProviderId && - products == other.products && - providerId == other.providerId && username == other.username && additionalProperties == other.additionalProperties } @@ -1984,21 +2479,21 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( id, - accountId, - authenticationMethods, clientId, clientType, - companyId, connectionId, connectionStatus, connectionType, + products, + providerId, + accountId, + authenticationMethods, + companyId, customerEmail, customerId, customerName, manual, payrollProviderId, - products, - providerId, username, additionalProperties, ) @@ -2007,5 +2502,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Introspection{id=$id, accountId=$accountId, authenticationMethods=$authenticationMethods, clientId=$clientId, clientType=$clientType, companyId=$companyId, connectionId=$connectionId, connectionStatus=$connectionStatus, connectionType=$connectionType, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, manual=$manual, payrollProviderId=$payrollProviderId, products=$products, providerId=$providerId, username=$username, additionalProperties=$additionalProperties}" + "Introspection{id=$id, clientId=$clientId, clientType=$clientType, connectionId=$connectionId, connectionStatus=$connectionStatus, connectionType=$connectionType, products=$products, providerId=$providerId, accountId=$accountId, authenticationMethods=$authenticationMethods, companyId=$companyId, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, manual=$manual, payrollProviderId=$payrollProviderId, username=$username, additionalProperties=$additionalProperties}" } 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 edc99c18..10922d08 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 @@ -42,7 +42,7 @@ import kotlin.jvm.optionals.getOrNull * `w4_form_employee_sync`: Enqueues a job for sync W-4 data for a particular individual, identified * by `individual_id`. This feature is currently in beta. * - * This endpoint is available for _Scale_ tier customers as an add-on. To request access to this + * This endpoint is available for *Scale* tier customers as an add-on. To request access to this * endpoint, please contact your Finch account manager. */ class JobAutomatedCreateParams @@ -402,6 +402,7 @@ private constructor( } class W4FormEmployeeSync + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val params: JsonField, private val type: JsonValue, @@ -585,6 +586,7 @@ private constructor( type.let { if (it == JsonValue.from("w4_form_employee_sync")) 1 else 0 } class Params + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val individualId: JsonField, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedListParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedListParams.kt index fb70e949..c8fbee18 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedListParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedListParams.kt @@ -16,20 +16,12 @@ import kotlin.jvm.optionals.getOrNull */ class JobAutomatedListParams private constructor( - private val entityId: String?, private val limit: Long?, private val offset: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - /** - * The entity ID to use when authenticating with a multi-account token. Required when using a - * multi-account token to specify which entity's data to access. Example: - * `123e4567-e89b-12d3-a456-426614174000` - */ - fun entityId(): Optional = Optional.ofNullable(entityId) - /** Number of items to return */ fun limit(): Optional = Optional.ofNullable(limit) @@ -55,7 +47,6 @@ private constructor( /** A builder for [JobAutomatedListParams]. */ class Builder internal constructor() { - private var entityId: String? = null private var limit: Long? = null private var offset: Long? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -63,23 +54,12 @@ private constructor( @JvmSynthetic internal fun from(jobAutomatedListParams: JobAutomatedListParams) = apply { - entityId = jobAutomatedListParams.entityId limit = jobAutomatedListParams.limit offset = jobAutomatedListParams.offset additionalHeaders = jobAutomatedListParams.additionalHeaders.toBuilder() additionalQueryParams = jobAutomatedListParams.additionalQueryParams.toBuilder() } - /** - * The entity ID to use when authenticating with a multi-account token. Required when using - * a multi-account token to specify which entity's data to access. Example: - * `123e4567-e89b-12d3-a456-426614174000` - */ - fun entityId(entityId: String?) = apply { this.entityId = entityId } - - /** Alias for calling [Builder.entityId] with `entityId.orElse(null)`. */ - fun entityId(entityId: Optional) = entityId(entityId.getOrNull()) - /** Number of items to return */ fun limit(limit: Long?) = apply { this.limit = limit } @@ -211,7 +191,6 @@ private constructor( */ fun build(): JobAutomatedListParams = JobAutomatedListParams( - entityId, limit, offset, additionalHeaders.build(), @@ -224,7 +203,6 @@ private constructor( override fun _queryParams(): QueryParams = QueryParams.builder() .apply { - entityId?.let { put("entity_id", it) } limit?.let { put("limit", it.toString()) } offset?.let { put("offset", it.toString()) } putAll(additionalQueryParams) @@ -237,7 +215,6 @@ private constructor( } return other is JobAutomatedListParams && - entityId == other.entityId && limit == other.limit && offset == other.offset && additionalHeaders == other.additionalHeaders && @@ -245,8 +222,8 @@ private constructor( } override fun hashCode(): Int = - Objects.hash(entityId, limit, offset, additionalHeaders, additionalQueryParams) + Objects.hash(limit, offset, additionalHeaders, additionalQueryParams) override fun toString() = - "JobAutomatedListParams{entityId=$entityId, limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "JobAutomatedListParams{limit=$limit, offset=$offset, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedRetrieveParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedRetrieveParams.kt index 86a9424f..d1abb27b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedRetrieveParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedRetrieveParams.kt @@ -13,20 +13,12 @@ import kotlin.jvm.optionals.getOrNull class JobAutomatedRetrieveParams private constructor( private val jobId: String?, - private val entityId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun jobId(): Optional = Optional.ofNullable(jobId) - /** - * The entity ID to use when authenticating with a multi-account token. Required when using a - * multi-account token to specify which entity's data to access. Example: - * `123e4567-e89b-12d3-a456-426614174000` - */ - fun entityId(): Optional = Optional.ofNullable(entityId) - /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -49,14 +41,12 @@ private constructor( class Builder internal constructor() { private var jobId: String? = null - private var entityId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(jobAutomatedRetrieveParams: JobAutomatedRetrieveParams) = apply { jobId = jobAutomatedRetrieveParams.jobId - entityId = jobAutomatedRetrieveParams.entityId additionalHeaders = jobAutomatedRetrieveParams.additionalHeaders.toBuilder() additionalQueryParams = jobAutomatedRetrieveParams.additionalQueryParams.toBuilder() } @@ -66,16 +56,6 @@ private constructor( /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) - /** - * The entity ID to use when authenticating with a multi-account token. Required when using - * a multi-account token to specify which entity's data to access. Example: - * `123e4567-e89b-12d3-a456-426614174000` - */ - fun entityId(entityId: String?) = apply { this.entityId = entityId } - - /** Alias for calling [Builder.entityId] with `entityId.orElse(null)`. */ - fun entityId(entityId: Optional) = entityId(entityId.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -182,7 +162,6 @@ private constructor( fun build(): JobAutomatedRetrieveParams = JobAutomatedRetrieveParams( jobId, - entityId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -196,13 +175,7 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - entityId?.let { put("entity_id", it) } - putAll(additionalQueryParams) - } - .build() + override fun _queryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -211,14 +184,12 @@ private constructor( return other is JobAutomatedRetrieveParams && jobId == other.jobId && - entityId == other.entityId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = - Objects.hash(jobId, entityId, additionalHeaders, additionalQueryParams) + override fun hashCode(): Int = Objects.hash(jobId, additionalHeaders, additionalQueryParams) override fun toString() = - "JobAutomatedRetrieveParams{jobId=$jobId, entityId=$entityId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "JobAutomatedRetrieveParams{jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCompletionEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCompletionEvent.kt index 52c576f5..7b47622e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCompletionEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCompletionEvent.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class JobCompletionEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountId: JsonField, private val companyId: JsonField, @@ -324,6 +325,7 @@ private constructor( (eventType.asKnown().getOrNull()?.validity() ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val jobId: JsonField, private val jobUrl: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCreateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCreateResponse.kt index 1af4be7a..01930c0c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCreateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCreateResponse.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class JobCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val allowedRefreshes: JsonField, private val jobId: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobManualRetrieveParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobManualRetrieveParams.kt index a1a4d175..110f2317 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobManualRetrieveParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobManualRetrieveParams.kt @@ -16,20 +16,12 @@ import kotlin.jvm.optionals.getOrNull class JobManualRetrieveParams private constructor( private val jobId: String?, - private val entityId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { fun jobId(): Optional = Optional.ofNullable(jobId) - /** - * The entity ID to use when authenticating with a multi-account token. Required when using a - * multi-account token to specify which entity's data to access. Example: - * `123e4567-e89b-12d3-a456-426614174000` - */ - fun entityId(): Optional = Optional.ofNullable(entityId) - /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -50,14 +42,12 @@ private constructor( class Builder internal constructor() { private var jobId: String? = null - private var entityId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(jobManualRetrieveParams: JobManualRetrieveParams) = apply { jobId = jobManualRetrieveParams.jobId - entityId = jobManualRetrieveParams.entityId additionalHeaders = jobManualRetrieveParams.additionalHeaders.toBuilder() additionalQueryParams = jobManualRetrieveParams.additionalQueryParams.toBuilder() } @@ -67,16 +57,6 @@ private constructor( /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) - /** - * The entity ID to use when authenticating with a multi-account token. Required when using - * a multi-account token to specify which entity's data to access. Example: - * `123e4567-e89b-12d3-a456-426614174000` - */ - fun entityId(entityId: String?) = apply { this.entityId = entityId } - - /** Alias for calling [Builder.entityId] with `entityId.orElse(null)`. */ - fun entityId(entityId: Optional) = entityId(entityId.getOrNull()) - fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -181,12 +161,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): JobManualRetrieveParams = - JobManualRetrieveParams( - jobId, - entityId, - additionalHeaders.build(), - additionalQueryParams.build(), - ) + JobManualRetrieveParams(jobId, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = @@ -197,13 +172,7 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - entityId?.let { put("entity_id", it) } - putAll(additionalQueryParams) - } - .build() + override fun _queryParams(): QueryParams = additionalQueryParams override fun equals(other: Any?): Boolean { if (this === other) { @@ -212,14 +181,12 @@ private constructor( return other is JobManualRetrieveParams && jobId == other.jobId && - entityId == other.entityId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = - Objects.hash(jobId, entityId, additionalHeaders, additionalQueryParams) + override fun hashCode(): Int = Objects.hash(jobId, additionalHeaders, additionalQueryParams) override fun toString() = - "JobManualRetrieveParams{jobId=$jobId, entityId=$entityId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "JobManualRetrieveParams{jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } 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 857bb56c..5f7a926e 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 @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class Location +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val city: JsonField, private val country: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ManualAsyncJob.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ManualAsyncJob.kt index 18fb4cc8..15b3d124 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ManualAsyncJob.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ManualAsyncJob.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class ManualAsyncJob +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val body: JsonField>, private val jobId: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Money.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Money.kt index 89d954bd..7790ef4e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Money.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Money.kt @@ -18,6 +18,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class Money +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val currency: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/OperationSupportMatrix.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/OperationSupportMatrix.kt index 237e66b5..e66ea860 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/OperationSupportMatrix.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/OperationSupportMatrix.kt @@ -17,6 +17,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class OperationSupportMatrix +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val create: JsonField, private val delete: JsonField, 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 421a092e..b1c025ab 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 @@ -17,6 +17,7 @@ import java.util.Objects import java.util.Optional class Paging +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val offset: JsonField, private val count: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupListResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupListResponse.kt index deb98373..a164bdc4 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupListResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupListResponse.kt @@ -20,6 +20,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class PayGroupListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val name: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupRetrieveResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupRetrieveResponse.kt index 949a01fa..acb630a8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupRetrieveResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupRetrieveResponse.kt @@ -20,6 +20,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class PayGroupRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val individualIds: JsonField>, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt index c0d7a035..00fcc100 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt @@ -21,15 +21,16 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PayStatement +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val earnings: JsonField>, - private val employeeDeductions: JsonField>, - private val employerContributions: JsonField>, + private val employeeDeductions: JsonField>, + private val employerContributions: JsonField>, private val grossPay: JsonField, private val individualId: JsonField, private val netPay: JsonField, private val paymentMethod: JsonField, - private val taxes: JsonField>, + private val taxes: JsonField>, private val totalHours: JsonField, private val type: JsonField, private val additionalProperties: MutableMap, @@ -42,10 +43,10 @@ private constructor( earnings: JsonField> = JsonMissing.of(), @JsonProperty("employee_deductions") @ExcludeMissing - employeeDeductions: JsonField> = JsonMissing.of(), + employeeDeductions: JsonField> = JsonMissing.of(), @JsonProperty("employer_contributions") @ExcludeMissing - employerContributions: JsonField> = JsonMissing.of(), + employerContributions: JsonField> = JsonMissing.of(), @JsonProperty("gross_pay") @ExcludeMissing grossPay: JsonField = JsonMissing.of(), @JsonProperty("individual_id") @ExcludeMissing @@ -54,7 +55,7 @@ private constructor( @JsonProperty("payment_method") @ExcludeMissing paymentMethod: JsonField = JsonMissing.of(), - @JsonProperty("taxes") @ExcludeMissing taxes: JsonField> = JsonMissing.of(), + @JsonProperty("taxes") @ExcludeMissing taxes: JsonField> = JsonMissing.of(), @JsonProperty("total_hours") @ExcludeMissing totalHours: JsonField = JsonMissing.of(), @@ -87,14 +88,14 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun employeeDeductions(): Optional> = + fun employeeDeductions(): Optional> = employeeDeductions.getOptional("employee_deductions") /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun employerContributions(): Optional> = + fun employerContributions(): Optional> = employerContributions.getOptional("employer_contributions") /** @@ -131,7 +132,7 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun taxes(): Optional> = taxes.getOptional("taxes") + fun taxes(): Optional> = taxes.getOptional("taxes") /** * The number of hours worked for this pay period @@ -164,7 +165,7 @@ private constructor( */ @JsonProperty("employee_deductions") @ExcludeMissing - fun _employeeDeductions(): JsonField> = employeeDeductions + fun _employeeDeductions(): JsonField> = employeeDeductions /** * Returns the raw JSON value of [employerContributions]. @@ -174,7 +175,7 @@ private constructor( */ @JsonProperty("employer_contributions") @ExcludeMissing - fun _employerContributions(): JsonField> = employerContributions + fun _employerContributions(): JsonField> = employerContributions /** * Returns the raw JSON value of [grossPay]. @@ -213,7 +214,7 @@ private constructor( * * Unlike [taxes], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("taxes") @ExcludeMissing fun _taxes(): JsonField> = taxes + @JsonProperty("taxes") @ExcludeMissing fun _taxes(): JsonField> = taxes /** * Returns the raw JSON value of [totalHours]. @@ -267,13 +268,13 @@ private constructor( class Builder internal constructor() { private var earnings: JsonField>? = null - private var employeeDeductions: JsonField>? = null - private var employerContributions: JsonField>? = null + private var employeeDeductions: JsonField>? = null + private var employerContributions: JsonField>? = null private var grossPay: JsonField? = null private var individualId: JsonField? = null private var netPay: JsonField? = null private var paymentMethod: JsonField? = null - private var taxes: JsonField>? = null + private var taxes: JsonField>? = null private var totalHours: JsonField? = null private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -323,23 +324,23 @@ private constructor( } /** The array of deductions objects associated with this pay statement. */ - fun employeeDeductions(employeeDeductions: List?) = + fun employeeDeductions(employeeDeductions: List?) = employeeDeductions(JsonField.ofNullable(employeeDeductions)) /** * Alias for calling [Builder.employeeDeductions] with `employeeDeductions.orElse(null)`. */ - fun employeeDeductions(employeeDeductions: Optional>) = + fun employeeDeductions(employeeDeductions: Optional>) = employeeDeductions(employeeDeductions.getOrNull()) /** * Sets [Builder.employeeDeductions] to an arbitrary JSON value. * * You should usually call [Builder.employeeDeductions] with a well-typed - * `List` value instead. This method is primarily for setting the field + * `List` value instead. This method is primarily for setting the field * to an undocumented or not yet supported value. */ - fun employeeDeductions(employeeDeductions: JsonField>) = apply { + fun employeeDeductions(employeeDeductions: JsonField>) = apply { this.employeeDeductions = employeeDeductions.map { it.toMutableList() } } @@ -355,24 +356,24 @@ private constructor( } } - fun employerContributions(employerContributions: List?) = + fun employerContributions(employerContributions: List?) = employerContributions(JsonField.ofNullable(employerContributions)) /** * Alias for calling [Builder.employerContributions] with * `employerContributions.orElse(null)`. */ - fun employerContributions(employerContributions: Optional>) = + fun employerContributions(employerContributions: Optional>) = employerContributions(employerContributions.getOrNull()) /** * Sets [Builder.employerContributions] to an arbitrary JSON value. * * You should usually call [Builder.employerContributions] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun employerContributions(employerContributions: JsonField>) = + fun employerContributions(employerContributions: JsonField>) = apply { this.employerContributions = employerContributions.map { it.toMutableList() } } @@ -449,19 +450,18 @@ private constructor( } /** The array of taxes objects associated with this pay statement. */ - fun taxes(taxes: List?) = taxes(JsonField.ofNullable(taxes)) + fun taxes(taxes: List?) = taxes(JsonField.ofNullable(taxes)) /** Alias for calling [Builder.taxes] with `taxes.orElse(null)`. */ - fun taxes(taxes: Optional>) = taxes(taxes.getOrNull()) + fun taxes(taxes: Optional>) = taxes(taxes.getOrNull()) /** * Sets [Builder.taxes] to an arbitrary JSON value. * - * You should usually call [Builder.taxes] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.taxes] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun taxes(taxes: JsonField>) = apply { + fun taxes(taxes: JsonField>) = apply { this.taxes = taxes.map { it.toMutableList() } } @@ -577,13 +577,13 @@ private constructor( } earnings().ifPresent { it.forEach { it?.validate() } } - employeeDeductions().ifPresent { it.forEach { it?.validate() } } - employerContributions().ifPresent { it.forEach { it?.validate() } } + employeeDeductions().ifPresent { it.forEach { it.validate() } } + employerContributions().ifPresent { it.forEach { it.validate() } } grossPay().ifPresent { it.validate() } individualId() netPay().ifPresent { it.validate() } paymentMethod().ifPresent { it.validate() } - taxes().ifPresent { it.forEach { it?.validate() } } + taxes().ifPresent { it.forEach { it.validate() } } totalHours() type().ifPresent { it.validate() } validated = true @@ -605,19 +605,18 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (earnings.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (employeeDeductions.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) + - (employerContributions.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) + + (employeeDeductions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (employerContributions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (grossPay.asKnown().getOrNull()?.validity() ?: 0) + (if (individualId.asKnown().isPresent) 1 else 0) + (netPay.asKnown().getOrNull()?.validity() ?: 0) + (paymentMethod.asKnown().getOrNull()?.validity() ?: 0) + - (taxes.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + + (taxes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (totalHours.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) class Earning + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val currency: JsonField, @@ -1173,6 +1172,7 @@ private constructor( } class Attributes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val metadata: JsonField, private val additionalProperties: MutableMap, @@ -1186,6 +1186,9 @@ private constructor( ) : this(metadata, mutableMapOf()) /** + * The metadata to be attached to the entity by existing rules. It is a key-value pairs + * where the values can be of any type (string, number, boolean, object, array, etc.). + * * @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). @@ -1239,6 +1242,11 @@ private constructor( additionalProperties = attributes.additionalProperties.toMutableMap() } + /** + * The metadata to be attached to the entity by existing rules. It is a key-value + * pairs where the values can be of any type (string, number, boolean, object, + * array, etc.). + */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** @@ -1319,95 +1327,39 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** + * The metadata to be attached to the entity by existing rules. It is a key-value pairs + * where the values can be of any type (string, number, boolean, object, array, etc.). + */ class Metadata + @JsonCreator private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - * - * @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 metadata(): InnerMetadata = metadata.getRequired("metadata") - - /** - * 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 - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [Metadata]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ class Builder internal constructor() { - private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata additionalProperties = metadata.additionalProperties.toMutableMap() } - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [InnerMetadata] - * 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 - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1434,19 +1386,8 @@ private constructor( * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = - Metadata( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false @@ -1456,7 +1397,6 @@ private constructor( return@apply } - metadata().validate() validated = true } @@ -1475,140 +1415,24 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - */ - class InnerMetadata - @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 - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = innerMetadata.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 [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = 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 other is InnerMetadata && - additionalProperties == other.additionalProperties + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && - metadata == other.metadata && - additionalProperties == other.additionalProperties + return other is Metadata && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1655,6 +1479,7 @@ private constructor( } class EmployeeDeduction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val currency: JsonField, @@ -2012,6 +1837,7 @@ private constructor( (attributes.asKnown().getOrNull()?.validity() ?: 0) class Attributes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val metadata: JsonField, private val additionalProperties: MutableMap, @@ -2025,6 +1851,9 @@ private constructor( ) : this(metadata, mutableMapOf()) /** + * The metadata to be attached to the entity by existing rules. It is a key-value pairs + * where the values can be of any type (string, number, boolean, object, array, etc.). + * * @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). @@ -2078,6 +1907,11 @@ private constructor( additionalProperties = attributes.additionalProperties.toMutableMap() } + /** + * The metadata to be attached to the entity by existing rules. It is a key-value + * pairs where the values can be of any type (string, number, boolean, object, + * array, etc.). + */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** @@ -2158,95 +1992,39 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** + * The metadata to be attached to the entity by existing rules. It is a key-value pairs + * where the values can be of any type (string, number, boolean, object, array, etc.). + */ class Metadata + @JsonCreator private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - * - * @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 metadata(): InnerMetadata = metadata.getRequired("metadata") - - /** - * 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 - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [Metadata]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ class Builder internal constructor() { - private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata additionalProperties = metadata.additionalProperties.toMutableMap() } - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [InnerMetadata] - * 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 - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2273,19 +2051,8 @@ private constructor( * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = - Metadata( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false @@ -2295,7 +2062,6 @@ private constructor( return@apply } - metadata().validate() validated = true } @@ -2314,140 +2080,24 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - */ - class InnerMetadata - @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 - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = innerMetadata.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 [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - private var validated: Boolean = false - - fun validate(): InnerMetadata = 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 other is InnerMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && - metadata == other.metadata && - additionalProperties == other.additionalProperties + return other is Metadata && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -2494,6 +2144,7 @@ private constructor( } class EmployerContribution + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val currency: JsonField, private val name: JsonField, @@ -2803,6 +2454,7 @@ private constructor( (attributes.asKnown().getOrNull()?.validity() ?: 0) class Attributes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val metadata: JsonField, private val additionalProperties: MutableMap, @@ -2816,6 +2468,9 @@ private constructor( ) : this(metadata, mutableMapOf()) /** + * The metadata to be attached to the entity by existing rules. It is a key-value pairs + * where the values can be of any type (string, number, boolean, object, array, etc.). + * * @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). @@ -2869,6 +2524,11 @@ private constructor( additionalProperties = attributes.additionalProperties.toMutableMap() } + /** + * The metadata to be attached to the entity by existing rules. It is a key-value + * pairs where the values can be of any type (string, number, boolean, object, + * array, etc.). + */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** @@ -2949,95 +2609,39 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** + * The metadata to be attached to the entity by existing rules. It is a key-value pairs + * where the values can be of any type (string, number, boolean, object, array, etc.). + */ class Metadata + @JsonCreator private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - * - * @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 metadata(): InnerMetadata = metadata.getRequired("metadata") - - /** - * 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 - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [Metadata]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ class Builder internal constructor() { - private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata additionalProperties = metadata.additionalProperties.toMutableMap() } - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [InnerMetadata] - * 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 - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3064,19 +2668,8 @@ private constructor( * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = - Metadata( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false @@ -3086,7 +2679,6 @@ private constructor( return@apply } - metadata().validate() validated = true } @@ -3105,140 +2697,24 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - */ - class InnerMetadata - @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 - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = innerMetadata.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 [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = 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 other is InnerMetadata && - additionalProperties == other.additionalProperties + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && - metadata == other.metadata && - additionalProperties == other.additionalProperties + return other is Metadata && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -3419,6 +2895,7 @@ private constructor( } class Tax + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val currency: JsonField, private val employer: JsonField, @@ -3916,6 +3393,7 @@ private constructor( } class Attributes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val metadata: JsonField, private val additionalProperties: MutableMap, @@ -3929,6 +3407,9 @@ private constructor( ) : this(metadata, mutableMapOf()) /** + * The metadata to be attached to the entity by existing rules. It is a key-value pairs + * where the values can be of any type (string, number, boolean, object, array, etc.). + * * @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). @@ -3982,6 +3463,11 @@ private constructor( additionalProperties = attributes.additionalProperties.toMutableMap() } + /** + * The metadata to be attached to the entity by existing rules. It is a key-value + * pairs where the values can be of any type (string, number, boolean, object, + * array, etc.). + */ fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) /** @@ -4062,95 +3548,39 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + /** + * The metadata to be attached to the entity by existing rules. It is a key-value pairs + * where the values can be of any type (string, number, boolean, object, array, etc.). + */ class Metadata + @JsonCreator private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - * - * @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 metadata(): InnerMetadata = metadata.getRequired("metadata") - - /** - * 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 - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [Metadata]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Metadata]. */ @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ class Builder internal constructor() { - private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata additionalProperties = metadata.additionalProperties.toMutableMap() } - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [InnerMetadata] - * 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 - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -4177,19 +3607,8 @@ private constructor( * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = - Metadata( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) + fun build(): Metadata = Metadata(additionalProperties.toImmutable()) } private var validated: Boolean = false @@ -4199,7 +3618,6 @@ private constructor( return@apply } - metadata().validate() validated = true } @@ -4218,140 +3636,24 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - */ - class InnerMetadata - @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 - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = innerMetadata.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 [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = 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 other is InnerMetadata && - additionalProperties == other.additionalProperties + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() } - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Metadata && - metadata == other.metadata && - additionalProperties == other.additionalProperties + return other is Metadata && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgress.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgress.kt index 4a0f4e6d..b28b0965 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgress.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgress.kt @@ -18,6 +18,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class PayStatementDataSyncInProgress +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val code: JsonField, private val finchCode: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementEvent.kt index fd55e536..bd2369e9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementEvent.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PayStatementEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountId: JsonField, private val companyId: JsonField, @@ -324,6 +325,7 @@ private constructor( (eventType.asKnown().getOrNull()?.validity() ?: 0) class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val individualId: JsonField, private val paymentId: JsonField, 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 156ac4c0..5c689b69 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 @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PayStatementItemListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val attributes: JsonField, private val category: JsonField, @@ -237,6 +238,7 @@ private constructor( /** The attributes of the pay statement item. */ class Attributes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val metadata: JsonField, private val employer: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponse.kt index 506a7962..a6b413e6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponse.kt @@ -29,6 +29,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PayStatementResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val body: JsonField, private val code: JsonField, @@ -464,6 +465,7 @@ private constructor( } class BatchError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val code: JsonField, private val message: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponseBody.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponseBody.kt index 4aea2be8..1469582f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponseBody.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponseBody.kt @@ -20,6 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PayStatementResponseBody +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val paging: JsonField, private val payStatements: JsonField>, @@ -209,6 +210,7 @@ private constructor( (payStatements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) class Paging + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val offset: JsonField, private val count: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Payment.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Payment.kt index b4b48b0e..9323559f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Payment.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Payment.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class Payment +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val companyDebit: JsonField, @@ -831,6 +832,7 @@ private constructor( /** The pay period object. */ class PayPeriod + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val endDate: JsonField, private val startDate: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentCreateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentCreateResponse.kt index d03e5ab1..f7f4ae99 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentCreateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentCreateResponse.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class PaymentCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val payDate: JsonField, private val paymentId: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentEvent.kt index a187499b..6191a5f3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentEvent.kt @@ -19,6 +19,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class PaymentEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountId: JsonField, private val companyId: JsonField, @@ -327,6 +328,7 @@ private constructor( (eventType.asKnown().getOrNull()?.validity() ?: 0) class PaymentIdentifiers + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val payDate: JsonField, private val paymentId: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Provider.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Provider.kt index a7a21494..94ccb0dd 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Provider.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Provider.kt @@ -21,30 +21,34 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class Provider +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, + private val displayName: JsonField, + private val products: JsonField>, private val authenticationMethods: JsonField>, private val beta: JsonField, - private val displayName: JsonField, private val icon: JsonField, private val logo: JsonField, private val manual: JsonField, private val mfaRequired: JsonField, private val primaryColor: JsonField, - private val products: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("products") + @ExcludeMissing + products: JsonField> = JsonMissing.of(), @JsonProperty("authentication_methods") @ExcludeMissing authenticationMethods: JsonField> = JsonMissing.of(), @JsonProperty("beta") @ExcludeMissing beta: JsonField = JsonMissing.of(), - @JsonProperty("display_name") - @ExcludeMissing - displayName: JsonField = JsonMissing.of(), @JsonProperty("icon") @ExcludeMissing icon: JsonField = JsonMissing.of(), @JsonProperty("logo") @ExcludeMissing logo: JsonField = JsonMissing.of(), @JsonProperty("manual") @ExcludeMissing manual: JsonField = JsonMissing.of(), @@ -54,55 +58,60 @@ private constructor( @JsonProperty("primary_color") @ExcludeMissing primaryColor: JsonField = JsonMissing.of(), - @JsonProperty("products") - @ExcludeMissing - products: JsonField> = JsonMissing.of(), ) : this( id, + displayName, + products, authenticationMethods, beta, - displayName, icon, logo, manual, mfaRequired, primaryColor, - products, mutableMapOf(), ) /** * The id of the payroll provider used in Connect. * - * @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 list of authentication methods supported by the provider. + * The display name of the payroll provider. * - * @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 authenticationMethods(): Optional> = - authenticationMethods.getOptional("authentication_methods") + fun displayName(): String = displayName.getRequired("display_name") /** - * `true` if the integration is in a beta state, `false` otherwise + * The list of Finch products supported on this payroll provider. + * + * @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 products(): List = products.getRequired("products") + + /** + * The authentication methods supported by the provider. * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun beta(): Optional = beta.getOptional("beta") + fun authenticationMethods(): Optional> = + authenticationMethods.getOptional("authentication_methods") /** - * The display name of the payroll provider. + * `true` if the integration is in a beta state, `false` otherwise * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun displayName(): Optional = displayName.getOptional("display_name") + fun beta(): Optional = beta.getOptional("beta") /** * The url to the official icon of the payroll provider. @@ -128,7 +137,7 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun manual(): Optional = manual.getOptional("manual") + @Deprecated("deprecated") fun manual(): Optional = manual.getOptional("manual") /** * whether MFA is required for the provider. @@ -147,19 +156,27 @@ private constructor( fun primaryColor(): Optional = primaryColor.getOptional("primary_color") /** - * The list of Finch products supported on this payroll provider. + * Returns the raw JSON value of [id]. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - fun products(): Optional> = products.getOptional("products") + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [id]. + * Returns the raw JSON value of [displayName]. * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [products]. + * + * Unlike [products], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("products") @ExcludeMissing fun _products(): JsonField> = products /** * Returns the raw JSON value of [authenticationMethods]. @@ -178,15 +195,6 @@ private constructor( */ @JsonProperty("beta") @ExcludeMissing fun _beta(): JsonField = beta - /** - * Returns the raw JSON value of [displayName]. - * - * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("display_name") - @ExcludeMissing - fun _displayName(): JsonField = displayName - /** * Returns the raw JSON value of [icon]. * @@ -206,7 +214,10 @@ private constructor( * * Unlike [manual], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("manual") @ExcludeMissing fun _manual(): JsonField = manual + @Deprecated("deprecated") + @JsonProperty("manual") + @ExcludeMissing + fun _manual(): JsonField = manual /** * Returns the raw JSON value of [mfaRequired]. @@ -226,13 +237,6 @@ private constructor( @ExcludeMissing fun _primaryColor(): JsonField = primaryColor - /** - * Returns the raw JSON value of [products]. - * - * Unlike [products], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("products") @ExcludeMissing fun _products(): JsonField> = products - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -247,37 +251,46 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Provider]. */ + /** + * Returns a mutable builder for constructing an instance of [Provider]. + * + * The following fields are required: + * ```java + * .id() + * .displayName() + * .products() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Provider]. */ class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var displayName: JsonField? = null + private var products: JsonField>? = null private var authenticationMethods: JsonField>? = null private var beta: JsonField = JsonMissing.of() - private var displayName: JsonField = JsonMissing.of() private var icon: JsonField = JsonMissing.of() private var logo: JsonField = JsonMissing.of() private var manual: JsonField = JsonMissing.of() private var mfaRequired: JsonField = JsonMissing.of() private var primaryColor: JsonField = JsonMissing.of() - private var products: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(provider: Provider) = apply { id = provider.id + displayName = provider.displayName + products = provider.products.map { it.toMutableList() } authenticationMethods = provider.authenticationMethods.map { it.toMutableList() } beta = provider.beta - displayName = provider.displayName icon = provider.icon logo = provider.logo manual = provider.manual mfaRequired = provider.mfaRequired primaryColor = provider.primaryColor - products = provider.products.map { it.toMutableList() } additionalProperties = provider.additionalProperties.toMutableMap() } @@ -292,7 +305,45 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - /** The list of authentication methods supported by the provider. */ + /** The display name of the payroll provider. */ + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField) = apply { this.displayName = displayName } + + /** The list of Finch products supported on this payroll provider. */ + fun products(products: List) = products(JsonField.of(products)) + + /** + * Sets [Builder.products] to an arbitrary JSON value. + * + * You should usually call [Builder.products] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [products]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addProduct(product: String) = apply { + products = + (products ?: JsonField.of(mutableListOf())).also { + checkKnown("products", it).add(product) + } + } + + /** The authentication methods supported by the provider. */ fun authenticationMethods(authenticationMethods: List) = authenticationMethods(JsonField.of(authenticationMethods)) @@ -331,18 +382,6 @@ private constructor( */ fun beta(beta: JsonField) = apply { this.beta = beta } - /** The display name of the payroll provider. */ - fun displayName(displayName: String) = displayName(JsonField.of(displayName)) - - /** - * Sets [Builder.displayName] to an arbitrary JSON value. - * - * You should usually call [Builder.displayName] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun displayName(displayName: JsonField) = apply { this.displayName = displayName } - /** The url to the official icon of the payroll provider. */ fun icon(icon: String) = icon(JsonField.of(icon)) @@ -370,7 +409,7 @@ private constructor( * Flow by default. This field is now deprecated. Please check for a `type` of `assisted` in * the `authentication_methods` field instead. */ - fun manual(manual: Boolean) = manual(JsonField.of(manual)) + @Deprecated("deprecated") fun manual(manual: Boolean) = manual(JsonField.of(manual)) /** * Sets [Builder.manual] to an arbitrary JSON value. @@ -378,6 +417,7 @@ private constructor( * You should usually call [Builder.manual] with a well-typed [Boolean] value instead. This * method is primarily for setting the field to an undocumented or not yet supported value. */ + @Deprecated("deprecated") fun manual(manual: JsonField) = apply { this.manual = manual } /** whether MFA is required for the provider. */ @@ -406,32 +446,6 @@ private constructor( this.primaryColor = primaryColor } - /** The list of Finch products supported on this payroll provider. */ - fun products(products: List) = products(JsonField.of(products)) - - /** - * Sets [Builder.products] to an arbitrary JSON value. - * - * You should usually call [Builder.products] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun products(products: JsonField>) = apply { - this.products = products.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [products]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addProduct(product: String) = apply { - products = - (products ?: JsonField.of(mutableListOf())).also { - checkKnown("products", it).add(product) - } - } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -455,19 +469,28 @@ private constructor( * Returns an immutable instance of [Provider]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .displayName() + * .products() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Provider = Provider( - id, + checkRequired("id", id), + checkRequired("displayName", displayName), + checkRequired("products", products).map { it.toImmutable() }, (authenticationMethods ?: JsonMissing.of()).map { it.toImmutable() }, beta, - displayName, icon, logo, manual, mfaRequired, primaryColor, - (products ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -480,15 +503,15 @@ private constructor( } id() + displayName() + products() authenticationMethods().ifPresent { it.forEach { it.validate() } } beta() - displayName() icon() logo() manual() mfaRequired() primaryColor() - products() validated = true } @@ -508,38 +531,46 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (products.asKnown().getOrNull()?.size ?: 0) + (authenticationMethods.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (beta.asKnown().isPresent) 1 else 0) + - (if (displayName.asKnown().isPresent) 1 else 0) + (if (icon.asKnown().isPresent) 1 else 0) + (if (logo.asKnown().isPresent) 1 else 0) + (if (manual.asKnown().isPresent) 1 else 0) + (if (mfaRequired.asKnown().isPresent) 1 else 0) + - (if (primaryColor.asKnown().isPresent) 1 else 0) + - (products.asKnown().getOrNull()?.size ?: 0) + (if (primaryColor.asKnown().isPresent) 1 else 0) class AuthenticationMethod + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val type: JsonField, private val benefitsSupport: JsonField, private val supportedFields: JsonField, - private val type: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @JsonProperty("benefits_support") @ExcludeMissing benefitsSupport: JsonField = JsonMissing.of(), @JsonProperty("supported_fields") @ExcludeMissing supportedFields: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(benefitsSupport, supportedFields, type, mutableMapOf()) + ) : this(type, benefitsSupport, supportedFields, mutableMapOf()) + + /** + * The type of authentication 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). + */ + fun type(): Type = type.getRequired("type") /** - * Each benefit type and their supported features. If the benefit type is not supported, the - * property will be null + * The supported benefit types and their configurations * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -548,7 +579,7 @@ private constructor( benefitsSupport.getOptional("benefits_support") /** - * The supported data fields returned by our HR and payroll endpoints + * The supported fields for each Finch product * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -557,12 +588,11 @@ private constructor( supportedFields.getOptional("supported_fields") /** - * The type of authentication method. + * Returns the raw JSON value of [type]. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - fun type(): Optional = type.getOptional("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * Returns the raw JSON value of [benefitsSupport]. @@ -584,13 +614,6 @@ private constructor( @ExcludeMissing fun _supportedFields(): JsonField = supportedFields - /** - * 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) @@ -605,36 +628,48 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [AuthenticationMethod]. */ + /** + * Returns a mutable builder for constructing an instance of [AuthenticationMethod]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [AuthenticationMethod]. */ class Builder internal constructor() { + private var type: JsonField? = null private var benefitsSupport: JsonField = JsonMissing.of() private var supportedFields: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(authenticationMethod: AuthenticationMethod) = apply { + type = authenticationMethod.type benefitsSupport = authenticationMethod.benefitsSupport supportedFields = authenticationMethod.supportedFields - type = authenticationMethod.type additionalProperties = authenticationMethod.additionalProperties.toMutableMap() } + /** The type of authentication method */ + fun type(type: Type) = type(JsonField.of(type)) + /** - * Each benefit type and their supported features. If the benefit type is not supported, - * the property will be null + * 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 benefitsSupport(benefitsSupport: BenefitsSupport?) = - benefitsSupport(JsonField.ofNullable(benefitsSupport)) + fun type(type: JsonField) = apply { this.type = type } - /** Alias for calling [Builder.benefitsSupport] with `benefitsSupport.orElse(null)`. */ - fun benefitsSupport(benefitsSupport: Optional) = - benefitsSupport(benefitsSupport.getOrNull()) + /** The supported benefit types and their configurations */ + fun benefitsSupport(benefitsSupport: BenefitsSupport) = + benefitsSupport(JsonField.of(benefitsSupport)) /** * Sets [Builder.benefitsSupport] to an arbitrary JSON value. @@ -647,13 +682,9 @@ private constructor( this.benefitsSupport = benefitsSupport } - /** The supported data fields returned by our HR and payroll endpoints */ - fun supportedFields(supportedFields: SupportedFields?) = - supportedFields(JsonField.ofNullable(supportedFields)) - - /** Alias for calling [Builder.supportedFields] with `supportedFields.orElse(null)`. */ - fun supportedFields(supportedFields: Optional) = - supportedFields(supportedFields.getOrNull()) + /** The supported fields for each Finch product */ + fun supportedFields(supportedFields: SupportedFields) = + supportedFields(JsonField.of(supportedFields)) /** * Sets [Builder.supportedFields] to an arbitrary JSON value. @@ -666,18 +697,6 @@ private constructor( this.supportedFields = supportedFields } - /** The type of authentication method. */ - 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) @@ -701,12 +720,19 @@ private constructor( * Returns an immutable instance of [AuthenticationMethod]. * * 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(): AuthenticationMethod = AuthenticationMethod( + checkRequired("type", type), benefitsSupport, supportedFields, - type, additionalProperties.toMutableMap(), ) } @@ -718,9 +744,9 @@ private constructor( return@apply } + type().validate() benefitsSupport().ifPresent { it.validate() } supportedFields().ifPresent { it.validate() } - type().ifPresent { it.validate() } validated = true } @@ -740,9365 +766,36 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (benefitsSupport.asKnown().getOrNull()?.validity() ?: 0) + - (supportedFields.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - /** The supported data fields returned by our HR and payroll endpoints */ - class SupportedFields - private constructor( - private val company: JsonField, - private val directory: JsonField, - private val employment: JsonField, - private val individual: JsonField, - private val payGroup: JsonField, - private val payStatement: JsonField, - private val payment: JsonField, - private val additionalProperties: MutableMap, - ) { + (type.asKnown().getOrNull()?.validity() ?: 0) + + (benefitsSupport.asKnown().getOrNull()?.validity() ?: 0) + + (supportedFields.asKnown().getOrNull()?.validity() ?: 0) - @JsonCreator - private constructor( - @JsonProperty("company") - @ExcludeMissing - company: JsonField = JsonMissing.of(), - @JsonProperty("directory") - @ExcludeMissing - directory: JsonField = JsonMissing.of(), - @JsonProperty("employment") - @ExcludeMissing - employment: JsonField = JsonMissing.of(), - @JsonProperty("individual") - @ExcludeMissing - individual: JsonField = JsonMissing.of(), - @JsonProperty("pay_group") - @ExcludeMissing - payGroup: JsonField = JsonMissing.of(), - @JsonProperty("pay_statement") - @ExcludeMissing - payStatement: JsonField = JsonMissing.of(), - @JsonProperty("payment") - @ExcludeMissing - payment: JsonField = JsonMissing.of(), - ) : this( - company, - directory, - employment, - individual, - payGroup, - payStatement, - payment, - mutableMapOf(), - ) + /** The type of authentication method */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected 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. */ - fun company(): Optional = company.getOptional("company") + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun directory(): Optional = directory.getOptional("directory") + companion 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") + @JvmField val ASSISTED = of("assisted") - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun individual(): Optional = - individual.getOptional("individual") + @JvmField val CREDENTIAL = of("credential") - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun payGroup(): Optional = payGroup.getOptional("pay_group") + @JvmField val API_TOKEN = of("api_token") - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun payStatement(): Optional = - payStatement.getOptional("pay_statement") + @JvmField val API_CREDENTIAL = of("api_credential") - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun payment(): Optional = payment.getOptional("payment") + @JvmField val OAUTH = of("oauth") - /** - * Returns the raw JSON value of [company]. - * - * Unlike [company], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("company") - @ExcludeMissing - fun _company(): JsonField = company - - /** - * Returns the raw JSON value of [directory]. - * - * Unlike [directory], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("directory") - @ExcludeMissing - fun _directory(): JsonField = directory - - /** - * 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 - - /** - * Returns the raw JSON value of [individual]. - * - * Unlike [individual], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("individual") - @ExcludeMissing - fun _individual(): JsonField = individual - - /** - * Returns the raw JSON value of [payGroup]. - * - * Unlike [payGroup], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("pay_group") - @ExcludeMissing - fun _payGroup(): JsonField = payGroup - - /** - * Returns the raw JSON value of [payStatement]. - * - * Unlike [payStatement], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("pay_statement") - @ExcludeMissing - fun _payStatement(): JsonField = payStatement - - /** - * Returns the raw JSON value of [payment]. - * - * Unlike [payment], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("payment") - @ExcludeMissing - fun _payment(): JsonField = payment - - @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 [SupportedFields]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SupportedFields]. */ - class Builder internal constructor() { - - private var company: JsonField = JsonMissing.of() - private var directory: JsonField = JsonMissing.of() - private var employment: JsonField = JsonMissing.of() - private var individual: JsonField = JsonMissing.of() - private var payGroup: JsonField = JsonMissing.of() - private var payStatement: JsonField = JsonMissing.of() - private var payment: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(supportedFields: SupportedFields) = apply { - company = supportedFields.company - directory = supportedFields.directory - employment = supportedFields.employment - individual = supportedFields.individual - payGroup = supportedFields.payGroup - payStatement = supportedFields.payStatement - payment = supportedFields.payment - additionalProperties = supportedFields.additionalProperties.toMutableMap() - } - - fun company(company: SupportedCompanyFields) = company(JsonField.of(company)) - - /** - * Sets [Builder.company] to an arbitrary JSON value. - * - * You should usually call [Builder.company] with a well-typed - * [SupportedCompanyFields] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun company(company: JsonField) = apply { - this.company = company - } - - fun directory(directory: SupportedDirectoryFields) = - directory(JsonField.of(directory)) - - /** - * Sets [Builder.directory] to an arbitrary JSON value. - * - * You should usually call [Builder.directory] with a well-typed - * [SupportedDirectoryFields] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun directory(directory: JsonField) = apply { - this.directory = directory - } - - fun employment(employment: SupportedEmploymentFields) = - employment(JsonField.of(employment)) - - /** - * Sets [Builder.employment] to an arbitrary JSON value. - * - * You should usually call [Builder.employment] with a well-typed - * [SupportedEmploymentFields] 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 - } - - fun individual(individual: SupportedIndividualFields) = - individual(JsonField.of(individual)) - - /** - * Sets [Builder.individual] to an arbitrary JSON value. - * - * You should usually call [Builder.individual] with a well-typed - * [SupportedIndividualFields] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun individual(individual: JsonField) = apply { - this.individual = individual - } - - fun payGroup(payGroup: SupportedPayGroupFields) = payGroup(JsonField.of(payGroup)) - - /** - * Sets [Builder.payGroup] to an arbitrary JSON value. - * - * You should usually call [Builder.payGroup] with a well-typed - * [SupportedPayGroupFields] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun payGroup(payGroup: JsonField) = apply { - this.payGroup = payGroup - } - - fun payStatement(payStatement: SupportedPayStatementFields) = - payStatement(JsonField.of(payStatement)) - - /** - * Sets [Builder.payStatement] to an arbitrary JSON value. - * - * You should usually call [Builder.payStatement] with a well-typed - * [SupportedPayStatementFields] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun payStatement(payStatement: JsonField) = apply { - this.payStatement = payStatement - } - - fun payment(payment: SupportedPaymentFields) = payment(JsonField.of(payment)) - - /** - * Sets [Builder.payment] to an arbitrary JSON value. - * - * You should usually call [Builder.payment] with a well-typed - * [SupportedPaymentFields] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun payment(payment: JsonField) = apply { - this.payment = payment - } - - 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 [SupportedFields]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SupportedFields = - SupportedFields( - company, - directory, - employment, - individual, - payGroup, - payStatement, - payment, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SupportedFields = apply { - if (validated) { - return@apply - } - - company().ifPresent { it.validate() } - directory().ifPresent { it.validate() } - employment().ifPresent { it.validate() } - individual().ifPresent { it.validate() } - payGroup().ifPresent { it.validate() } - payStatement().ifPresent { it.validate() } - payment().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 = - (company.asKnown().getOrNull()?.validity() ?: 0) + - (directory.asKnown().getOrNull()?.validity() ?: 0) + - (employment.asKnown().getOrNull()?.validity() ?: 0) + - (individual.asKnown().getOrNull()?.validity() ?: 0) + - (payGroup.asKnown().getOrNull()?.validity() ?: 0) + - (payStatement.asKnown().getOrNull()?.validity() ?: 0) + - (payment.asKnown().getOrNull()?.validity() ?: 0) - - class SupportedCompanyFields - private constructor( - private val id: JsonField, - private val accounts: JsonField, - private val departments: JsonField, - private val ein: JsonField, - private val entity: JsonField, - private val legalName: JsonField, - private val locations: JsonField, - private val primaryEmail: JsonField, - private val primaryPhoneNumber: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("accounts") - @ExcludeMissing - accounts: JsonField = JsonMissing.of(), - @JsonProperty("departments") - @ExcludeMissing - departments: JsonField = JsonMissing.of(), - @JsonProperty("ein") @ExcludeMissing ein: JsonField = JsonMissing.of(), - @JsonProperty("entity") - @ExcludeMissing - entity: JsonField = JsonMissing.of(), - @JsonProperty("legal_name") - @ExcludeMissing - legalName: JsonField = JsonMissing.of(), - @JsonProperty("locations") - @ExcludeMissing - locations: JsonField = JsonMissing.of(), - @JsonProperty("primary_email") - @ExcludeMissing - primaryEmail: JsonField = JsonMissing.of(), - @JsonProperty("primary_phone_number") - @ExcludeMissing - primaryPhoneNumber: JsonField = JsonMissing.of(), - ) : this( - id, - accounts, - departments, - ein, - entity, - legalName, - locations, - primaryEmail, - primaryPhoneNumber, - mutableMapOf(), - ) - - /** - * @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") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun accounts(): Optional = accounts.getOptional("accounts") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun departments(): Optional = departments.getOptional("departments") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun ein(): Optional = ein.getOptional("ein") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun entity(): Optional = entity.getOptional("entity") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun legalName(): Optional = legalName.getOptional("legal_name") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun locations(): Optional = locations.getOptional("locations") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun primaryEmail(): Optional = primaryEmail.getOptional("primary_email") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun primaryPhoneNumber(): Optional = - primaryPhoneNumber.getOptional("primary_phone_number") - - /** - * 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 - - /** - * Returns the raw JSON value of [accounts]. - * - * Unlike [accounts], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("accounts") - @ExcludeMissing - fun _accounts(): JsonField = accounts - - /** - * Returns the raw JSON value of [departments]. - * - * Unlike [departments], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("departments") - @ExcludeMissing - fun _departments(): JsonField = departments - - /** - * Returns the raw JSON value of [ein]. - * - * Unlike [ein], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ein") @ExcludeMissing fun _ein(): JsonField = ein - - /** - * Returns the raw JSON value of [entity]. - * - * Unlike [entity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("entity") @ExcludeMissing fun _entity(): JsonField = entity - - /** - * Returns the raw JSON value of [legalName]. - * - * Unlike [legalName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("legal_name") - @ExcludeMissing - fun _legalName(): JsonField = legalName - - /** - * Returns the raw JSON value of [locations]. - * - * Unlike [locations], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("locations") - @ExcludeMissing - fun _locations(): JsonField = locations - - /** - * Returns the raw JSON value of [primaryEmail]. - * - * Unlike [primaryEmail], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("primary_email") - @ExcludeMissing - fun _primaryEmail(): JsonField = primaryEmail - - /** - * Returns the raw JSON value of [primaryPhoneNumber]. - * - * Unlike [primaryPhoneNumber], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("primary_phone_number") - @ExcludeMissing - fun _primaryPhoneNumber(): JsonField = primaryPhoneNumber - - @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 - * [SupportedCompanyFields]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SupportedCompanyFields]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var accounts: JsonField = JsonMissing.of() - private var departments: JsonField = JsonMissing.of() - private var ein: JsonField = JsonMissing.of() - private var entity: JsonField = JsonMissing.of() - private var legalName: JsonField = JsonMissing.of() - private var locations: JsonField = JsonMissing.of() - private var primaryEmail: JsonField = JsonMissing.of() - private var primaryPhoneNumber: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(supportedCompanyFields: SupportedCompanyFields) = apply { - id = supportedCompanyFields.id - accounts = supportedCompanyFields.accounts - departments = supportedCompanyFields.departments - ein = supportedCompanyFields.ein - entity = supportedCompanyFields.entity - legalName = supportedCompanyFields.legalName - locations = supportedCompanyFields.locations - primaryEmail = supportedCompanyFields.primaryEmail - primaryPhoneNumber = supportedCompanyFields.primaryPhoneNumber - additionalProperties = - supportedCompanyFields.additionalProperties.toMutableMap() - } - - fun id(id: Boolean) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [Boolean] 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 accounts(accounts: Accounts) = accounts(JsonField.of(accounts)) - - /** - * Sets [Builder.accounts] to an arbitrary JSON value. - * - * You should usually call [Builder.accounts] with a well-typed [Accounts] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun accounts(accounts: JsonField) = apply { this.accounts = accounts } - - fun departments(departments: Departments) = - departments(JsonField.of(departments)) - - /** - * Sets [Builder.departments] to an arbitrary JSON value. - * - * You should usually call [Builder.departments] with a well-typed [Departments] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun departments(departments: JsonField) = apply { - this.departments = departments - } - - fun ein(ein: Boolean) = ein(JsonField.of(ein)) - - /** - * Sets [Builder.ein] to an arbitrary JSON value. - * - * You should usually call [Builder.ein] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ein(ein: JsonField) = apply { this.ein = ein } - - fun entity(entity: Entity) = entity(JsonField.of(entity)) - - /** - * Sets [Builder.entity] to an arbitrary JSON value. - * - * You should usually call [Builder.entity] with a well-typed [Entity] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun entity(entity: JsonField) = apply { this.entity = entity } - - fun legalName(legalName: Boolean) = legalName(JsonField.of(legalName)) - - /** - * Sets [Builder.legalName] to an arbitrary JSON value. - * - * You should usually call [Builder.legalName] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun legalName(legalName: JsonField) = apply { - this.legalName = legalName - } - - fun locations(locations: Locations) = locations(JsonField.of(locations)) - - /** - * Sets [Builder.locations] to an arbitrary JSON value. - * - * You should usually call [Builder.locations] with a well-typed [Locations] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun locations(locations: JsonField) = apply { - this.locations = locations - } - - fun primaryEmail(primaryEmail: Boolean) = - primaryEmail(JsonField.of(primaryEmail)) - - /** - * Sets [Builder.primaryEmail] to an arbitrary JSON value. - * - * You should usually call [Builder.primaryEmail] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun primaryEmail(primaryEmail: JsonField) = apply { - this.primaryEmail = primaryEmail - } - - fun primaryPhoneNumber(primaryPhoneNumber: Boolean) = - primaryPhoneNumber(JsonField.of(primaryPhoneNumber)) - - /** - * Sets [Builder.primaryPhoneNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.primaryPhoneNumber] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun primaryPhoneNumber(primaryPhoneNumber: JsonField) = apply { - this.primaryPhoneNumber = primaryPhoneNumber - } - - 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 [SupportedCompanyFields]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SupportedCompanyFields = - SupportedCompanyFields( - id, - accounts, - departments, - ein, - entity, - legalName, - locations, - primaryEmail, - primaryPhoneNumber, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SupportedCompanyFields = apply { - if (validated) { - return@apply - } - - id() - accounts().ifPresent { it.validate() } - departments().ifPresent { it.validate() } - ein() - entity().ifPresent { it.validate() } - legalName() - locations().ifPresent { it.validate() } - primaryEmail() - primaryPhoneNumber() - 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 (id.asKnown().isPresent) 1 else 0) + - (accounts.asKnown().getOrNull()?.validity() ?: 0) + - (departments.asKnown().getOrNull()?.validity() ?: 0) + - (if (ein.asKnown().isPresent) 1 else 0) + - (entity.asKnown().getOrNull()?.validity() ?: 0) + - (if (legalName.asKnown().isPresent) 1 else 0) + - (locations.asKnown().getOrNull()?.validity() ?: 0) + - (if (primaryEmail.asKnown().isPresent) 1 else 0) + - (if (primaryPhoneNumber.asKnown().isPresent) 1 else 0) - - class Accounts - private constructor( - private val accountName: JsonField, - private val accountNumber: JsonField, - private val accountType: JsonField, - private val institutionName: JsonField, - private val routingNumber: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("account_name") - @ExcludeMissing - accountName: JsonField = JsonMissing.of(), - @JsonProperty("account_number") - @ExcludeMissing - accountNumber: JsonField = JsonMissing.of(), - @JsonProperty("account_type") - @ExcludeMissing - accountType: JsonField = JsonMissing.of(), - @JsonProperty("institution_name") - @ExcludeMissing - institutionName: JsonField = JsonMissing.of(), - @JsonProperty("routing_number") - @ExcludeMissing - routingNumber: JsonField = JsonMissing.of(), - ) : this( - accountName, - accountNumber, - accountType, - institutionName, - routingNumber, - mutableMapOf(), - ) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun accountName(): Optional = accountName.getOptional("account_name") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun accountNumber(): Optional = - accountNumber.getOptional("account_number") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun accountType(): Optional = accountType.getOptional("account_type") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun institutionName(): Optional = - institutionName.getOptional("institution_name") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun routingNumber(): Optional = - routingNumber.getOptional("routing_number") - - /** - * Returns the raw JSON value of [accountName]. - * - * Unlike [accountName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("account_name") - @ExcludeMissing - fun _accountName(): JsonField = accountName - - /** - * Returns the raw JSON value of [accountNumber]. - * - * Unlike [accountNumber], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("account_number") - @ExcludeMissing - fun _accountNumber(): JsonField = accountNumber - - /** - * Returns the raw JSON value of [accountType]. - * - * Unlike [accountType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("account_type") - @ExcludeMissing - fun _accountType(): JsonField = accountType - - /** - * Returns the raw JSON value of [institutionName]. - * - * Unlike [institutionName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("institution_name") - @ExcludeMissing - fun _institutionName(): JsonField = institutionName - - /** - * Returns the raw JSON value of [routingNumber]. - * - * Unlike [routingNumber], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("routing_number") - @ExcludeMissing - fun _routingNumber(): JsonField = routingNumber - - @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 [Accounts]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Accounts]. */ - 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 additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(accounts: Accounts) = apply { - accountName = accounts.accountName - accountNumber = accounts.accountNumber - accountType = accounts.accountType - institutionName = accounts.institutionName - routingNumber = accounts.routingNumber - additionalProperties = accounts.additionalProperties.toMutableMap() - } - - fun accountName(accountName: Boolean) = - accountName(JsonField.of(accountName)) - - /** - * Sets [Builder.accountName] to an arbitrary JSON value. - * - * You should usually call [Builder.accountName] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun accountName(accountName: JsonField) = apply { - this.accountName = accountName - } - - fun accountNumber(accountNumber: Boolean) = - accountNumber(JsonField.of(accountNumber)) - - /** - * Sets [Builder.accountNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.accountNumber] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun accountNumber(accountNumber: JsonField) = apply { - this.accountNumber = accountNumber - } - - fun accountType(accountType: Boolean) = - accountType(JsonField.of(accountType)) - - /** - * Sets [Builder.accountType] to an arbitrary JSON value. - * - * You should usually call [Builder.accountType] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun accountType(accountType: JsonField) = apply { - this.accountType = accountType - } - - fun institutionName(institutionName: Boolean) = - institutionName(JsonField.of(institutionName)) - - /** - * Sets [Builder.institutionName] to an arbitrary JSON value. - * - * You should usually call [Builder.institutionName] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun institutionName(institutionName: JsonField) = apply { - this.institutionName = institutionName - } - - fun routingNumber(routingNumber: Boolean) = - routingNumber(JsonField.of(routingNumber)) - - /** - * Sets [Builder.routingNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.routingNumber] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun routingNumber(routingNumber: JsonField) = apply { - this.routingNumber = routingNumber - } - - 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 [Accounts]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Accounts = - Accounts( - accountName, - accountNumber, - accountType, - institutionName, - routingNumber, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Accounts = apply { - if (validated) { - return@apply - } - - accountName() - accountNumber() - accountType() - institutionName() - routingNumber() - 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 (accountName.asKnown().isPresent) 1 else 0) + - (if (accountNumber.asKnown().isPresent) 1 else 0) + - (if (accountType.asKnown().isPresent) 1 else 0) + - (if (institutionName.asKnown().isPresent) 1 else 0) + - (if (routingNumber.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Accounts && - accountName == other.accountName && - accountNumber == other.accountNumber && - accountType == other.accountType && - institutionName == other.institutionName && - routingNumber == other.routingNumber && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - accountName, - accountNumber, - accountType, - institutionName, - routingNumber, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Accounts{accountName=$accountName, accountNumber=$accountNumber, accountType=$accountType, institutionName=$institutionName, routingNumber=$routingNumber, additionalProperties=$additionalProperties}" - } - - class Departments - private constructor( - private val name: JsonField, - private val parent: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("parent") - @ExcludeMissing - parent: JsonField = JsonMissing.of(), - ) : this(name, parent, 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 parent(): Optional = parent.getOptional("parent") - - /** - * 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 [parent]. - * - * Unlike [parent], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("parent") - @ExcludeMissing - fun _parent(): JsonField = parent - - @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 [Departments]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Departments]. */ - class Builder internal constructor() { - - private var name: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(departments: Departments) = apply { - name = departments.name - parent = departments.parent - additionalProperties = departments.additionalProperties.toMutableMap() - } - - fun name(name: Boolean) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [Boolean] 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 parent(parent: Parent) = parent(JsonField.of(parent)) - - /** - * Sets [Builder.parent] to an arbitrary JSON value. - * - * You should usually call [Builder.parent] with a well-typed [Parent] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun parent(parent: JsonField) = apply { this.parent = parent } - - 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 [Departments]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Departments = - Departments(name, parent, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Departments = apply { - if (validated) { - return@apply - } - - name() - parent().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 (name.asKnown().isPresent) 1 else 0) + - (parent.asKnown().getOrNull()?.validity() ?: 0) - - class Parent - private constructor( - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of() - ) : this(name, 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") - - /** - * 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 [Parent]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Parent]. */ - class Builder internal constructor() { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(parent: Parent) = apply { - name = parent.name - additionalProperties = parent.additionalProperties.toMutableMap() - } - - fun name(name: Boolean) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [Boolean] - * 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 [Parent]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Parent = Parent(name, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Parent = 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 other is Parent && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Parent{name=$name, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Departments && - name == other.name && - parent == other.parent && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(name, parent, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Departments{name=$name, parent=$parent, additionalProperties=$additionalProperties}" - } - - class Entity - 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()) - - /** - * @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") - - /** - * @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 [Entity]. */ - @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 additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(entity: Entity) = apply { - subtype = entity.subtype - type = entity.type - additionalProperties = entity.additionalProperties.toMutableMap() - } - - fun subtype(subtype: Boolean) = subtype(JsonField.of(subtype)) - - /** - * Sets [Builder.subtype] to an arbitrary JSON value. - * - * You should usually call [Builder.subtype] with a well-typed [Boolean] - * 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 } - - fun type(type: Boolean) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Boolean] 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 [Entity]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Entity = - Entity(subtype, type, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Entity = apply { - if (validated) { - return@apply - } - - subtype() - type() - 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 (subtype.asKnown().isPresent) 1 else 0) + - (if (type.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Entity && - subtype == other.subtype && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(subtype, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Entity{subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" - } - - class Locations - private constructor( - private val city: JsonField, - private val country: JsonField, - private val line1: JsonField, - private val line2: JsonField, - private val postalCode: JsonField, - private val state: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("city") - @ExcludeMissing - city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - state: JsonField = JsonMissing.of(), - ) : this(city, country, line1, line2, postalCode, state, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun city(): Optional = city.getOptional("city") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun country(): Optional = country.getOptional("country") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun line1(): Optional = line1.getOptional("line1") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun line2(): Optional = line2.getOptional("line2") - - /** - * @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") - - /** - * @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") - - /** - * Returns the raw JSON value of [city]. - * - * Unlike [city], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - /** - * Returns the raw JSON value of [country]. - * - * Unlike [country], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("country") - @ExcludeMissing - fun _country(): JsonField = country - - /** - * Returns the raw JSON value of [line1]. - * - * Unlike [line1], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - /** - * Returns the raw JSON value of [line2]. - * - * Unlike [line2], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - /** - * Returns the raw JSON value of [postalCode]. - * - * Unlike [postalCode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - /** - * Returns the raw JSON value of [state]. - * - * Unlike [state], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - @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 [Locations]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Locations]. */ - 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 postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(locations: Locations) = apply { - city = locations.city - country = locations.country - line1 = locations.line1 - line2 = locations.line2 - postalCode = locations.postalCode - state = locations.state - additionalProperties = locations.additionalProperties.toMutableMap() - } - - fun city(city: Boolean) = city(JsonField.of(city)) - - /** - * Sets [Builder.city] to an arbitrary JSON value. - * - * You should usually call [Builder.city] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: Boolean) = country(JsonField.of(country)) - - /** - * Sets [Builder.country] to an arbitrary JSON value. - * - * You should usually call [Builder.country] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: Boolean) = line1(JsonField.of(line1)) - - /** - * Sets [Builder.line1] to an arbitrary JSON value. - * - * You should usually call [Builder.line1] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: Boolean) = line2(JsonField.of(line2)) - - /** - * Sets [Builder.line2] to an arbitrary JSON value. - * - * You should usually call [Builder.line2] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: Boolean) = postalCode(JsonField.of(postalCode)) - - /** - * Sets [Builder.postalCode] to an arbitrary JSON value. - * - * You should usually call [Builder.postalCode] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun postalCode(postalCode: JsonField) = apply { - this.postalCode = postalCode - } - - fun state(state: Boolean) = state(JsonField.of(state)) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun state(state: JsonField) = apply { this.state = state } - - 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 [Locations]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Locations = - Locations( - city, - country, - line1, - line2, - postalCode, - state, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Locations = apply { - if (validated) { - return@apply - } - - city() - country() - line1() - line2() - postalCode() - state() - 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 (city.asKnown().isPresent) 1 else 0) + - (if (country.asKnown().isPresent) 1 else 0) + - (if (line1.asKnown().isPresent) 1 else 0) + - (if (line2.asKnown().isPresent) 1 else 0) + - (if (postalCode.asKnown().isPresent) 1 else 0) + - (if (state.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Locations && - city == other.city && - country == other.country && - line1 == other.line1 && - line2 == other.line2 && - postalCode == other.postalCode && - state == other.state && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - city, - country, - line1, - line2, - postalCode, - state, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Locations{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SupportedCompanyFields && - id == other.id && - accounts == other.accounts && - departments == other.departments && - ein == other.ein && - entity == other.entity && - legalName == other.legalName && - locations == other.locations && - primaryEmail == other.primaryEmail && - primaryPhoneNumber == other.primaryPhoneNumber && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - accounts, - departments, - ein, - entity, - legalName, - locations, - primaryEmail, - primaryPhoneNumber, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SupportedCompanyFields{id=$id, accounts=$accounts, departments=$departments, ein=$ein, entity=$entity, legalName=$legalName, locations=$locations, primaryEmail=$primaryEmail, primaryPhoneNumber=$primaryPhoneNumber, additionalProperties=$additionalProperties}" - } - - class SupportedDirectoryFields - private constructor( - private val individuals: JsonField, - private val paging: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("individuals") - @ExcludeMissing - individuals: JsonField = JsonMissing.of(), - @JsonProperty("paging") - @ExcludeMissing - paging: JsonField = JsonMissing.of(), - ) : this(individuals, paging, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun individuals(): Optional = individuals.getOptional("individuals") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun paging(): Optional = paging.getOptional("paging") - - /** - * Returns the raw JSON value of [individuals]. - * - * Unlike [individuals], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("individuals") - @ExcludeMissing - fun _individuals(): JsonField = individuals - - /** - * Returns the raw JSON value of [paging]. - * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - - @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 - * [SupportedDirectoryFields]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SupportedDirectoryFields]. */ - class Builder internal constructor() { - - private var individuals: JsonField = JsonMissing.of() - private var paging: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(supportedDirectoryFields: SupportedDirectoryFields) = apply { - individuals = supportedDirectoryFields.individuals - paging = supportedDirectoryFields.paging - additionalProperties = - supportedDirectoryFields.additionalProperties.toMutableMap() - } - - fun individuals(individuals: Individuals) = - individuals(JsonField.of(individuals)) - - /** - * Sets [Builder.individuals] to an arbitrary JSON value. - * - * You should usually call [Builder.individuals] with a well-typed [Individuals] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun individuals(individuals: JsonField) = apply { - this.individuals = individuals - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - /** - * Sets [Builder.paging] to an arbitrary JSON value. - * - * You should usually call [Builder.paging] with a well-typed [Paging] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - 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 [SupportedDirectoryFields]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SupportedDirectoryFields = - SupportedDirectoryFields( - individuals, - paging, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SupportedDirectoryFields = apply { - if (validated) { - return@apply - } - - individuals().ifPresent { it.validate() } - paging().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 = - (individuals.asKnown().getOrNull()?.validity() ?: 0) + - (paging.asKnown().getOrNull()?.validity() ?: 0) - - class Individuals - private constructor( - private val id: JsonField, - private val department: JsonField, - private val firstName: JsonField, - private val isActive: JsonField, - private val lastName: JsonField, - private val manager: JsonField, - private val middleName: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") - @ExcludeMissing - id: JsonField = JsonMissing.of(), - @JsonProperty("department") - @ExcludeMissing - department: 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("manager") - @ExcludeMissing - manager: JsonField = JsonMissing.of(), - @JsonProperty("middle_name") - @ExcludeMissing - middleName: JsonField = JsonMissing.of(), - ) : this( - id, - department, - firstName, - isActive, - lastName, - manager, - middleName, - mutableMapOf(), - ) - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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 manager(): Optional = manager.getOptional("manager") - - /** - * @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") - - /** - * 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 - - /** - * 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 - - /** - * 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 - - /** - * 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 - - /** - * 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 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 - - /** - * 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 - - @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 [Individuals]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Individuals]. */ - 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 additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(individuals: Individuals) = apply { - id = individuals.id - department = individuals.department - firstName = individuals.firstName - isActive = individuals.isActive - lastName = individuals.lastName - manager = individuals.manager - middleName = individuals.middleName - additionalProperties = individuals.additionalProperties.toMutableMap() - } - - fun id(id: Boolean) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [Boolean] 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 department(department: Boolean) = department(JsonField.of(department)) - - /** - * Sets [Builder.department] to an arbitrary JSON value. - * - * You should usually call [Builder.department] with a well-typed [Boolean] - * 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 - } - - fun firstName(firstName: Boolean) = firstName(JsonField.of(firstName)) - - /** - * Sets [Builder.firstName] to an arbitrary JSON value. - * - * You should usually call [Builder.firstName] with a well-typed [Boolean] - * 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 - } - - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - /** - * 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 - } - - fun lastName(lastName: Boolean) = lastName(JsonField.of(lastName)) - - /** - * Sets [Builder.lastName] to an arbitrary JSON value. - * - * You should usually call [Builder.lastName] with a well-typed [Boolean] - * 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 manager(manager: Manager) = manager(JsonField.of(manager)) - - /** - * 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 } - - fun middleName(middleName: Boolean) = middleName(JsonField.of(middleName)) - - /** - * Sets [Builder.middleName] to an arbitrary JSON value. - * - * You should usually call [Builder.middleName] with a well-typed [Boolean] - * 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 - } - - 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 [Individuals]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Individuals = - Individuals( - id, - department, - firstName, - isActive, - lastName, - manager, - middleName, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Individuals = apply { - if (validated) { - return@apply - } - - id() - department() - firstName() - isActive() - lastName() - manager().ifPresent { it.validate() } - middleName() - 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 (id.asKnown().isPresent) 1 else 0) + - (if (department.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) + - (manager.asKnown().getOrNull()?.validity() ?: 0) + - (if (middleName.asKnown().isPresent) 1 else 0) - - 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()) - - /** - * @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") - - /** - * 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 - - @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 [Manager]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Manager]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(manager: Manager) = apply { - id = manager.id - additionalProperties = manager.additionalProperties.toMutableMap() - } - - fun id(id: Boolean) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [Boolean] - * 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) - } - - 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. - */ - fun build(): Manager = Manager(id, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Manager = apply { - if (validated) { - return@apply - } - - id() - 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 (id.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Manager && - id == other.id && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - - 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 other is Individuals && - id == other.id && - department == other.department && - firstName == other.firstName && - isActive == other.isActive && - lastName == other.lastName && - manager == other.manager && - middleName == other.middleName && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - department, - firstName, - isActive, - lastName, - manager, - middleName, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Individuals{id=$id, department=$department, firstName=$firstName, isActive=$isActive, lastName=$lastName, manager=$manager, middleName=$middleName, additionalProperties=$additionalProperties}" - } - - class Paging - private constructor( - private val count: JsonField, - private val offset: 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()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun count(): Optional = count.getOptional("count") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun offset(): Optional = offset.getOptional("offset") - - /** - * Returns the raw JSON value of [count]. - * - * Unlike [count], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @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) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Paging]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Paging]. */ - class Builder internal constructor() { - - 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 - additionalProperties = paging.additionalProperties.toMutableMap() - } - - fun count(count: Boolean) = count(JsonField.of(count)) - - /** - * Sets [Builder.count] to an arbitrary JSON value. - * - * You should usually call [Builder.count] with a well-typed [Boolean] 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: Boolean) = offset(JsonField.of(offset)) - - /** - * Sets [Builder.offset] to an arbitrary JSON value. - * - * You should usually call [Builder.offset] with a well-typed [Boolean] - * 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 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 [Paging]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Paging = - Paging(count, offset, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Paging = apply { - if (validated) { - return@apply - } - - count() - offset() - 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 (count.asKnown().isPresent) 1 else 0) + - (if (offset.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Paging && - count == other.count && - offset == other.offset && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(count, offset, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Paging{count=$count, offset=$offset, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SupportedDirectoryFields && - individuals == other.individuals && - paging == other.paging && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(individuals, paging, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SupportedDirectoryFields{individuals=$individuals, paging=$paging, additionalProperties=$additionalProperties}" - } - - class SupportedEmploymentFields - 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 location: JsonField, - private val manager: JsonField, - private val middleName: JsonField, - private val startDate: JsonField, - private val title: JsonField, - private val additionalProperties: MutableMap, - ) { - - @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("location") - @ExcludeMissing - location: JsonField = JsonMissing.of(), - @JsonProperty("manager") - @ExcludeMissing - manager: JsonField = JsonMissing.of(), - @JsonProperty("middle_name") - @ExcludeMissing - middleName: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - startDate: JsonField = JsonMissing.of(), - @JsonProperty("title") - @ExcludeMissing - title: JsonField = JsonMissing.of(), - ) : this( - id, - classCode, - customFields, - department, - employment, - employmentStatus, - endDate, - firstName, - income, - incomeHistory, - isActive, - lastName, - location, - manager, - middleName, - startDate, - title, - mutableMapOf(), - ) - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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 location(): Optional = location.getOptional("location") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * 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 - - /** - * 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 - - /** - * 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 - - /** - * 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 - - /** - * 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 - - /** - * 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 - - /** - * 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 - - /** - * 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 - - /** - * 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 [incomeHistory]. - * - * Unlike [incomeHistory], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("income_history") - @ExcludeMissing - fun _incomeHistory(): JsonField = incomeHistory - - /** - * 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 - - /** - * 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 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 - - /** - * 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 - - /** - * 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 - - /** - * 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 - - /** - * 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 - - @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 - * [SupportedEmploymentFields]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SupportedEmploymentFields]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var classCode: JsonField = JsonMissing.of() - private var customFields: JsonField = JsonMissing.of() - 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 = JsonMissing.of() - private var isActive: JsonField = JsonMissing.of() - private var lastName: JsonField = JsonMissing.of() - private var location: JsonField = JsonMissing.of() - private var manager: JsonField = JsonMissing.of() - private var middleName: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var title: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(supportedEmploymentFields: SupportedEmploymentFields) = - apply { - id = supportedEmploymentFields.id - classCode = supportedEmploymentFields.classCode - customFields = supportedEmploymentFields.customFields - department = supportedEmploymentFields.department - employment = supportedEmploymentFields.employment - employmentStatus = supportedEmploymentFields.employmentStatus - endDate = supportedEmploymentFields.endDate - firstName = supportedEmploymentFields.firstName - income = supportedEmploymentFields.income - incomeHistory = supportedEmploymentFields.incomeHistory - isActive = supportedEmploymentFields.isActive - lastName = supportedEmploymentFields.lastName - location = supportedEmploymentFields.location - manager = supportedEmploymentFields.manager - middleName = supportedEmploymentFields.middleName - startDate = supportedEmploymentFields.startDate - title = supportedEmploymentFields.title - additionalProperties = - supportedEmploymentFields.additionalProperties.toMutableMap() - } - - fun id(id: Boolean) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [Boolean] 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 classCode(classCode: Boolean) = classCode(JsonField.of(classCode)) - - /** - * Sets [Builder.classCode] to an arbitrary JSON value. - * - * You should usually call [Builder.classCode] with a well-typed [Boolean] 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 customFields(customFields: Boolean) = - customFields(JsonField.of(customFields)) - - /** - * Sets [Builder.customFields] to an arbitrary JSON value. - * - * You should usually call [Builder.customFields] with a well-typed [Boolean] - * 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 - } - - fun department(department: Department) = department(JsonField.of(department)) - - /** - * 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 - } - - fun employment(employment: Employment) = employment(JsonField.of(employment)) - - /** - * 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 - } - - fun employmentStatus(employmentStatus: Boolean) = - employmentStatus(JsonField.of(employmentStatus)) - - /** - * Sets [Builder.employmentStatus] to an arbitrary JSON value. - * - * You should usually call [Builder.employmentStatus] with a well-typed - * [Boolean] 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 - } - - fun endDate(endDate: Boolean) = endDate(JsonField.of(endDate)) - - /** - * Sets [Builder.endDate] to an arbitrary JSON value. - * - * You should usually call [Builder.endDate] with a well-typed [Boolean] 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 } - - fun firstName(firstName: Boolean) = firstName(JsonField.of(firstName)) - - /** - * Sets [Builder.firstName] to an arbitrary JSON value. - * - * You should usually call [Builder.firstName] with a well-typed [Boolean] 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 - } - - fun income(income: Income) = income(JsonField.of(income)) - - /** - * 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 } - - fun incomeHistory(incomeHistory: Boolean) = - incomeHistory(JsonField.of(incomeHistory)) - - /** - * Sets [Builder.incomeHistory] to an arbitrary JSON value. - * - * You should usually call [Builder.incomeHistory] with a well-typed [Boolean] - * 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 - } - - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - /** - * 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 } - - fun lastName(lastName: Boolean) = lastName(JsonField.of(lastName)) - - /** - * Sets [Builder.lastName] to an arbitrary JSON value. - * - * You should usually call [Builder.lastName] with a well-typed [Boolean] 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 location(location: Location) = location(JsonField.of(location)) - - /** - * Sets [Builder.location] to an arbitrary JSON 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 location(location: JsonField) = apply { this.location = location } - - fun manager(manager: Manager) = manager(JsonField.of(manager)) - - /** - * 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 } - - fun middleName(middleName: Boolean) = middleName(JsonField.of(middleName)) - - /** - * Sets [Builder.middleName] to an arbitrary JSON value. - * - * You should usually call [Builder.middleName] with a well-typed [Boolean] - * 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 - } - - fun startDate(startDate: Boolean) = startDate(JsonField.of(startDate)) - - /** - * Sets [Builder.startDate] to an arbitrary JSON value. - * - * You should usually call [Builder.startDate] with a well-typed [Boolean] 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 - } - - fun title(title: Boolean) = title(JsonField.of(title)) - - /** - * Sets [Builder.title] to an arbitrary JSON value. - * - * You should usually call [Builder.title] with a well-typed [Boolean] 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 } - - 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 [SupportedEmploymentFields]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SupportedEmploymentFields = - SupportedEmploymentFields( - id, - classCode, - customFields, - department, - employment, - employmentStatus, - endDate, - firstName, - income, - incomeHistory, - isActive, - lastName, - location, - manager, - middleName, - startDate, - title, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SupportedEmploymentFields = apply { - if (validated) { - return@apply - } - - id() - classCode() - customFields() - department().ifPresent { it.validate() } - employment().ifPresent { it.validate() } - employmentStatus() - endDate() - firstName() - income().ifPresent { it.validate() } - incomeHistory() - isActive() - lastName() - location().ifPresent { it.validate() } - manager().ifPresent { it.validate() } - middleName() - startDate() - title() - 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 (id.asKnown().isPresent) 1 else 0) + - (if (classCode.asKnown().isPresent) 1 else 0) + - (if (customFields.asKnown().isPresent) 1 else 0) + - (department.asKnown().getOrNull()?.validity() ?: 0) + - (employment.asKnown().getOrNull()?.validity() ?: 0) + - (if (employmentStatus.asKnown().isPresent) 1 else 0) + - (if (endDate.asKnown().isPresent) 1 else 0) + - (if (firstName.asKnown().isPresent) 1 else 0) + - (income.asKnown().getOrNull()?.validity() ?: 0) + - (if (incomeHistory.asKnown().isPresent) 1 else 0) + - (if (isActive.asKnown().isPresent) 1 else 0) + - (if (lastName.asKnown().isPresent) 1 else 0) + - (location.asKnown().getOrNull()?.validity() ?: 0) + - (manager.asKnown().getOrNull()?.validity() ?: 0) + - (if (middleName.asKnown().isPresent) 1 else 0) + - (if (startDate.asKnown().isPresent) 1 else 0) + - (if (title.asKnown().isPresent) 1 else 0) - - 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()) - - /** - * @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]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Department]. */ - class Builder internal constructor() { - - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(department: Department) = apply { - name = department.name - additionalProperties = department.additionalProperties.toMutableMap() - } - - fun name(name: Boolean) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [Boolean] 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. - */ - fun build(): Department = - Department(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 other is Department && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Department{name=$name, additionalProperties=$additionalProperties}" - } - - 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()) - - /** - * @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") - - /** - * @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]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Employment]. */ - class Builder internal constructor() { - - private var subtype: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(employment: Employment) = apply { - subtype = employment.subtype - type = employment.type - additionalProperties = employment.additionalProperties.toMutableMap() - } - - fun subtype(subtype: Boolean) = subtype(JsonField.of(subtype)) - - /** - * Sets [Builder.subtype] to an arbitrary JSON value. - * - * You should usually call [Builder.subtype] with a well-typed [Boolean] - * 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 } - - fun type(type: Boolean) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Boolean] 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. - */ - fun build(): Employment = - Employment(subtype, type, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Employment = apply { - if (validated) { - return@apply - } - - subtype() - type() - 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 (subtype.asKnown().isPresent) 1 else 0) + - (if (type.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Employment && - subtype == other.subtype && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(subtype, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Employment{subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" - } - - class Income - private constructor( - private val amount: JsonField, - private val currency: JsonField, - private val unit: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("unit") - @ExcludeMissing - unit: JsonField = JsonMissing.of(), - ) : this(amount, currency, unit, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun unit(): Optional = unit.getOptional("unit") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("amount") - @ExcludeMissing - fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [unit]. - * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit - - @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 [Income]. */ - @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 unit: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(income: Income) = apply { - amount = income.amount - currency = income.currency - unit = income.unit - additionalProperties = income.additionalProperties.toMutableMap() - } - - fun amount(amount: Boolean) = amount(JsonField.of(amount)) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun currency(currency: Boolean) = currency(JsonField.of(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { - this.currency = currency - } - - fun unit(unit: Boolean) = unit(JsonField.of(unit)) - - /** - * Sets [Builder.unit] to an arbitrary JSON value. - * - * You should usually call [Builder.unit] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun unit(unit: JsonField) = apply { this.unit = unit } - - 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 [Income]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Income = - Income(amount, currency, unit, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Income = apply { - if (validated) { - return@apply - } - - amount() - currency() - unit() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (unit.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Income && - amount == other.amount && - currency == other.currency && - unit == other.unit && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(amount, currency, unit, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Income{amount=$amount, currency=$currency, unit=$unit, additionalProperties=$additionalProperties}" - } - - class Location - private constructor( - private val city: JsonField, - private val country: JsonField, - private val line1: JsonField, - private val line2: JsonField, - private val postalCode: JsonField, - private val state: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("city") - @ExcludeMissing - city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - state: JsonField = JsonMissing.of(), - ) : this(city, country, line1, line2, postalCode, state, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun city(): Optional = city.getOptional("city") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun country(): Optional = country.getOptional("country") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun line1(): Optional = line1.getOptional("line1") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun line2(): Optional = line2.getOptional("line2") - - /** - * @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") - - /** - * @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") - - /** - * Returns the raw JSON value of [city]. - * - * Unlike [city], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - /** - * Returns the raw JSON value of [country]. - * - * Unlike [country], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("country") - @ExcludeMissing - fun _country(): JsonField = country - - /** - * Returns the raw JSON value of [line1]. - * - * Unlike [line1], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - /** - * Returns the raw JSON value of [line2]. - * - * Unlike [line2], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - /** - * Returns the raw JSON value of [postalCode]. - * - * Unlike [postalCode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - /** - * Returns the raw JSON value of [state]. - * - * Unlike [state], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - @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 [Location]. */ - @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 postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(location: Location) = apply { - city = location.city - country = location.country - line1 = location.line1 - line2 = location.line2 - postalCode = location.postalCode - state = location.state - additionalProperties = location.additionalProperties.toMutableMap() - } - - fun city(city: Boolean) = city(JsonField.of(city)) - - /** - * Sets [Builder.city] to an arbitrary JSON value. - * - * You should usually call [Builder.city] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: Boolean) = country(JsonField.of(country)) - - /** - * Sets [Builder.country] to an arbitrary JSON value. - * - * You should usually call [Builder.country] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: Boolean) = line1(JsonField.of(line1)) - - /** - * Sets [Builder.line1] to an arbitrary JSON value. - * - * You should usually call [Builder.line1] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: Boolean) = line2(JsonField.of(line2)) - - /** - * Sets [Builder.line2] to an arbitrary JSON value. - * - * You should usually call [Builder.line2] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: Boolean) = postalCode(JsonField.of(postalCode)) - - /** - * Sets [Builder.postalCode] to an arbitrary JSON value. - * - * You should usually call [Builder.postalCode] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun postalCode(postalCode: JsonField) = apply { - this.postalCode = postalCode - } - - fun state(state: Boolean) = state(JsonField.of(state)) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun state(state: JsonField) = apply { this.state = state } - - 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 [Location]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Location = - Location( - city, - country, - line1, - line2, - postalCode, - state, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Location = apply { - if (validated) { - return@apply - } - - city() - country() - line1() - line2() - postalCode() - state() - 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 (city.asKnown().isPresent) 1 else 0) + - (if (country.asKnown().isPresent) 1 else 0) + - (if (line1.asKnown().isPresent) 1 else 0) + - (if (line2.asKnown().isPresent) 1 else 0) + - (if (postalCode.asKnown().isPresent) 1 else 0) + - (if (state.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Location && - city == other.city && - country == other.country && - line1 == other.line1 && - line2 == other.line2 && - postalCode == other.postalCode && - state == other.state && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - city, - country, - line1, - line2, - postalCode, - state, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Location{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" - } - - 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()) - - /** - * @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") - - /** - * 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 - - @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 [Manager]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Manager]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(manager: Manager) = apply { - id = manager.id - additionalProperties = manager.additionalProperties.toMutableMap() - } - - fun id(id: Boolean) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [Boolean] 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) - } - - 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. - */ - fun build(): Manager = Manager(id, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Manager = apply { - if (validated) { - return@apply - } - - id() - 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 (id.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Manager && - id == other.id && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } - - 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 other is SupportedEmploymentFields && - 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 && - location == other.location && - manager == other.manager && - middleName == other.middleName && - startDate == other.startDate && - title == other.title && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - classCode, - customFields, - department, - employment, - employmentStatus, - endDate, - firstName, - income, - incomeHistory, - isActive, - lastName, - location, - manager, - middleName, - startDate, - title, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SupportedEmploymentFields{id=$id, classCode=$classCode, customFields=$customFields, department=$department, employment=$employment, employmentStatus=$employmentStatus, endDate=$endDate, firstName=$firstName, income=$income, incomeHistory=$incomeHistory, isActive=$isActive, lastName=$lastName, location=$location, manager=$manager, middleName=$middleName, startDate=$startDate, title=$title, additionalProperties=$additionalProperties}" - } - - class SupportedIndividualFields - 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, - private val lastName: JsonField, - private val middleName: JsonField, - private val phoneNumbers: JsonField, - private val preferredName: JsonField, - private val residence: JsonField, - private val ssn: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - 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(), - @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("ssn") @ExcludeMissing ssn: JsonField = JsonMissing.of(), - ) : this( - id, - dob, - emails, - encryptedSsn, - ethnicity, - firstName, - gender, - lastName, - middleName, - phoneNumbers, - preferredName, - residence, - ssn, - mutableMapOf(), - ) - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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 middleName(): Optional = middleName.getOptional("middle_name") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * @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") - - /** - * 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 - - /** - * 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 - - /** - * 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]. - * - * Unlike [ethnicity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("ethnicity") - @ExcludeMissing - fun _ethnicity(): JsonField = ethnicity - - /** - * 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 - - /** - * Returns the raw JSON value of [gender]. - * - * Unlike [gender], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("gender") @ExcludeMissing fun _gender(): JsonField = gender - - /** - * 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 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 - - /** - * 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 - - /** - * 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 - - /** - * 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 - - /** - * 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 - - @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 - * [SupportedIndividualFields]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SupportedIndividualFields]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var dob: JsonField = JsonMissing.of() - private var emails: JsonField = JsonMissing.of() - 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 = JsonMissing.of() - private var preferredName: JsonField = JsonMissing.of() - private var residence: JsonField = JsonMissing.of() - private var ssn: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(supportedIndividualFields: SupportedIndividualFields) = - apply { - id = supportedIndividualFields.id - dob = supportedIndividualFields.dob - emails = supportedIndividualFields.emails - encryptedSsn = supportedIndividualFields.encryptedSsn - ethnicity = supportedIndividualFields.ethnicity - firstName = supportedIndividualFields.firstName - gender = supportedIndividualFields.gender - lastName = supportedIndividualFields.lastName - middleName = supportedIndividualFields.middleName - phoneNumbers = supportedIndividualFields.phoneNumbers - preferredName = supportedIndividualFields.preferredName - residence = supportedIndividualFields.residence - ssn = supportedIndividualFields.ssn - additionalProperties = - supportedIndividualFields.additionalProperties.toMutableMap() - } - - fun id(id: Boolean) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [Boolean] 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 dob(dob: Boolean) = dob(JsonField.of(dob)) - - /** - * Sets [Builder.dob] to an arbitrary JSON value. - * - * You should usually call [Builder.dob] with a well-typed [Boolean] 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 } - - fun emails(emails: Emails) = emails(JsonField.of(emails)) - - /** - * Sets [Builder.emails] to an arbitrary JSON value. - * - * You should usually call [Builder.emails] with a well-typed [Emails] 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 } - - fun encryptedSsn(encryptedSsn: Boolean) = - encryptedSsn(JsonField.of(encryptedSsn)) - - /** - * Sets [Builder.encryptedSsn] to an arbitrary JSON value. - * - * You should usually call [Builder.encryptedSsn] with a well-typed [Boolean] - * 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 - } - - fun ethnicity(ethnicity: Boolean) = ethnicity(JsonField.of(ethnicity)) - - /** - * Sets [Builder.ethnicity] to an arbitrary JSON value. - * - * You should usually call [Builder.ethnicity] with a well-typed [Boolean] 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 - } - - fun firstName(firstName: Boolean) = firstName(JsonField.of(firstName)) - - /** - * Sets [Builder.firstName] to an arbitrary JSON value. - * - * You should usually call [Builder.firstName] with a well-typed [Boolean] 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 - } - - fun gender(gender: Boolean) = gender(JsonField.of(gender)) - - /** - * Sets [Builder.gender] to an arbitrary JSON value. - * - * You should usually call [Builder.gender] with a well-typed [Boolean] 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 } - - fun lastName(lastName: Boolean) = lastName(JsonField.of(lastName)) - - /** - * Sets [Builder.lastName] to an arbitrary JSON value. - * - * You should usually call [Builder.lastName] with a well-typed [Boolean] 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 middleName(middleName: Boolean) = middleName(JsonField.of(middleName)) - - /** - * Sets [Builder.middleName] to an arbitrary JSON value. - * - * You should usually call [Builder.middleName] with a well-typed [Boolean] - * 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 - } - - fun phoneNumbers(phoneNumbers: PhoneNumbers) = - phoneNumbers(JsonField.of(phoneNumbers)) - - /** - * Sets [Builder.phoneNumbers] to an arbitrary JSON value. - * - * You should usually call [Builder.phoneNumbers] with a well-typed - * [PhoneNumbers] 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 - } - - fun preferredName(preferredName: Boolean) = - preferredName(JsonField.of(preferredName)) - - /** - * Sets [Builder.preferredName] to an arbitrary JSON value. - * - * You should usually call [Builder.preferredName] with a well-typed [Boolean] - * 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 - } - - fun residence(residence: Residence) = residence(JsonField.of(residence)) - - /** - * Sets [Builder.residence] to an arbitrary JSON value. - * - * You should usually call [Builder.residence] with a well-typed [Residence] - * 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 - } - - fun ssn(ssn: Boolean) = ssn(JsonField.of(ssn)) - - /** - * Sets [Builder.ssn] to an arbitrary JSON value. - * - * You should usually call [Builder.ssn] with a well-typed [Boolean] 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 } - - 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 [SupportedIndividualFields]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SupportedIndividualFields = - SupportedIndividualFields( - id, - dob, - emails, - encryptedSsn, - ethnicity, - firstName, - gender, - lastName, - middleName, - phoneNumbers, - preferredName, - residence, - ssn, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SupportedIndividualFields = apply { - if (validated) { - return@apply - } - - id() - dob() - emails().ifPresent { it.validate() } - encryptedSsn() - ethnicity() - firstName() - gender() - lastName() - middleName() - phoneNumbers().ifPresent { it.validate() } - preferredName() - residence().ifPresent { it.validate() } - ssn() - 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 (id.asKnown().isPresent) 1 else 0) + - (if (dob.asKnown().isPresent) 1 else 0) + - (emails.asKnown().getOrNull()?.validity() ?: 0) + - (if (encryptedSsn.asKnown().isPresent) 1 else 0) + - (if (ethnicity.asKnown().isPresent) 1 else 0) + - (if (firstName.asKnown().isPresent) 1 else 0) + - (if (gender.asKnown().isPresent) 1 else 0) + - (if (lastName.asKnown().isPresent) 1 else 0) + - (if (middleName.asKnown().isPresent) 1 else 0) + - (phoneNumbers.asKnown().getOrNull()?.validity() ?: 0) + - (if (preferredName.asKnown().isPresent) 1 else 0) + - (residence.asKnown().getOrNull()?.validity() ?: 0) + - (if (ssn.asKnown().isPresent) 1 else 0) - - class Emails - 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 [Emails]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Emails]. */ - 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(emails: Emails) = apply { - data = emails.data - type = emails.type - additionalProperties = emails.additionalProperties.toMutableMap() - } - - fun data(data: Boolean) = data(JsonField.of(data)) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Boolean] 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: Boolean) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Boolean] 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 [Emails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Emails = - Emails(data, type, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Emails = apply { - if (validated) { - return@apply - } - - data() - type() - 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) + - (if (type.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Emails && - data == other.data && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(data, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Emails{data=$data, type=$type, additionalProperties=$additionalProperties}" - } - - class PhoneNumbers - 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 [PhoneNumbers]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PhoneNumbers]. */ - 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(phoneNumbers: PhoneNumbers) = apply { - data = phoneNumbers.data - type = phoneNumbers.type - additionalProperties = phoneNumbers.additionalProperties.toMutableMap() - } - - fun data(data: Boolean) = data(JsonField.of(data)) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Boolean] 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: Boolean) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Boolean] 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 [PhoneNumbers]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): PhoneNumbers = - PhoneNumbers(data, type, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): PhoneNumbers = apply { - if (validated) { - return@apply - } - - data() - type() - 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) + - (if (type.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PhoneNumbers && - data == other.data && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(data, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PhoneNumbers{data=$data, type=$type, additionalProperties=$additionalProperties}" - } - - class Residence - private constructor( - private val city: JsonField, - private val country: JsonField, - private val line1: JsonField, - private val line2: JsonField, - private val postalCode: JsonField, - private val state: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("city") - @ExcludeMissing - city: JsonField = JsonMissing.of(), - @JsonProperty("country") - @ExcludeMissing - country: JsonField = JsonMissing.of(), - @JsonProperty("line1") - @ExcludeMissing - line1: JsonField = JsonMissing.of(), - @JsonProperty("line2") - @ExcludeMissing - line2: JsonField = JsonMissing.of(), - @JsonProperty("postal_code") - @ExcludeMissing - postalCode: JsonField = JsonMissing.of(), - @JsonProperty("state") - @ExcludeMissing - state: JsonField = JsonMissing.of(), - ) : this(city, country, line1, line2, postalCode, state, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun city(): Optional = city.getOptional("city") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun country(): Optional = country.getOptional("country") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun line1(): Optional = line1.getOptional("line1") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun line2(): Optional = line2.getOptional("line2") - - /** - * @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") - - /** - * @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") - - /** - * Returns the raw JSON value of [city]. - * - * Unlike [city], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - - /** - * Returns the raw JSON value of [country]. - * - * Unlike [country], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("country") - @ExcludeMissing - fun _country(): JsonField = country - - /** - * Returns the raw JSON value of [line1]. - * - * Unlike [line1], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - - /** - * Returns the raw JSON value of [line2]. - * - * Unlike [line2], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - - /** - * Returns the raw JSON value of [postalCode]. - * - * Unlike [postalCode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("postal_code") - @ExcludeMissing - fun _postalCode(): JsonField = postalCode - - /** - * Returns the raw JSON value of [state]. - * - * Unlike [state], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - @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 [Residence]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Residence]. */ - 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 postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(residence: Residence) = apply { - city = residence.city - country = residence.country - line1 = residence.line1 - line2 = residence.line2 - postalCode = residence.postalCode - state = residence.state - additionalProperties = residence.additionalProperties.toMutableMap() - } - - fun city(city: Boolean) = city(JsonField.of(city)) - - /** - * Sets [Builder.city] to an arbitrary JSON value. - * - * You should usually call [Builder.city] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun city(city: JsonField) = apply { this.city = city } - - fun country(country: Boolean) = country(JsonField.of(country)) - - /** - * Sets [Builder.country] to an arbitrary JSON value. - * - * You should usually call [Builder.country] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun country(country: JsonField) = apply { this.country = country } - - fun line1(line1: Boolean) = line1(JsonField.of(line1)) - - /** - * Sets [Builder.line1] to an arbitrary JSON value. - * - * You should usually call [Builder.line1] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun line1(line1: JsonField) = apply { this.line1 = line1 } - - fun line2(line2: Boolean) = line2(JsonField.of(line2)) - - /** - * Sets [Builder.line2] to an arbitrary JSON value. - * - * You should usually call [Builder.line2] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun line2(line2: JsonField) = apply { this.line2 = line2 } - - fun postalCode(postalCode: Boolean) = postalCode(JsonField.of(postalCode)) - - /** - * Sets [Builder.postalCode] to an arbitrary JSON value. - * - * You should usually call [Builder.postalCode] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun postalCode(postalCode: JsonField) = apply { - this.postalCode = postalCode - } - - fun state(state: Boolean) = state(JsonField.of(state)) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun state(state: JsonField) = apply { this.state = state } - - 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 [Residence]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Residence = - Residence( - city, - country, - line1, - line2, - postalCode, - state, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Residence = apply { - if (validated) { - return@apply - } - - city() - country() - line1() - line2() - postalCode() - state() - 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 (city.asKnown().isPresent) 1 else 0) + - (if (country.asKnown().isPresent) 1 else 0) + - (if (line1.asKnown().isPresent) 1 else 0) + - (if (line2.asKnown().isPresent) 1 else 0) + - (if (postalCode.asKnown().isPresent) 1 else 0) + - (if (state.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Residence && - city == other.city && - country == other.country && - line1 == other.line1 && - line2 == other.line2 && - postalCode == other.postalCode && - state == other.state && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - city, - country, - line1, - line2, - postalCode, - state, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Residence{city=$city, country=$country, line1=$line1, line2=$line2, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SupportedIndividualFields && - 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 - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - dob, - emails, - encryptedSsn, - ethnicity, - firstName, - gender, - lastName, - middleName, - phoneNumbers, - preferredName, - residence, - ssn, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SupportedIndividualFields{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}" - } - - class SupportedPayGroupFields - private constructor( - private val id: JsonField, - private val individualIds: JsonField, - private val name: JsonField, - private val payFrequencies: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("individual_ids") - @ExcludeMissing - individualIds: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("pay_frequencies") - @ExcludeMissing - payFrequencies: JsonField = JsonMissing.of(), - ) : this(id, individualIds, name, payFrequencies, mutableMapOf()) - - /** - * @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") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun individualIds(): Optional = individualIds.getOptional("individual_ids") - - /** - * @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 payFrequencies(): Optional = - payFrequencies.getOptional("pay_frequencies") - - /** - * 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 - - /** - * Returns the raw JSON value of [individualIds]. - * - * Unlike [individualIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("individual_ids") - @ExcludeMissing - fun _individualIds(): JsonField = individualIds - - /** - * 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 [payFrequencies]. - * - * Unlike [payFrequencies], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("pay_frequencies") - @ExcludeMissing - fun _payFrequencies(): JsonField = payFrequencies - - @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 - * [SupportedPayGroupFields]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SupportedPayGroupFields]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var individualIds: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var payFrequencies: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(supportedPayGroupFields: SupportedPayGroupFields) = apply { - id = supportedPayGroupFields.id - individualIds = supportedPayGroupFields.individualIds - name = supportedPayGroupFields.name - payFrequencies = supportedPayGroupFields.payFrequencies - additionalProperties = - supportedPayGroupFields.additionalProperties.toMutableMap() - } - - fun id(id: Boolean) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [Boolean] 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 individualIds(individualIds: Boolean) = - individualIds(JsonField.of(individualIds)) - - /** - * Sets [Builder.individualIds] to an arbitrary JSON value. - * - * You should usually call [Builder.individualIds] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun individualIds(individualIds: JsonField) = apply { - this.individualIds = individualIds - } - - fun name(name: Boolean) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [Boolean] 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 payFrequencies(payFrequencies: Boolean) = - payFrequencies(JsonField.of(payFrequencies)) - - /** - * Sets [Builder.payFrequencies] to an arbitrary JSON value. - * - * You should usually call [Builder.payFrequencies] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun payFrequencies(payFrequencies: JsonField) = apply { - this.payFrequencies = payFrequencies - } - - 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 [SupportedPayGroupFields]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SupportedPayGroupFields = - SupportedPayGroupFields( - id, - individualIds, - name, - payFrequencies, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SupportedPayGroupFields = apply { - if (validated) { - return@apply - } - - id() - individualIds() - name() - payFrequencies() - 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 (id.asKnown().isPresent) 1 else 0) + - (if (individualIds.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (payFrequencies.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SupportedPayGroupFields && - id == other.id && - individualIds == other.individualIds && - name == other.name && - payFrequencies == other.payFrequencies && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, individualIds, name, payFrequencies, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SupportedPayGroupFields{id=$id, individualIds=$individualIds, name=$name, payFrequencies=$payFrequencies, additionalProperties=$additionalProperties}" - } - - class SupportedPayStatementFields - private constructor( - private val paging: JsonField, - private val payStatements: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("paging") - @ExcludeMissing - paging: JsonField = JsonMissing.of(), - @JsonProperty("pay_statements") - @ExcludeMissing - payStatements: JsonField = JsonMissing.of(), - ) : this(paging, payStatements, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun paging(): Optional = paging.getOptional("paging") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun payStatements(): Optional = - payStatements.getOptional("pay_statements") - - /** - * Returns the raw JSON value of [paging]. - * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - - /** - * Returns the raw JSON value of [payStatements]. - * - * Unlike [payStatements], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("pay_statements") - @ExcludeMissing - fun _payStatements(): JsonField = payStatements - - @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 - * [SupportedPayStatementFields]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SupportedPayStatementFields]. */ - class Builder internal constructor() { - - private var paging: JsonField = JsonMissing.of() - private var payStatements: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(supportedPayStatementFields: SupportedPayStatementFields) = - apply { - paging = supportedPayStatementFields.paging - payStatements = supportedPayStatementFields.payStatements - additionalProperties = - supportedPayStatementFields.additionalProperties.toMutableMap() - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - /** - * Sets [Builder.paging] to an arbitrary JSON value. - * - * You should usually call [Builder.paging] with a well-typed [Paging] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun payStatements(payStatements: PayStatements) = - payStatements(JsonField.of(payStatements)) - - /** - * Sets [Builder.payStatements] to an arbitrary JSON value. - * - * You should usually call [Builder.payStatements] with a well-typed - * [PayStatements] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun payStatements(payStatements: JsonField) = apply { - this.payStatements = payStatements - } - - 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 [SupportedPayStatementFields]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SupportedPayStatementFields = - SupportedPayStatementFields( - paging, - payStatements, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SupportedPayStatementFields = apply { - if (validated) { - return@apply - } - - paging().ifPresent { it.validate() } - payStatements().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 = - (paging.asKnown().getOrNull()?.validity() ?: 0) + - (payStatements.asKnown().getOrNull()?.validity() ?: 0) - - class Paging - private constructor( - private val count: JsonField, - private val offset: 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()) - - /** - * @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 count(): Boolean = count.getRequired("count") - - /** - * @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(): Boolean = offset.getRequired("offset") - - /** - * Returns the raw JSON value of [count]. - * - * Unlike [count], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @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) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Paging]. - * - * The following fields are required: - * ```java - * .count() - * .offset() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Paging]. */ - class Builder internal constructor() { - - private var count: JsonField? = null - private var offset: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(paging: Paging) = apply { - count = paging.count - offset = paging.offset - additionalProperties = paging.additionalProperties.toMutableMap() - } - - fun count(count: Boolean) = count(JsonField.of(count)) - - /** - * Sets [Builder.count] to an arbitrary JSON value. - * - * You should usually call [Builder.count] with a well-typed [Boolean] 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: Boolean) = offset(JsonField.of(offset)) - - /** - * Sets [Builder.offset] to an arbitrary JSON value. - * - * You should usually call [Builder.offset] with a well-typed [Boolean] - * 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 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 [Paging]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .count() - * .offset() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Paging = - Paging( - checkRequired("count", count), - checkRequired("offset", offset), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Paging = apply { - if (validated) { - return@apply - } - - count() - offset() - 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 (count.asKnown().isPresent) 1 else 0) + - (if (offset.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Paging && - count == other.count && - offset == other.offset && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(count, offset, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Paging{count=$count, offset=$offset, additionalProperties=$additionalProperties}" - } - - class PayStatements - private constructor( - private val earnings: JsonField, - private val employeeDeductions: JsonField, - private val employerContributions: JsonField, - private val grossPay: JsonField, - private val individualId: JsonField, - private val netPay: JsonField, - private val paymentMethod: JsonField, - private val taxes: JsonField, - private val totalHours: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("earnings") - @ExcludeMissing - earnings: JsonField = JsonMissing.of(), - @JsonProperty("employee_deductions") - @ExcludeMissing - employeeDeductions: JsonField = JsonMissing.of(), - @JsonProperty("employer_contributions") - @ExcludeMissing - employerContributions: JsonField = JsonMissing.of(), - @JsonProperty("gross_pay") - @ExcludeMissing - grossPay: JsonField = JsonMissing.of(), - @JsonProperty("individual_id") - @ExcludeMissing - individualId: JsonField = JsonMissing.of(), - @JsonProperty("net_pay") - @ExcludeMissing - netPay: JsonField = JsonMissing.of(), - @JsonProperty("payment_method") - @ExcludeMissing - paymentMethod: JsonField = JsonMissing.of(), - @JsonProperty("taxes") - @ExcludeMissing - taxes: JsonField = JsonMissing.of(), - @JsonProperty("total_hours") - @ExcludeMissing - totalHours: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - ) : this( - earnings, - employeeDeductions, - employerContributions, - grossPay, - individualId, - netPay, - paymentMethod, - taxes, - totalHours, - type, - mutableMapOf(), - ) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun earnings(): Optional = earnings.getOptional("earnings") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun employeeDeductions(): Optional = - employeeDeductions.getOptional("employee_deductions") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun employerContributions(): Optional = - employerContributions.getOptional("employer_contributions") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun grossPay(): Optional = grossPay.getOptional("gross_pay") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun individualId(): Optional = - individualId.getOptional("individual_id") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun netPay(): Optional = netPay.getOptional("net_pay") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun paymentMethod(): Optional = - paymentMethod.getOptional("payment_method") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun taxes(): Optional = taxes.getOptional("taxes") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun totalHours(): Optional = totalHours.getOptional("total_hours") - - /** - * @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 [earnings]. - * - * Unlike [earnings], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("earnings") - @ExcludeMissing - fun _earnings(): JsonField = earnings - - /** - * Returns the raw JSON value of [employeeDeductions]. - * - * Unlike [employeeDeductions], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("employee_deductions") - @ExcludeMissing - fun _employeeDeductions(): JsonField = employeeDeductions - - /** - * Returns the raw JSON value of [employerContributions]. - * - * Unlike [employerContributions], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("employer_contributions") - @ExcludeMissing - fun _employerContributions(): JsonField = - employerContributions - - /** - * Returns the raw JSON value of [grossPay]. - * - * Unlike [grossPay], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("gross_pay") - @ExcludeMissing - fun _grossPay(): JsonField = grossPay - - /** - * Returns the raw JSON value of [individualId]. - * - * Unlike [individualId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("individual_id") - @ExcludeMissing - fun _individualId(): JsonField = individualId - - /** - * Returns the raw JSON value of [netPay]. - * - * Unlike [netPay], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("net_pay") - @ExcludeMissing - fun _netPay(): JsonField = netPay - - /** - * Returns the raw JSON value of [paymentMethod]. - * - * Unlike [paymentMethod], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("payment_method") - @ExcludeMissing - fun _paymentMethod(): JsonField = paymentMethod - - /** - * Returns the raw JSON value of [taxes]. - * - * Unlike [taxes], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("taxes") @ExcludeMissing fun _taxes(): JsonField = taxes - - /** - * Returns the raw JSON value of [totalHours]. - * - * Unlike [totalHours], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("total_hours") - @ExcludeMissing - fun _totalHours(): JsonField = totalHours - - /** - * 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 - * [PayStatements]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PayStatements]. */ - class Builder internal constructor() { - - private var earnings: JsonField = JsonMissing.of() - private var employeeDeductions: JsonField = - JsonMissing.of() - private var employerContributions: JsonField = - JsonMissing.of() - private var grossPay: JsonField = JsonMissing.of() - private var individualId: JsonField = JsonMissing.of() - private var netPay: JsonField = JsonMissing.of() - private var paymentMethod: JsonField = JsonMissing.of() - private var taxes: JsonField = JsonMissing.of() - private var totalHours: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(payStatements: PayStatements) = apply { - earnings = payStatements.earnings - employeeDeductions = payStatements.employeeDeductions - employerContributions = payStatements.employerContributions - grossPay = payStatements.grossPay - individualId = payStatements.individualId - netPay = payStatements.netPay - paymentMethod = payStatements.paymentMethod - taxes = payStatements.taxes - totalHours = payStatements.totalHours - type = payStatements.type - additionalProperties = payStatements.additionalProperties.toMutableMap() - } - - fun earnings(earnings: Earnings) = earnings(JsonField.of(earnings)) - - /** - * Sets [Builder.earnings] to an arbitrary JSON value. - * - * You should usually call [Builder.earnings] with a well-typed [Earnings] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun earnings(earnings: JsonField) = apply { - this.earnings = earnings - } - - fun employeeDeductions(employeeDeductions: EmployeeDeductions) = - employeeDeductions(JsonField.of(employeeDeductions)) - - /** - * Sets [Builder.employeeDeductions] to an arbitrary JSON value. - * - * You should usually call [Builder.employeeDeductions] with a well-typed - * [EmployeeDeductions] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun employeeDeductions(employeeDeductions: JsonField) = - apply { - this.employeeDeductions = employeeDeductions - } - - fun employerContributions(employerContributions: EmployerContributions) = - employerContributions(JsonField.of(employerContributions)) - - /** - * Sets [Builder.employerContributions] to an arbitrary JSON value. - * - * You should usually call [Builder.employerContributions] with a well-typed - * [EmployerContributions] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun employerContributions( - employerContributions: JsonField - ) = apply { this.employerContributions = employerContributions } - - fun grossPay(grossPay: Boolean) = grossPay(JsonField.of(grossPay)) - - /** - * Sets [Builder.grossPay] to an arbitrary JSON value. - * - * You should usually call [Builder.grossPay] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun grossPay(grossPay: JsonField) = apply { - this.grossPay = grossPay - } - - fun individualId(individualId: Boolean) = - individualId(JsonField.of(individualId)) - - /** - * Sets [Builder.individualId] to an arbitrary JSON value. - * - * You should usually call [Builder.individualId] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun individualId(individualId: JsonField) = apply { - this.individualId = individualId - } - - fun netPay(netPay: Boolean) = netPay(JsonField.of(netPay)) - - /** - * Sets [Builder.netPay] to an arbitrary JSON value. - * - * You should usually call [Builder.netPay] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun netPay(netPay: JsonField) = apply { this.netPay = netPay } - - fun paymentMethod(paymentMethod: Boolean) = - paymentMethod(JsonField.of(paymentMethod)) - - /** - * Sets [Builder.paymentMethod] to an arbitrary JSON value. - * - * You should usually call [Builder.paymentMethod] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun paymentMethod(paymentMethod: JsonField) = apply { - this.paymentMethod = paymentMethod - } - - fun taxes(taxes: Taxes) = taxes(JsonField.of(taxes)) - - /** - * Sets [Builder.taxes] to an arbitrary JSON value. - * - * You should usually call [Builder.taxes] with a well-typed [Taxes] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun taxes(taxes: JsonField) = apply { this.taxes = taxes } - - fun totalHours(totalHours: Boolean) = totalHours(JsonField.of(totalHours)) - - /** - * Sets [Builder.totalHours] to an arbitrary JSON value. - * - * You should usually call [Builder.totalHours] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun totalHours(totalHours: JsonField) = apply { - this.totalHours = totalHours - } - - fun type(type: Boolean) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Boolean] 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 [PayStatements]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): PayStatements = - PayStatements( - earnings, - employeeDeductions, - employerContributions, - grossPay, - individualId, - netPay, - paymentMethod, - taxes, - totalHours, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): PayStatements = apply { - if (validated) { - return@apply - } - - earnings().ifPresent { it.validate() } - employeeDeductions().ifPresent { it.validate() } - employerContributions().ifPresent { it.validate() } - grossPay() - individualId() - netPay() - paymentMethod() - taxes().ifPresent { it.validate() } - totalHours() - type() - 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 = - (earnings.asKnown().getOrNull()?.validity() ?: 0) + - (employeeDeductions.asKnown().getOrNull()?.validity() ?: 0) + - (employerContributions.asKnown().getOrNull()?.validity() ?: 0) + - (if (grossPay.asKnown().isPresent) 1 else 0) + - (if (individualId.asKnown().isPresent) 1 else 0) + - (if (netPay.asKnown().isPresent) 1 else 0) + - (if (paymentMethod.asKnown().isPresent) 1 else 0) + - (taxes.asKnown().getOrNull()?.validity() ?: 0) + - (if (totalHours.asKnown().isPresent) 1 else 0) + - (if (type.asKnown().isPresent) 1 else 0) - - class Earnings - private constructor( - private val amount: JsonField, - private val currency: JsonField, - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - ) : this(amount, currency, name, type, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * @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 type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("amount") - @ExcludeMissing - fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * 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 [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 [Earnings]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Earnings]. */ - class Builder internal constructor() { - - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(earnings: Earnings) = apply { - amount = earnings.amount - currency = earnings.currency - name = earnings.name - type = earnings.type - additionalProperties = earnings.additionalProperties.toMutableMap() - } - - fun amount(amount: Boolean) = amount(JsonField.of(amount)) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun currency(currency: Boolean) = currency(JsonField.of(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { - this.currency = currency - } - - fun name(name: Boolean) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [Boolean] - * 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 type(type: Boolean) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Boolean] - * 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 [Earnings]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Earnings = - Earnings( - amount, - currency, - name, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Earnings = apply { - if (validated) { - return@apply - } - - amount() - currency() - name() - type() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (type.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Earnings && - amount == other.amount && - currency == other.currency && - name == other.name && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(amount, currency, name, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Earnings{amount=$amount, currency=$currency, name=$name, type=$type, additionalProperties=$additionalProperties}" - } - - class EmployeeDeductions - private constructor( - private val amount: JsonField, - private val currency: JsonField, - private val name: JsonField, - private val preTax: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("pre_tax") - @ExcludeMissing - preTax: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - ) : this(amount, currency, name, preTax, type, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * @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 preTax(): Optional = preTax.getOptional("pre_tax") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("amount") - @ExcludeMissing - fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * 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 [preTax]. - * - * Unlike [preTax], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("pre_tax") - @ExcludeMissing - fun _preTax(): JsonField = preTax - - /** - * 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 - * [EmployeeDeductions]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EmployeeDeductions]. */ - class Builder internal constructor() { - - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var preTax: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(employeeDeductions: EmployeeDeductions) = apply { - amount = employeeDeductions.amount - currency = employeeDeductions.currency - name = employeeDeductions.name - preTax = employeeDeductions.preTax - type = employeeDeductions.type - additionalProperties = - employeeDeductions.additionalProperties.toMutableMap() - } - - fun amount(amount: Boolean) = amount(JsonField.of(amount)) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun currency(currency: Boolean) = currency(JsonField.of(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { - this.currency = currency - } - - fun name(name: Boolean) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [Boolean] - * 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 preTax(preTax: Boolean) = preTax(JsonField.of(preTax)) - - /** - * Sets [Builder.preTax] to an arbitrary JSON value. - * - * You should usually call [Builder.preTax] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun preTax(preTax: JsonField) = apply { this.preTax = preTax } - - fun type(type: Boolean) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Boolean] - * 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 [EmployeeDeductions]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): EmployeeDeductions = - EmployeeDeductions( - amount, - currency, - name, - preTax, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EmployeeDeductions = apply { - if (validated) { - return@apply - } - - amount() - currency() - name() - preTax() - type() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (preTax.asKnown().isPresent) 1 else 0) + - (if (type.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EmployeeDeductions && - amount == other.amount && - currency == other.currency && - name == other.name && - preTax == other.preTax && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(amount, currency, name, preTax, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EmployeeDeductions{amount=$amount, currency=$currency, name=$name, preTax=$preTax, type=$type, additionalProperties=$additionalProperties}" - } - - class EmployerContributions - private constructor( - private val amount: JsonField, - private val currency: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - ) : this(amount, currency, name, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * @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 [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("amount") - @ExcludeMissing - fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * 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 - * [EmployerContributions]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EmployerContributions]. */ - class Builder internal constructor() { - - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(employerContributions: EmployerContributions) = - apply { - amount = employerContributions.amount - currency = employerContributions.currency - name = employerContributions.name - additionalProperties = - employerContributions.additionalProperties.toMutableMap() - } - - fun amount(amount: Boolean) = amount(JsonField.of(amount)) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun currency(currency: Boolean) = currency(JsonField.of(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { - this.currency = currency - } - - fun name(name: Boolean) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [Boolean] - * 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 [EmployerContributions]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): EmployerContributions = - EmployerContributions( - amount, - currency, - name, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EmployerContributions = apply { - if (validated) { - return@apply - } - - amount() - currency() - 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 (amount.asKnown().isPresent) 1 else 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is EmployerContributions && - amount == other.amount && - currency == other.currency && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(amount, currency, name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EmployerContributions{amount=$amount, currency=$currency, name=$name, additionalProperties=$additionalProperties}" - } - - class Taxes - private constructor( - private val amount: JsonField, - private val currency: JsonField, - private val employer: JsonField, - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("employer") - @ExcludeMissing - employer: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - ) : this(amount, currency, employer, name, type, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun employer(): Optional = employer.getOptional("employer") - - /** - * @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 type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("amount") - @ExcludeMissing - fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [employer]. - * - * Unlike [employer], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("employer") - @ExcludeMissing - fun _employer(): JsonField = employer - - /** - * 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 [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 [Taxes]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Taxes]. */ - class Builder internal constructor() { - - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var employer: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(taxes: Taxes) = apply { - amount = taxes.amount - currency = taxes.currency - employer = taxes.employer - name = taxes.name - type = taxes.type - additionalProperties = taxes.additionalProperties.toMutableMap() - } - - fun amount(amount: Boolean) = amount(JsonField.of(amount)) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun currency(currency: Boolean) = currency(JsonField.of(currency)) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun currency(currency: JsonField) = apply { - this.currency = currency - } - - fun employer(employer: Boolean) = employer(JsonField.of(employer)) - - /** - * Sets [Builder.employer] to an arbitrary JSON value. - * - * You should usually call [Builder.employer] with a well-typed - * [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun employer(employer: JsonField) = apply { - this.employer = employer - } - - fun name(name: Boolean) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [Boolean] - * 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 type(type: Boolean) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Boolean] - * 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 [Taxes]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Taxes = - Taxes( - amount, - currency, - employer, - name, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Taxes = apply { - if (validated) { - return@apply - } - - amount() - currency() - employer() - name() - type() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (employer.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (type.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Taxes && - amount == other.amount && - currency == other.currency && - employer == other.employer && - name == other.name && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - amount, - currency, - employer, - name, - type, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Taxes{amount=$amount, currency=$currency, employer=$employer, name=$name, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PayStatements && - earnings == other.earnings && - employeeDeductions == other.employeeDeductions && - employerContributions == other.employerContributions && - grossPay == other.grossPay && - individualId == other.individualId && - netPay == other.netPay && - paymentMethod == other.paymentMethod && - taxes == other.taxes && - totalHours == other.totalHours && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - earnings, - employeeDeductions, - employerContributions, - grossPay, - individualId, - netPay, - paymentMethod, - taxes, - totalHours, - type, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PayStatements{earnings=$earnings, employeeDeductions=$employeeDeductions, employerContributions=$employerContributions, grossPay=$grossPay, individualId=$individualId, netPay=$netPay, paymentMethod=$paymentMethod, taxes=$taxes, totalHours=$totalHours, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SupportedPayStatementFields && - paging == other.paging && - payStatements == other.payStatements && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(paging, payStatements, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SupportedPayStatementFields{paging=$paging, payStatements=$payStatements, additionalProperties=$additionalProperties}" - } - - class SupportedPaymentFields - private constructor( - private val id: JsonField, - private val companyDebit: JsonField, - private val debitDate: JsonField, - private val employeeTaxes: JsonField, - private val employerTaxes: JsonField, - private val grossPay: JsonField, - private val individualIds: JsonField, - private val netPay: JsonField, - private val payDate: JsonField, - private val payFrequencies: JsonField, - private val payGroupIds: JsonField, - private val payPeriod: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("company_debit") - @ExcludeMissing - companyDebit: JsonField = JsonMissing.of(), - @JsonProperty("debit_date") - @ExcludeMissing - debitDate: JsonField = JsonMissing.of(), - @JsonProperty("employee_taxes") - @ExcludeMissing - employeeTaxes: JsonField = JsonMissing.of(), - @JsonProperty("employer_taxes") - @ExcludeMissing - employerTaxes: JsonField = JsonMissing.of(), - @JsonProperty("gross_pay") - @ExcludeMissing - grossPay: JsonField = JsonMissing.of(), - @JsonProperty("individual_ids") - @ExcludeMissing - individualIds: JsonField = JsonMissing.of(), - @JsonProperty("net_pay") - @ExcludeMissing - netPay: JsonField = JsonMissing.of(), - @JsonProperty("pay_date") - @ExcludeMissing - payDate: JsonField = JsonMissing.of(), - @JsonProperty("pay_frequencies") - @ExcludeMissing - payFrequencies: JsonField = JsonMissing.of(), - @JsonProperty("pay_group_ids") - @ExcludeMissing - payGroupIds: JsonField = JsonMissing.of(), - @JsonProperty("pay_period") - @ExcludeMissing - payPeriod: JsonField = JsonMissing.of(), - ) : this( - id, - companyDebit, - debitDate, - employeeTaxes, - employerTaxes, - grossPay, - individualIds, - netPay, - payDate, - payFrequencies, - payGroupIds, - payPeriod, - mutableMapOf(), - ) - - /** - * @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") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun companyDebit(): Optional = companyDebit.getOptional("company_debit") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun debitDate(): Optional = debitDate.getOptional("debit_date") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun employeeTaxes(): Optional = employeeTaxes.getOptional("employee_taxes") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun employerTaxes(): Optional = employerTaxes.getOptional("employer_taxes") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun grossPay(): Optional = grossPay.getOptional("gross_pay") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun individualIds(): Optional = individualIds.getOptional("individual_ids") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun netPay(): Optional = netPay.getOptional("net_pay") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun payDate(): Optional = payDate.getOptional("pay_date") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun payFrequencies(): Optional = - payFrequencies.getOptional("pay_frequencies") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun payGroupIds(): Optional = payGroupIds.getOptional("pay_group_ids") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun payPeriod(): Optional = payPeriod.getOptional("pay_period") - - /** - * 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 - - /** - * Returns the raw JSON value of [companyDebit]. - * - * Unlike [companyDebit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("company_debit") - @ExcludeMissing - fun _companyDebit(): JsonField = companyDebit - - /** - * Returns the raw JSON value of [debitDate]. - * - * Unlike [debitDate], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("debit_date") - @ExcludeMissing - fun _debitDate(): JsonField = debitDate - - /** - * Returns the raw JSON value of [employeeTaxes]. - * - * Unlike [employeeTaxes], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("employee_taxes") - @ExcludeMissing - fun _employeeTaxes(): JsonField = employeeTaxes - - /** - * Returns the raw JSON value of [employerTaxes]. - * - * Unlike [employerTaxes], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("employer_taxes") - @ExcludeMissing - fun _employerTaxes(): JsonField = employerTaxes - - /** - * Returns the raw JSON value of [grossPay]. - * - * Unlike [grossPay], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("gross_pay") - @ExcludeMissing - fun _grossPay(): JsonField = grossPay - - /** - * Returns the raw JSON value of [individualIds]. - * - * Unlike [individualIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("individual_ids") - @ExcludeMissing - fun _individualIds(): JsonField = individualIds - - /** - * Returns the raw JSON value of [netPay]. - * - * Unlike [netPay], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("net_pay") @ExcludeMissing fun _netPay(): JsonField = netPay - - /** - * Returns the raw JSON value of [payDate]. - * - * Unlike [payDate], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("pay_date") - @ExcludeMissing - fun _payDate(): JsonField = payDate - - /** - * Returns the raw JSON value of [payFrequencies]. - * - * Unlike [payFrequencies], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("pay_frequencies") - @ExcludeMissing - fun _payFrequencies(): JsonField = payFrequencies - - /** - * Returns the raw JSON value of [payGroupIds]. - * - * Unlike [payGroupIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("pay_group_ids") - @ExcludeMissing - fun _payGroupIds(): JsonField = payGroupIds - - /** - * Returns the raw JSON value of [payPeriod]. - * - * Unlike [payPeriod], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("pay_period") - @ExcludeMissing - fun _payPeriod(): JsonField = payPeriod - - @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 - * [SupportedPaymentFields]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SupportedPaymentFields]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var companyDebit: JsonField = JsonMissing.of() - private var debitDate: JsonField = JsonMissing.of() - private var employeeTaxes: JsonField = JsonMissing.of() - private var employerTaxes: JsonField = JsonMissing.of() - private var grossPay: JsonField = JsonMissing.of() - private var individualIds: JsonField = JsonMissing.of() - private var netPay: JsonField = JsonMissing.of() - private var payDate: JsonField = JsonMissing.of() - private var payFrequencies: JsonField = JsonMissing.of() - private var payGroupIds: JsonField = JsonMissing.of() - private var payPeriod: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(supportedPaymentFields: SupportedPaymentFields) = apply { - id = supportedPaymentFields.id - companyDebit = supportedPaymentFields.companyDebit - debitDate = supportedPaymentFields.debitDate - employeeTaxes = supportedPaymentFields.employeeTaxes - employerTaxes = supportedPaymentFields.employerTaxes - grossPay = supportedPaymentFields.grossPay - individualIds = supportedPaymentFields.individualIds - netPay = supportedPaymentFields.netPay - payDate = supportedPaymentFields.payDate - payFrequencies = supportedPaymentFields.payFrequencies - payGroupIds = supportedPaymentFields.payGroupIds - payPeriod = supportedPaymentFields.payPeriod - additionalProperties = - supportedPaymentFields.additionalProperties.toMutableMap() - } - - fun id(id: Boolean) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [Boolean] 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 companyDebit(companyDebit: Boolean) = - companyDebit(JsonField.of(companyDebit)) - - /** - * Sets [Builder.companyDebit] to an arbitrary JSON value. - * - * You should usually call [Builder.companyDebit] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun companyDebit(companyDebit: JsonField) = apply { - this.companyDebit = companyDebit - } - - fun debitDate(debitDate: Boolean) = debitDate(JsonField.of(debitDate)) - - /** - * Sets [Builder.debitDate] to an arbitrary JSON value. - * - * You should usually call [Builder.debitDate] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun debitDate(debitDate: JsonField) = apply { - this.debitDate = debitDate - } - - fun employeeTaxes(employeeTaxes: Boolean) = - employeeTaxes(JsonField.of(employeeTaxes)) - - /** - * Sets [Builder.employeeTaxes] to an arbitrary JSON value. - * - * You should usually call [Builder.employeeTaxes] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun employeeTaxes(employeeTaxes: JsonField) = apply { - this.employeeTaxes = employeeTaxes - } - - fun employerTaxes(employerTaxes: Boolean) = - employerTaxes(JsonField.of(employerTaxes)) - - /** - * Sets [Builder.employerTaxes] to an arbitrary JSON value. - * - * You should usually call [Builder.employerTaxes] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun employerTaxes(employerTaxes: JsonField) = apply { - this.employerTaxes = employerTaxes - } - - fun grossPay(grossPay: Boolean) = grossPay(JsonField.of(grossPay)) - - /** - * Sets [Builder.grossPay] to an arbitrary JSON value. - * - * You should usually call [Builder.grossPay] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun grossPay(grossPay: JsonField) = apply { this.grossPay = grossPay } - - fun individualIds(individualIds: Boolean) = - individualIds(JsonField.of(individualIds)) - - /** - * Sets [Builder.individualIds] to an arbitrary JSON value. - * - * You should usually call [Builder.individualIds] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun individualIds(individualIds: JsonField) = apply { - this.individualIds = individualIds - } - - fun netPay(netPay: Boolean) = netPay(JsonField.of(netPay)) - - /** - * Sets [Builder.netPay] to an arbitrary JSON value. - * - * You should usually call [Builder.netPay] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun netPay(netPay: JsonField) = apply { this.netPay = netPay } - - fun payDate(payDate: Boolean) = payDate(JsonField.of(payDate)) - - /** - * Sets [Builder.payDate] to an arbitrary JSON value. - * - * You should usually call [Builder.payDate] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun payDate(payDate: JsonField) = apply { this.payDate = payDate } - - fun payFrequencies(payFrequencies: Boolean) = - payFrequencies(JsonField.of(payFrequencies)) - - /** - * Sets [Builder.payFrequencies] to an arbitrary JSON value. - * - * You should usually call [Builder.payFrequencies] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun payFrequencies(payFrequencies: JsonField) = apply { - this.payFrequencies = payFrequencies - } - - fun payGroupIds(payGroupIds: Boolean) = payGroupIds(JsonField.of(payGroupIds)) - - /** - * Sets [Builder.payGroupIds] to an arbitrary JSON value. - * - * You should usually call [Builder.payGroupIds] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun payGroupIds(payGroupIds: JsonField) = apply { - this.payGroupIds = payGroupIds - } - - fun payPeriod(payPeriod: PayPeriod) = payPeriod(JsonField.of(payPeriod)) - - /** - * Sets [Builder.payPeriod] to an arbitrary JSON value. - * - * You should usually call [Builder.payPeriod] with a well-typed [PayPeriod] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun payPeriod(payPeriod: JsonField) = apply { - this.payPeriod = payPeriod - } - - 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 [SupportedPaymentFields]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SupportedPaymentFields = - SupportedPaymentFields( - id, - companyDebit, - debitDate, - employeeTaxes, - employerTaxes, - grossPay, - individualIds, - netPay, - payDate, - payFrequencies, - payGroupIds, - payPeriod, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SupportedPaymentFields = apply { - if (validated) { - return@apply - } - - id() - companyDebit() - debitDate() - employeeTaxes() - employerTaxes() - grossPay() - individualIds() - netPay() - payDate() - payFrequencies() - payGroupIds() - payPeriod().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 (id.asKnown().isPresent) 1 else 0) + - (if (companyDebit.asKnown().isPresent) 1 else 0) + - (if (debitDate.asKnown().isPresent) 1 else 0) + - (if (employeeTaxes.asKnown().isPresent) 1 else 0) + - (if (employerTaxes.asKnown().isPresent) 1 else 0) + - (if (grossPay.asKnown().isPresent) 1 else 0) + - (if (individualIds.asKnown().isPresent) 1 else 0) + - (if (netPay.asKnown().isPresent) 1 else 0) + - (if (payDate.asKnown().isPresent) 1 else 0) + - (if (payFrequencies.asKnown().isPresent) 1 else 0) + - (if (payGroupIds.asKnown().isPresent) 1 else 0) + - (payPeriod.asKnown().getOrNull()?.validity() ?: 0) - - class PayPeriod - private constructor( - private val endDate: JsonField, - private val startDate: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("end_date") - @ExcludeMissing - endDate: JsonField = JsonMissing.of(), - @JsonProperty("start_date") - @ExcludeMissing - startDate: JsonField = JsonMissing.of(), - ) : this(endDate, startDate, mutableMapOf()) - - /** - * @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") - - /** - * @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") - - /** - * 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 - - /** - * 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 - - @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 [PayPeriod]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PayPeriod]. */ - class Builder internal constructor() { - - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(payPeriod: PayPeriod) = apply { - endDate = payPeriod.endDate - startDate = payPeriod.startDate - additionalProperties = payPeriod.additionalProperties.toMutableMap() - } - - fun endDate(endDate: Boolean) = endDate(JsonField.of(endDate)) - - /** - * Sets [Builder.endDate] to an arbitrary JSON value. - * - * You should usually call [Builder.endDate] with a well-typed [Boolean] - * 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 } - - fun startDate(startDate: Boolean) = startDate(JsonField.of(startDate)) - - /** - * Sets [Builder.startDate] to an arbitrary JSON value. - * - * You should usually call [Builder.startDate] with a well-typed [Boolean] - * 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 - } - - 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 [PayPeriod]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): PayPeriod = - PayPeriod(endDate, startDate, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): PayPeriod = apply { - if (validated) { - return@apply - } - - endDate() - startDate() - 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 (endDate.asKnown().isPresent) 1 else 0) + - (if (startDate.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PayPeriod && - endDate == other.endDate && - startDate == other.startDate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(endDate, startDate, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PayPeriod{endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SupportedPaymentFields && - id == other.id && - companyDebit == other.companyDebit && - debitDate == other.debitDate && - employeeTaxes == other.employeeTaxes && - employerTaxes == other.employerTaxes && - grossPay == other.grossPay && - individualIds == other.individualIds && - netPay == other.netPay && - payDate == other.payDate && - payFrequencies == other.payFrequencies && - payGroupIds == other.payGroupIds && - payPeriod == other.payPeriod && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - companyDebit, - debitDate, - employeeTaxes, - employerTaxes, - grossPay, - individualIds, - netPay, - payDate, - payFrequencies, - payGroupIds, - payPeriod, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SupportedPaymentFields{id=$id, companyDebit=$companyDebit, debitDate=$debitDate, employeeTaxes=$employeeTaxes, employerTaxes=$employerTaxes, grossPay=$grossPay, individualIds=$individualIds, netPay=$netPay, payDate=$payDate, payFrequencies=$payFrequencies, payGroupIds=$payGroupIds, payPeriod=$payPeriod, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SupportedFields && - company == other.company && - directory == other.directory && - employment == other.employment && - individual == other.individual && - payGroup == other.payGroup && - payStatement == other.payStatement && - payment == other.payment && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - company, - directory, - employment, - individual, - payGroup, - payStatement, - payment, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SupportedFields{company=$company, directory=$directory, employment=$employment, individual=$individual, payGroup=$payGroup, payStatement=$payStatement, payment=$payment, additionalProperties=$additionalProperties}" - } - - /** The type of authentication method. */ - 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 ASSISTED = of("assisted") - - @JvmField val CREDENTIAL = of("credential") - - @JvmField val API_TOKEN = of("api_token") - - @JvmField val API_CREDENTIAL = of("api_credential") - - @JvmField val OAUTH = of("oauth") + @JvmField val API = of("api") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } @@ -10110,6 +807,7 @@ private constructor( API_TOKEN, API_CREDENTIAL, OAUTH, + API, } /** @@ -10127,6 +825,7 @@ private constructor( API_TOKEN, API_CREDENTIAL, OAUTH, + API, /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -10145,6 +844,7 @@ private constructor( API_TOKEN -> Value.API_TOKEN API_CREDENTIAL -> Value.API_CREDENTIAL OAUTH -> Value.OAUTH + API -> Value.API else -> Value._UNKNOWN } @@ -10164,6 +864,7 @@ private constructor( API_TOKEN -> Known.API_TOKEN API_CREDENTIAL -> Known.API_CREDENTIAL OAUTH -> Known.OAUTH + API -> Known.API else -> throw FinchInvalidDataException("Unknown Type: $value") } @@ -10221,26 +922,234 @@ private constructor( override fun toString() = value.toString() } + /** The supported benefit types and their configurations */ + class BenefitsSupport + @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 [BenefitsSupport]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BenefitsSupport]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(benefitsSupport: BenefitsSupport) = apply { + additionalProperties = benefitsSupport.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 [BenefitsSupport]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BenefitsSupport = BenefitsSupport(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): BenefitsSupport = 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 other is BenefitsSupport && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "BenefitsSupport{additionalProperties=$additionalProperties}" + } + + /** The supported fields for each Finch product */ + class SupportedFields + @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 [SupportedFields]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SupportedFields]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(supportedFields: SupportedFields) = apply { + additionalProperties = supportedFields.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 [SupportedFields]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SupportedFields = SupportedFields(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): SupportedFields = 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 other is SupportedFields && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SupportedFields{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } return other is AuthenticationMethod && + type == other.type && benefitsSupport == other.benefitsSupport && supportedFields == other.supportedFields && - type == other.type && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(benefitsSupport, supportedFields, type, additionalProperties) + Objects.hash(type, benefitsSupport, supportedFields, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AuthenticationMethod{benefitsSupport=$benefitsSupport, supportedFields=$supportedFields, type=$type, additionalProperties=$additionalProperties}" + "AuthenticationMethod{type=$type, benefitsSupport=$benefitsSupport, supportedFields=$supportedFields, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -10250,30 +1159,30 @@ private constructor( return other is Provider && id == other.id && + displayName == other.displayName && + products == other.products && authenticationMethods == other.authenticationMethods && beta == other.beta && - displayName == other.displayName && icon == other.icon && logo == other.logo && manual == other.manual && mfaRequired == other.mfaRequired && primaryColor == other.primaryColor && - products == other.products && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( id, + displayName, + products, authenticationMethods, beta, - displayName, icon, logo, manual, mfaRequired, primaryColor, - products, additionalProperties, ) } @@ -10281,5 +1190,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Provider{id=$id, authenticationMethods=$authenticationMethods, beta=$beta, displayName=$displayName, icon=$icon, logo=$logo, manual=$manual, mfaRequired=$mfaRequired, primaryColor=$primaryColor, products=$products, additionalProperties=$additionalProperties}" + "Provider{id=$id, displayName=$displayName, products=$products, authenticationMethods=$authenticationMethods, beta=$beta, icon=$icon, logo=$logo, manual=$manual, mfaRequired=$mfaRequired, primaryColor=$primaryColor, additionalProperties=$additionalProperties}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPage.kt index ac8d8314..355f5772 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPage.kt @@ -13,8 +13,8 @@ class ProviderListPage private constructor( private val service: ProviderService, private val params: ProviderListParams, - private val items: List, -) : Page { + private val items: List, +) : Page { override fun hasNextPage(): Boolean = false @@ -23,13 +23,13 @@ private constructor( override fun nextPage(): ProviderListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager.from(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): ProviderListParams = params /** The response that this page was parsed from. */ - override fun items(): List = items + override fun items(): List = items fun toBuilder() = Builder().from(this) @@ -53,7 +53,7 @@ private constructor( private var service: ProviderService? = null private var params: ProviderListParams? = null - private var items: List? = null + private var items: List? = null @JvmSynthetic internal fun from(providerListPage: ProviderListPage) = apply { @@ -68,7 +68,7 @@ private constructor( fun params(params: ProviderListParams) = apply { this.params = params } /** The response that this page was parsed from. */ - fun items(items: List) = apply { this.items = items } + fun items(items: List) = apply { this.items = items } /** * Returns an immutable instance of [ProviderListPage]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPageAsync.kt index 8a02daf9..fce3d905 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPageAsync.kt @@ -16,8 +16,8 @@ private constructor( private val service: ProviderServiceAsync, private val streamHandlerExecutor: Executor, private val params: ProviderListParams, - private val items: List, -) : PageAsync { + private val items: List, +) : PageAsync { override fun hasNextPage(): Boolean = false @@ -27,13 +27,14 @@ private constructor( override fun nextPage(): CompletableFuture = service.list(nextPageParams()) - fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): ProviderListParams = params /** The response that this page was parsed from. */ - override fun items(): List = items + override fun items(): List = items fun toBuilder() = Builder().from(this) @@ -59,7 +60,7 @@ private constructor( private var service: ProviderServiceAsync? = null private var streamHandlerExecutor: Executor? = null private var params: ProviderListParams? = null - private var items: List? = null + private var items: List? = null @JvmSynthetic internal fun from(providerListPageAsync: ProviderListPageAsync) = apply { @@ -79,7 +80,7 @@ private constructor( fun params(params: ProviderListParams) = apply { this.params = params } /** The response that this page was parsed from. */ - fun items(items: List) = apply { this.items = items } + fun items(items: List) = apply { this.items = items } /** * Returns an immutable instance of [ProviderListPageAsync]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListResponse.kt new file mode 100644 index 00000000..927404e6 --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListResponse.kt @@ -0,0 +1,1195 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.tryfinch.api.core.Enum +import com.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.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 +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ProviderListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val displayName: JsonField, + private val products: JsonField>, + private val authenticationMethods: JsonField>, + private val beta: JsonField, + private val icon: JsonField, + private val logo: JsonField, + private val manual: JsonField, + private val mfaRequired: JsonField, + private val primaryColor: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), + @JsonProperty("products") + @ExcludeMissing + products: JsonField> = JsonMissing.of(), + @JsonProperty("authentication_methods") + @ExcludeMissing + authenticationMethods: JsonField> = JsonMissing.of(), + @JsonProperty("beta") @ExcludeMissing beta: JsonField = JsonMissing.of(), + @JsonProperty("icon") @ExcludeMissing icon: JsonField = JsonMissing.of(), + @JsonProperty("logo") @ExcludeMissing logo: JsonField = JsonMissing.of(), + @JsonProperty("manual") @ExcludeMissing manual: JsonField = JsonMissing.of(), + @JsonProperty("mfa_required") + @ExcludeMissing + mfaRequired: JsonField = JsonMissing.of(), + @JsonProperty("primary_color") + @ExcludeMissing + primaryColor: JsonField = JsonMissing.of(), + ) : this( + id, + displayName, + products, + authenticationMethods, + beta, + icon, + logo, + manual, + mfaRequired, + primaryColor, + mutableMapOf(), + ) + + /** + * The id of the payroll provider used in Connect. + * + * @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") + + /** + * The display name of the payroll provider. + * + * @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 displayName(): String = displayName.getRequired("display_name") + + /** + * The list of Finch products supported on this payroll provider. + * + * @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 products(): List = products.getRequired("products") + + /** + * The authentication methods supported by the provider. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun authenticationMethods(): Optional> = + authenticationMethods.getOptional("authentication_methods") + + /** + * `true` if the integration is in a beta state, `false` otherwise + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun beta(): Optional = beta.getOptional("beta") + + /** + * The url to the official icon of the payroll provider. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun icon(): Optional = icon.getOptional("icon") + + /** + * The url to the official logo of the payroll provider. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun logo(): Optional = logo.getOptional("logo") + + /** + * [DEPRECATED] Whether the Finch integration with this provider uses the Assisted Connect Flow + * by default. This field is now deprecated. Please check for a `type` of `assisted` in the + * `authentication_methods` field instead. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun manual(): Optional = manual.getOptional("manual") + + /** + * whether MFA is required for the provider. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mfaRequired(): Optional = mfaRequired.getOptional("mfa_required") + + /** + * The hex code for the primary color of the payroll provider. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun primaryColor(): Optional = primaryColor.getOptional("primary_color") + + /** + * 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 + + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + + /** + * Returns the raw JSON value of [products]. + * + * Unlike [products], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("products") @ExcludeMissing fun _products(): JsonField> = products + + /** + * Returns the raw JSON value of [authenticationMethods]. + * + * Unlike [authenticationMethods], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authentication_methods") + @ExcludeMissing + fun _authenticationMethods(): JsonField> = authenticationMethods + + /** + * Returns the raw JSON value of [beta]. + * + * Unlike [beta], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("beta") @ExcludeMissing fun _beta(): JsonField = beta + + /** + * Returns the raw JSON value of [icon]. + * + * Unlike [icon], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("icon") @ExcludeMissing fun _icon(): JsonField = icon + + /** + * Returns the raw JSON value of [logo]. + * + * Unlike [logo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logo") @ExcludeMissing fun _logo(): JsonField = logo + + /** + * Returns the raw JSON value of [manual]. + * + * Unlike [manual], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("manual") + @ExcludeMissing + fun _manual(): JsonField = manual + + /** + * Returns the raw JSON value of [mfaRequired]. + * + * Unlike [mfaRequired], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mfa_required") + @ExcludeMissing + fun _mfaRequired(): JsonField = mfaRequired + + /** + * Returns the raw JSON value of [primaryColor]. + * + * Unlike [primaryColor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("primary_color") + @ExcludeMissing + fun _primaryColor(): JsonField = primaryColor + + @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 [ProviderListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .displayName() + * .products() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProviderListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var displayName: JsonField? = null + private var products: JsonField>? = null + private var authenticationMethods: JsonField>? = null + private var beta: JsonField = JsonMissing.of() + private var icon: JsonField = JsonMissing.of() + private var logo: JsonField = JsonMissing.of() + private var manual: JsonField = JsonMissing.of() + private var mfaRequired: JsonField = JsonMissing.of() + private var primaryColor: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(providerListResponse: ProviderListResponse) = apply { + id = providerListResponse.id + displayName = providerListResponse.displayName + products = providerListResponse.products.map { it.toMutableList() } + authenticationMethods = + providerListResponse.authenticationMethods.map { it.toMutableList() } + beta = providerListResponse.beta + icon = providerListResponse.icon + logo = providerListResponse.logo + manual = providerListResponse.manual + mfaRequired = providerListResponse.mfaRequired + primaryColor = providerListResponse.primaryColor + additionalProperties = providerListResponse.additionalProperties.toMutableMap() + } + + /** The id of the payroll provider used in Connect. */ + 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 } + + /** The display name of the payroll provider. */ + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField) = apply { this.displayName = displayName } + + /** The list of Finch products supported on this payroll provider. */ + fun products(products: List) = products(JsonField.of(products)) + + /** + * Sets [Builder.products] to an arbitrary JSON value. + * + * You should usually call [Builder.products] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [products]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addProduct(product: String) = apply { + products = + (products ?: JsonField.of(mutableListOf())).also { + checkKnown("products", it).add(product) + } + } + + /** The authentication methods supported by the provider. */ + fun authenticationMethods(authenticationMethods: List) = + authenticationMethods(JsonField.of(authenticationMethods)) + + /** + * Sets [Builder.authenticationMethods] to an arbitrary JSON value. + * + * You should usually call [Builder.authenticationMethods] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun authenticationMethods(authenticationMethods: JsonField>) = + apply { + this.authenticationMethods = authenticationMethods.map { it.toMutableList() } + } + + /** + * Adds a single [AuthenticationMethod] to [authenticationMethods]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAuthenticationMethod(authenticationMethod: AuthenticationMethod) = apply { + authenticationMethods = + (authenticationMethods ?: JsonField.of(mutableListOf())).also { + checkKnown("authenticationMethods", it).add(authenticationMethod) + } + } + + /** `true` if the integration is in a beta state, `false` otherwise */ + fun beta(beta: Boolean) = beta(JsonField.of(beta)) + + /** + * Sets [Builder.beta] to an arbitrary JSON value. + * + * You should usually call [Builder.beta] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun beta(beta: JsonField) = apply { this.beta = beta } + + /** The url to the official icon of the payroll provider. */ + fun icon(icon: String) = icon(JsonField.of(icon)) + + /** + * Sets [Builder.icon] to an arbitrary JSON value. + * + * You should usually call [Builder.icon] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun icon(icon: JsonField) = apply { this.icon = icon } + + /** The url to the official logo of the payroll provider. */ + fun logo(logo: String) = logo(JsonField.of(logo)) + + /** + * Sets [Builder.logo] to an arbitrary JSON value. + * + * You should usually call [Builder.logo] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun logo(logo: JsonField) = apply { this.logo = logo } + + /** + * [DEPRECATED] Whether the Finch integration with this provider uses the Assisted Connect + * Flow by default. This field is now deprecated. Please check for a `type` of `assisted` in + * the `authentication_methods` field instead. + */ + @Deprecated("deprecated") fun manual(manual: Boolean) = manual(JsonField.of(manual)) + + /** + * Sets [Builder.manual] to an arbitrary JSON value. + * + * You should usually call [Builder.manual] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun manual(manual: JsonField) = apply { this.manual = manual } + + /** whether MFA is required for the provider. */ + fun mfaRequired(mfaRequired: Boolean) = mfaRequired(JsonField.of(mfaRequired)) + + /** + * Sets [Builder.mfaRequired] to an arbitrary JSON value. + * + * You should usually call [Builder.mfaRequired] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun mfaRequired(mfaRequired: JsonField) = apply { this.mfaRequired = mfaRequired } + + /** The hex code for the primary color of the payroll provider. */ + fun primaryColor(primaryColor: String) = primaryColor(JsonField.of(primaryColor)) + + /** + * Sets [Builder.primaryColor] to an arbitrary JSON value. + * + * You should usually call [Builder.primaryColor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun primaryColor(primaryColor: JsonField) = apply { + this.primaryColor = primaryColor + } + + 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 [ProviderListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .displayName() + * .products() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProviderListResponse = + ProviderListResponse( + checkRequired("id", id), + checkRequired("displayName", displayName), + checkRequired("products", products).map { it.toImmutable() }, + (authenticationMethods ?: JsonMissing.of()).map { it.toImmutable() }, + beta, + icon, + logo, + manual, + mfaRequired, + primaryColor, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ProviderListResponse = apply { + if (validated) { + return@apply + } + + id() + displayName() + products() + authenticationMethods().ifPresent { it.forEach { it.validate() } } + beta() + icon() + logo() + manual() + mfaRequired() + primaryColor() + 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 (id.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + + (products.asKnown().getOrNull()?.size ?: 0) + + (authenticationMethods.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (beta.asKnown().isPresent) 1 else 0) + + (if (icon.asKnown().isPresent) 1 else 0) + + (if (logo.asKnown().isPresent) 1 else 0) + + (if (manual.asKnown().isPresent) 1 else 0) + + (if (mfaRequired.asKnown().isPresent) 1 else 0) + + (if (primaryColor.asKnown().isPresent) 1 else 0) + + class AuthenticationMethod + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonField, + private val benefitsSupport: JsonField, + private val supportedFields: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("benefits_support") + @ExcludeMissing + benefitsSupport: JsonField = JsonMissing.of(), + @JsonProperty("supported_fields") + @ExcludeMissing + supportedFields: JsonField = JsonMissing.of(), + ) : this(type, benefitsSupport, supportedFields, mutableMapOf()) + + /** + * The type of authentication 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). + */ + fun type(): Type = type.getRequired("type") + + /** + * The supported benefit types and their configurations + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun benefitsSupport(): Optional = + benefitsSupport.getOptional("benefits_support") + + /** + * The supported fields for each Finch product + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun supportedFields(): Optional = + supportedFields.getOptional("supported_fields") + + /** + * 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 + + /** + * Returns the raw JSON value of [benefitsSupport]. + * + * Unlike [benefitsSupport], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("benefits_support") + @ExcludeMissing + fun _benefitsSupport(): JsonField = benefitsSupport + + /** + * Returns the raw JSON value of [supportedFields]. + * + * Unlike [supportedFields], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("supported_fields") + @ExcludeMissing + fun _supportedFields(): JsonField = supportedFields + + @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 [AuthenticationMethod]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AuthenticationMethod]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var benefitsSupport: JsonField = JsonMissing.of() + private var supportedFields: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authenticationMethod: AuthenticationMethod) = apply { + type = authenticationMethod.type + benefitsSupport = authenticationMethod.benefitsSupport + supportedFields = authenticationMethod.supportedFields + additionalProperties = authenticationMethod.additionalProperties.toMutableMap() + } + + /** The type of authentication method */ + 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 } + + /** The supported benefit types and their configurations */ + fun benefitsSupport(benefitsSupport: BenefitsSupport) = + benefitsSupport(JsonField.of(benefitsSupport)) + + /** + * Sets [Builder.benefitsSupport] to an arbitrary JSON value. + * + * You should usually call [Builder.benefitsSupport] with a well-typed [BenefitsSupport] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun benefitsSupport(benefitsSupport: JsonField) = apply { + this.benefitsSupport = benefitsSupport + } + + /** The supported fields for each Finch product */ + fun supportedFields(supportedFields: SupportedFields) = + supportedFields(JsonField.of(supportedFields)) + + /** + * Sets [Builder.supportedFields] to an arbitrary JSON value. + * + * You should usually call [Builder.supportedFields] with a well-typed [SupportedFields] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun supportedFields(supportedFields: JsonField) = apply { + this.supportedFields = supportedFields + } + + 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 [AuthenticationMethod]. + * + * 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(): AuthenticationMethod = + AuthenticationMethod( + checkRequired("type", type), + benefitsSupport, + supportedFields, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AuthenticationMethod = apply { + if (validated) { + return@apply + } + + type().validate() + benefitsSupport().ifPresent { it.validate() } + supportedFields().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 = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (benefitsSupport.asKnown().getOrNull()?.validity() ?: 0) + + (supportedFields.asKnown().getOrNull()?.validity() ?: 0) + + /** The type of authentication method */ + 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 ASSISTED = of("assisted") + + @JvmField val CREDENTIAL = of("credential") + + @JvmField val API_TOKEN = of("api_token") + + @JvmField val API_CREDENTIAL = of("api_credential") + + @JvmField val OAUTH = of("oauth") + + @JvmField val API = of("api") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ASSISTED, + CREDENTIAL, + API_TOKEN, + API_CREDENTIAL, + OAUTH, + API, + } + + /** + * 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 { + ASSISTED, + CREDENTIAL, + API_TOKEN, + API_CREDENTIAL, + OAUTH, + API, + /** 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) { + ASSISTED -> Value.ASSISTED + CREDENTIAL -> Value.CREDENTIAL + API_TOKEN -> Value.API_TOKEN + API_CREDENTIAL -> Value.API_CREDENTIAL + OAUTH -> Value.OAUTH + API -> Value.API + 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) { + ASSISTED -> Known.ASSISTED + CREDENTIAL -> Known.CREDENTIAL + API_TOKEN -> Known.API_TOKEN + API_CREDENTIAL -> Known.API_CREDENTIAL + OAUTH -> Known.OAUTH + API -> Known.API + 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 other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The supported benefit types and their configurations */ + class BenefitsSupport + @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 [BenefitsSupport]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BenefitsSupport]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(benefitsSupport: BenefitsSupport) = apply { + additionalProperties = benefitsSupport.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 [BenefitsSupport]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BenefitsSupport = BenefitsSupport(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): BenefitsSupport = 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 other is BenefitsSupport && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "BenefitsSupport{additionalProperties=$additionalProperties}" + } + + /** The supported fields for each Finch product */ + class SupportedFields + @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 [SupportedFields]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SupportedFields]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(supportedFields: SupportedFields) = apply { + additionalProperties = supportedFields.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 [SupportedFields]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SupportedFields = SupportedFields(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): SupportedFields = 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 other is SupportedFields && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SupportedFields{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthenticationMethod && + type == other.type && + benefitsSupport == other.benefitsSupport && + supportedFields == other.supportedFields && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, benefitsSupport, supportedFields, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AuthenticationMethod{type=$type, benefitsSupport=$benefitsSupport, supportedFields=$supportedFields, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderListResponse && + id == other.id && + displayName == other.displayName && + products == other.products && + authenticationMethods == other.authenticationMethods && + beta == other.beta && + icon == other.icon && + logo == other.logo && + manual == other.manual && + mfaRequired == other.mfaRequired && + primaryColor == other.primaryColor && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + displayName, + products, + authenticationMethods, + beta, + icon, + logo, + manual, + mfaRequired, + primaryColor, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProviderListResponse{id=$id, displayName=$displayName, products=$products, authenticationMethods=$authenticationMethods, beta=$beta, icon=$icon, logo=$logo, manual=$manual, mfaRequired=$mfaRequired, primaryColor=$primaryColor, additionalProperties=$additionalProperties}" +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardParams.kt index 9b283b05..529fd7fa 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardParams.kt @@ -14,6 +14,7 @@ import com.tryfinch.api.core.Params import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams +import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects @@ -27,7 +28,7 @@ import kotlin.jvm.optionals.getOrNull */ class RequestForwardingForwardParams private constructor( - private val body: Body, + private val body: ForwardRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -63,14 +64,20 @@ private constructor( * The HTTP headers to include on the forwarded request. This value must be specified as an * object of key-value pairs. Example: `{"Content-Type": "application/xml", "X-API-Version": * "v1" }` + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun _headers_(): JsonValue = body._headers_() + fun headers(): Optional = body.headers() /** * The query parameters for the forwarded request. This value must be specified as a valid JSON * object rather than a query string. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun _params(): JsonValue = body._params() + fun params(): Optional = body.params() /** * Returns the raw JSON value of [method]. @@ -93,6 +100,20 @@ private constructor( */ fun _data(): JsonField = body._data() + /** + * Returns the raw JSON value of [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _headers_(): JsonField = body._headers_() + + /** + * Returns the raw JSON value of [params]. + * + * Unlike [params], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _params(): JsonField = body._params() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -121,7 +142,7 @@ private constructor( /** A builder for [RequestForwardingForwardParams]. */ class Builder internal constructor() { - private var body: Body.Builder = Body.builder() + private var body: ForwardRequest.Builder = ForwardRequest.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -144,7 +165,7 @@ private constructor( * - [params] * - etc. */ - fun body(body: Body) = apply { this.body = body.toBuilder() } + fun body(body: ForwardRequest) = apply { this.body = body.toBuilder() } /** * The HTTP method for the forwarded request. Valid values include: `GET` , `POST` , `PUT` , @@ -196,13 +217,35 @@ private constructor( * object of key-value pairs. Example: `{"Content-Type": "application/xml", "X-API-Version": * "v1" }` */ - fun headers(headers: JsonValue) = apply { body.headers(headers) } + fun headers(headers: Headers?) = apply { body.headers(headers) } + + /** Alias for calling [Builder.headers] with `headers.orElse(null)`. */ + fun headers(headers: Optional) = headers(headers.getOrNull()) + + /** + * Sets [Builder.headers] to an arbitrary JSON value. + * + * You should usually call [Builder.headers] with a well-typed [Headers] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun headers(headers: JsonField) = apply { body.headers(headers) } /** * The query parameters for the forwarded request. This value must be specified as a valid * JSON object rather than a query string. */ - fun params(params: JsonValue) = apply { body.params(params) } + fun params(params: Params?) = apply { body.params(params) } + + /** Alias for calling [Builder.params] with `params.orElse(null)`. */ + fun params(params: Optional) = params(params.getOrNull()) + + /** + * Sets [Builder.params] to an arbitrary JSON value. + * + * You should usually call [Builder.params] with a well-typed [Params] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun params(params: JsonField) = apply { body.params(params) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) @@ -342,20 +385,20 @@ private constructor( ) } - fun _body(): Body = body + fun _body(): ForwardRequest = body override fun _headers(): Headers = additionalHeaders override fun _queryParams(): QueryParams = additionalQueryParams - /** Forward Request Body */ - class Body + class ForwardRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val method: JsonField, private val route: JsonField, private val data: JsonField, - private val headers: JsonValue, - private val params: JsonValue, + private val headers: JsonField, + private val params: JsonField, private val additionalProperties: MutableMap, ) { @@ -364,8 +407,8 @@ private constructor( @JsonProperty("method") @ExcludeMissing method: JsonField = JsonMissing.of(), @JsonProperty("route") @ExcludeMissing route: JsonField = JsonMissing.of(), @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("headers") @ExcludeMissing headers: JsonValue = JsonMissing.of(), - @JsonProperty("params") @ExcludeMissing params: JsonValue = JsonMissing.of(), + @JsonProperty("headers") @ExcludeMissing headers: JsonField = JsonMissing.of(), + @JsonProperty("params") @ExcludeMissing params: JsonField = JsonMissing.of(), ) : this(method, route, data, headers, params, mutableMapOf()) /** @@ -399,14 +442,20 @@ private constructor( * The HTTP headers to include on the forwarded request. This value must be specified as an * object of key-value pairs. Example: `{"Content-Type": "application/xml", "X-API-Version": * "v1" }` + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("headers") @ExcludeMissing fun _headers_(): JsonValue = headers + fun headers(): Optional = headers.getOptional("headers") /** * The query parameters for the forwarded request. This value must be specified as a valid * JSON object rather than a query string. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("params") @ExcludeMissing fun _params(): JsonValue = params + fun params(): Optional = params.getOptional("params") /** * Returns the raw JSON value of [method]. @@ -429,6 +478,20 @@ private constructor( */ @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + /** + * Returns the raw JSON value of [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("headers") @ExcludeMissing fun _headers_(): JsonField = headers + + /** + * Returns the raw JSON value of [params]. + * + * Unlike [params], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("params") @ExcludeMissing fun _params(): JsonField = params + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -444,7 +507,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [Body]. + * Returns a mutable builder for constructing an instance of [ForwardRequest]. * * The following fields are required: * ```java @@ -455,24 +518,24 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [Body]. */ + /** A builder for [ForwardRequest]. */ class Builder internal constructor() { private var method: JsonField? = null private var route: JsonField? = null private var data: JsonField = JsonMissing.of() - private var headers: JsonValue = JsonMissing.of() - private var params: JsonValue = JsonMissing.of() + private var headers: JsonField = JsonMissing.of() + private var params: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - method = body.method - route = body.route - data = body.data - headers = body.headers - params = body.params - additionalProperties = body.additionalProperties.toMutableMap() + internal fun from(forwardRequest: ForwardRequest) = apply { + method = forwardRequest.method + route = forwardRequest.route + data = forwardRequest.data + headers = forwardRequest.headers + params = forwardRequest.params + additionalProperties = forwardRequest.additionalProperties.toMutableMap() } /** @@ -529,13 +592,37 @@ private constructor( * an object of key-value pairs. Example: `{"Content-Type": "application/xml", * "X-API-Version": "v1" }` */ - fun headers(headers: JsonValue) = apply { this.headers = headers } + fun headers(headers: Headers?) = headers(JsonField.ofNullable(headers)) + + /** Alias for calling [Builder.headers] with `headers.orElse(null)`. */ + fun headers(headers: Optional) = headers(headers.getOrNull()) + + /** + * Sets [Builder.headers] to an arbitrary JSON value. + * + * You should usually call [Builder.headers] with a well-typed [Headers] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun headers(headers: JsonField) = apply { this.headers = headers } /** * The query parameters for the forwarded request. This value must be specified as a * valid JSON object rather than a query string. */ - fun params(params: JsonValue) = apply { this.params = params } + fun params(params: Params?) = params(JsonField.ofNullable(params)) + + /** Alias for calling [Builder.params] with `params.orElse(null)`. */ + fun params(params: Optional) = params(params.getOrNull()) + + /** + * Sets [Builder.params] to an arbitrary JSON value. + * + * You should usually call [Builder.params] with a well-typed [Params] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun params(params: JsonField) = apply { this.params = params } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -557,7 +644,7 @@ private constructor( } /** - * Returns an immutable instance of [Body]. + * Returns an immutable instance of [ForwardRequest]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -569,8 +656,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): Body = - Body( + fun build(): ForwardRequest = + ForwardRequest( checkRequired("method", method), checkRequired("route", route), data, @@ -582,7 +669,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { + fun validate(): ForwardRequest = apply { if (validated) { return@apply } @@ -590,6 +677,8 @@ private constructor( method() route() data() + headers().ifPresent { it.validate() } + params().ifPresent { it.validate() } validated = true } @@ -611,14 +700,16 @@ private constructor( internal fun validity(): Int = (if (method.asKnown().isPresent) 1 else 0) + (if (route.asKnown().isPresent) 1 else 0) + - (if (data.asKnown().isPresent) 1 else 0) + (if (data.asKnown().isPresent) 1 else 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) + + (params.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Body && + return other is ForwardRequest && method == other.method && route == other.route && data == other.data && @@ -634,7 +725,214 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{method=$method, route=$route, data=$data, headers=$headers, params=$params, additionalProperties=$additionalProperties}" + "ForwardRequest{method=$method, route=$route, data=$data, headers=$headers, params=$params, additionalProperties=$additionalProperties}" + } + + /** + * The HTTP headers to include on the forwarded request. This value must be specified as an + * object of key-value pairs. Example: `{"Content-Type": "application/xml", "X-API-Version": + * "v1" }` + */ + class Headers + @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 [Headers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.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 [Headers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Headers = 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 other is Headers && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Headers{additionalProperties=$additionalProperties}" + } + + /** + * The query parameters for the forwarded request. This value must be specified as a valid JSON + * object rather than a query string. + */ + class Params + @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 [Params]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Params]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(params: Params) = apply { + additionalProperties = params.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 [Params]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Params = Params(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Params = 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 other is Params && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Params{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardResponse.kt index 3ba2bef7..be52c8a9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardResponse.kt @@ -6,11 +6,23 @@ 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.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.checkRequired +import com.tryfinch.api.core.getOrThrow +import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects @@ -18,37 +30,22 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class RequestForwardingForwardResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val data: JsonField, - private val headers: JsonValue, private val request: JsonField, private val statusCode: JsonField, + private val data: JsonField, + private val headers: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("headers") @ExcludeMissing headers: JsonValue = JsonMissing.of(), @JsonProperty("request") @ExcludeMissing request: JsonField = JsonMissing.of(), @JsonProperty("statusCode") @ExcludeMissing statusCode: JsonField = JsonMissing.of(), - ) : this(data, headers, request, statusCode, mutableMapOf()) - - /** - * A string representation of the HTTP response body of the forwarded request's response - * received from the underlying integration's API. This field may be null in the case where the - * upstream system's response is empty. - * - * @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") - - /** - * The HTTP headers of the forwarded request's response, exactly as received from the underlying - * integration's API. - */ - @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonValue = headers + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("headers") @ExcludeMissing headers: JsonField = JsonMissing.of(), + ) : this(request, statusCode, data, headers, mutableMapOf()) /** * An object containing details of your original forwarded request, for your ease of reference. @@ -68,11 +65,23 @@ private constructor( fun statusCode(): Long = statusCode.getRequired("statusCode") /** - * Returns the raw JSON value of [data]. + * A string representation of the HTTP response body of the forwarded request's response + * received from the underlying integration's API. This field may be null in the case where the + * upstream system's response is empty. * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + fun data(): Optional = data.getOptional("data") + + /** + * The HTTP headers of the forwarded request's response, exactly as received from the underlying + * integration's API. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun headers(): Optional = headers.getOptional("headers") /** * Returns the raw JSON value of [request]. @@ -88,6 +97,20 @@ private constructor( */ @JsonProperty("statusCode") @ExcludeMissing fun _statusCode(): JsonField = statusCode + /** + * 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 [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -108,8 +131,6 @@ private constructor( * * The following fields are required: * ```java - * .data() - * .headers() * .request() * .statusCode() * ``` @@ -120,23 +141,51 @@ private constructor( /** A builder for [RequestForwardingForwardResponse]. */ class Builder internal constructor() { - private var data: JsonField? = null - private var headers: JsonValue? = null private var request: JsonField? = null private var statusCode: JsonField? = null + private var data: JsonField = JsonMissing.of() + private var headers: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(requestForwardingForwardResponse: RequestForwardingForwardResponse) = apply { - data = requestForwardingForwardResponse.data - headers = requestForwardingForwardResponse.headers request = requestForwardingForwardResponse.request statusCode = requestForwardingForwardResponse.statusCode + data = requestForwardingForwardResponse.data + headers = requestForwardingForwardResponse.headers additionalProperties = requestForwardingForwardResponse.additionalProperties.toMutableMap() } + /** + * An object containing details of your original forwarded request, for your ease of + * reference. + */ + fun request(request: Request) = request(JsonField.of(request)) + + /** + * Sets [Builder.request] to an arbitrary JSON value. + * + * You should usually call [Builder.request] with a well-typed [Request] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun request(request: JsonField) = apply { this.request = request } + + /** + * The HTTP status code of the forwarded request's response, exactly received from the + * underlying integration's API. This value will be returned as an integer. + */ + fun statusCode(statusCode: Long) = statusCode(JsonField.of(statusCode)) + + /** + * Sets [Builder.statusCode] to an arbitrary JSON value. + * + * You should usually call [Builder.statusCode] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun statusCode(statusCode: JsonField) = apply { this.statusCode = statusCode } + /** * A string representation of the HTTP response body of the forwarded request's response * received from the underlying integration's API. This field may be null in the case where @@ -159,35 +208,18 @@ private constructor( * The HTTP headers of the forwarded request's response, exactly as received from the * underlying integration's API. */ - fun headers(headers: JsonValue) = apply { this.headers = headers } + fun headers(headers: Headers?) = headers(JsonField.ofNullable(headers)) - /** - * An object containing details of your original forwarded request, for your ease of - * reference. - */ - fun request(request: Request) = request(JsonField.of(request)) + /** Alias for calling [Builder.headers] with `headers.orElse(null)`. */ + fun headers(headers: Optional) = headers(headers.getOrNull()) /** - * Sets [Builder.request] to an arbitrary JSON value. + * Sets [Builder.headers] to an arbitrary JSON value. * - * You should usually call [Builder.request] with a well-typed [Request] value instead. This + * You should usually call [Builder.headers] with a well-typed [Headers] value instead. This * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun request(request: JsonField) = apply { this.request = request } - - /** - * The HTTP status code of the forwarded request's response, exactly received from the - * underlying integration's API. This value will be returned as an integer. - */ - fun statusCode(statusCode: Long) = statusCode(JsonField.of(statusCode)) - - /** - * Sets [Builder.statusCode] to an arbitrary JSON value. - * - * You should usually call [Builder.statusCode] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun statusCode(statusCode: JsonField) = apply { this.statusCode = statusCode } + fun headers(headers: JsonField) = apply { this.headers = headers } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -215,8 +247,6 @@ private constructor( * * The following fields are required: * ```java - * .data() - * .headers() * .request() * .statusCode() * ``` @@ -225,10 +255,10 @@ private constructor( */ fun build(): RequestForwardingForwardResponse = RequestForwardingForwardResponse( - checkRequired("data", data), - checkRequired("headers", headers), checkRequired("request", request), checkRequired("statusCode", statusCode), + data, + headers, additionalProperties.toMutableMap(), ) } @@ -240,9 +270,10 @@ private constructor( return@apply } - data() request().validate() statusCode() + data() + headers().ifPresent { it.validate() } validated = true } @@ -261,47 +292,33 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (data.asKnown().isPresent) 1 else 0) + - (request.asKnown().getOrNull()?.validity() ?: 0) + - (if (statusCode.asKnown().isPresent) 1 else 0) + (request.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusCode.asKnown().isPresent) 1 else 0) + + (if (data.asKnown().isPresent) 1 else 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) /** * An object containing details of your original forwarded request, for your ease of reference. */ class Request + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val data: JsonField, - private val headers: JsonValue, private val method: JsonField, - private val params: JsonValue, private val route: JsonField, + private val data: JsonField, + private val headers: JsonField, + private val params: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("headers") @ExcludeMissing headers: JsonValue = JsonMissing.of(), @JsonProperty("method") @ExcludeMissing method: JsonField = JsonMissing.of(), - @JsonProperty("params") @ExcludeMissing params: JsonValue = JsonMissing.of(), @JsonProperty("route") @ExcludeMissing route: JsonField = JsonMissing.of(), - ) : this(data, headers, method, params, route, mutableMapOf()) - - /** - * The body that was specified for the forwarded request. If a value was not specified in - * the original request, this value will be returned as null ; otherwise, this value will - * always be returned as a string. - * - * @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") - - /** - * The specified HTTP headers that were included in the forwarded request. If no headers - * were specified, this will be returned as `null`. - */ - @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonValue = headers + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("headers") @ExcludeMissing headers: JsonField = JsonMissing.of(), + @JsonProperty("params") @ExcludeMissing params: JsonField = JsonMissing.of(), + ) : this(method, route, data, headers, params, mutableMapOf()) /** * The HTTP method that was specified for the forwarded request. Valid values include: `GET` @@ -312,12 +329,6 @@ private constructor( */ fun method(): String = method.getRequired("method") - /** - * The query parameters that were included in the forwarded request. If no query parameters - * were specified, this will be returned as `null`. - */ - @JsonProperty("params") @ExcludeMissing fun _params(): JsonValue = params - /** * The URL route path that was specified for the forwarded request. * @@ -327,11 +338,28 @@ private constructor( fun route(): String = route.getRequired("route") /** - * Returns the raw JSON value of [data]. + * The body that was specified for the forwarded request. * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + fun data(): Optional = data.getOptional("data") + + /** + * The HTTP headers that were specified for the forwarded request. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun headers(): Optional = headers.getOptional("headers") + + /** + * The query parameters that were specified for the forwarded request. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun params(): Optional = params.getOptional("params") /** * Returns the raw JSON value of [method]. @@ -347,6 +375,27 @@ private constructor( */ @JsonProperty("route") @ExcludeMissing fun _route(): JsonField = route + /** + * 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 [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers + + /** + * Returns the raw JSON value of [params]. + * + * Unlike [params], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("params") @ExcludeMissing fun _params(): JsonField = params + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -366,10 +415,7 @@ private constructor( * * The following fields are required: * ```java - * .data() - * .headers() * .method() - * .params() * .route() * ``` */ @@ -379,80 +425,100 @@ private constructor( /** A builder for [Request]. */ class Builder internal constructor() { - private var data: JsonField? = null - private var headers: JsonValue? = null private var method: JsonField? = null - private var params: JsonValue? = null private var route: JsonField? = null + private var data: JsonField = JsonMissing.of() + private var headers: JsonField = JsonMissing.of() + private var params: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(request: Request) = apply { + method = request.method + route = request.route data = request.data headers = request.headers - method = request.method params = request.params - route = request.route additionalProperties = request.additionalProperties.toMutableMap() } /** - * The body that was specified for the forwarded request. If a value was not specified - * in the original request, this value will be returned as null ; otherwise, this value - * will always be returned as a string. + * The HTTP method that was specified for the forwarded request. Valid values include: + * `GET` , `POST` , `PUT` , `DELETE` , and `PATCH`. */ - fun data(data: String?) = data(JsonField.ofNullable(data)) + fun method(method: String) = method(JsonField.of(method)) + + /** + * Sets [Builder.method] to an arbitrary JSON value. + * + * You should usually call [Builder.method] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun method(method: JsonField) = apply { this.method = method } + + /** The URL route path that was specified for the forwarded request. */ + fun route(route: String) = route(JsonField.of(route)) + + /** + * Sets [Builder.route] to an arbitrary JSON value. + * + * You should usually call [Builder.route] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun route(route: JsonField) = apply { this.route = route } + + /** The body that was specified for the forwarded request. */ + fun data(data: Data?) = data(JsonField.ofNullable(data)) /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) + 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 + * You should usually call [Builder.data] with a well-typed [Data] 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 data(data: JsonField) = apply { this.data = data } - /** - * The specified HTTP headers that were included in the forwarded request. If no headers - * were specified, this will be returned as `null`. - */ - fun headers(headers: JsonValue) = apply { this.headers = headers } + /** Alias for calling [data] with `Data.ofString(string)`. */ + fun data(string: String) = data(Data.ofString(string)) - /** - * The HTTP method that was specified for the forwarded request. Valid values include: - * `GET` , `POST` , `PUT` , `DELETE` , and `PATCH`. - */ - fun method(method: String) = method(JsonField.of(method)) + /** Alias for calling [data] with `Data.ofUnionMember1(unionMember1)`. */ + fun data(unionMember1: Data.UnionMember1) = data(Data.ofUnionMember1(unionMember1)) + + /** The HTTP headers that were specified for the forwarded request. */ + fun headers(headers: Headers?) = headers(JsonField.ofNullable(headers)) + + /** Alias for calling [Builder.headers] with `headers.orElse(null)`. */ + fun headers(headers: Optional) = headers(headers.getOrNull()) /** - * Sets [Builder.method] to an arbitrary JSON value. + * Sets [Builder.headers] to an arbitrary JSON value. * - * You should usually call [Builder.method] with a well-typed [String] value instead. + * You should usually call [Builder.headers] with a well-typed [Headers] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun method(method: JsonField) = apply { this.method = method } + fun headers(headers: JsonField) = apply { this.headers = headers } - /** - * The query parameters that were included in the forwarded request. If no query - * parameters were specified, this will be returned as `null`. - */ - fun params(params: JsonValue) = apply { this.params = params } + /** The query parameters that were specified for the forwarded request. */ + fun params(params: Params?) = params(JsonField.ofNullable(params)) - /** The URL route path that was specified for the forwarded request. */ - fun route(route: String) = route(JsonField.of(route)) + /** Alias for calling [Builder.params] with `params.orElse(null)`. */ + fun params(params: Optional) = params(params.getOrNull()) /** - * Sets [Builder.route] to an arbitrary JSON value. + * Sets [Builder.params] to an arbitrary JSON value. * - * You should usually call [Builder.route] with a well-typed [String] value instead. + * You should usually call [Builder.params] with a well-typed [Params] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun route(route: JsonField) = apply { this.route = route } + fun params(params: JsonField) = apply { this.params = params } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -480,10 +546,7 @@ private constructor( * * The following fields are required: * ```java - * .data() - * .headers() * .method() - * .params() * .route() * ``` * @@ -491,11 +554,11 @@ private constructor( */ fun build(): Request = Request( - checkRequired("data", data), - checkRequired("headers", headers), checkRequired("method", method), - checkRequired("params", params), checkRequired("route", route), + data, + headers, + params, additionalProperties.toMutableMap(), ) } @@ -507,9 +570,11 @@ private constructor( return@apply } - data() method() route() + data().ifPresent { it.validate() } + headers().ifPresent { it.validate() } + params().ifPresent { it.validate() } validated = true } @@ -529,9 +594,496 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (data.asKnown().isPresent) 1 else 0) + - (if (method.asKnown().isPresent) 1 else 0) + - (if (route.asKnown().isPresent) 1 else 0) + (if (method.asKnown().isPresent) 1 else 0) + + (if (route.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) + + (params.asKnown().getOrNull()?.validity() ?: 0) + + /** The body that was specified for the forwarded request. */ + @JsonDeserialize(using = Data.Deserializer::class) + @JsonSerialize(using = Data.Serializer::class) + class Data + private constructor( + private val string: String? = null, + private val unionMember1: UnionMember1? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun isString(): Boolean = string != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun asString(): String = string.getOrThrow("string") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.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 = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && string == other.string && unionMember1 == other.unionMember1 + } + + override fun hashCode(): Int = Objects.hash(string, unionMember1) + + override fun toString(): String = + when { + string != null -> "Data{string=$string}" + unionMember1 != null -> "Data{unionMember1=$unionMember1}" + _json != null -> "Data{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Data") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Data(string = string) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = Data(unionMember1 = unionMember1) + } + + /** + * An interface that defines how to map each variant of [Data] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + /** + * Maps an unknown variant of [Data] to a value of type [T]. + * + * An instance of [Data] 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 Data: $json") + } + } + + internal class Deserializer : BaseDeserializer(Data::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Data { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Data(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Data(string = 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 array). + 0 -> Data(_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(Data::class) { + + override fun serialize( + value: Data, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } + } + } + + class UnionMember1 + @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 [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + additionalProperties = unionMember1.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 [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = UnionMember1(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = 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 other is UnionMember1 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UnionMember1{additionalProperties=$additionalProperties}" + } + } + + /** The HTTP headers that were specified for the forwarded request. */ + class Headers + @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 [Headers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.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 [Headers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Headers = 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 other is Headers && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Headers{additionalProperties=$additionalProperties}" + } + + /** The query parameters that were specified for the forwarded request. */ + class Params + @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 [Params]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Params]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(params: Params) = apply { + additionalProperties = params.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 [Params]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Params = Params(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Params = 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 other is Params && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Params{additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -539,22 +1091,125 @@ private constructor( } return other is Request && + method == other.method && + route == other.route && data == other.data && headers == other.headers && - method == other.method && params == other.params && - route == other.route && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(data, headers, method, params, route, additionalProperties) + Objects.hash(method, route, data, headers, params, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Request{data=$data, headers=$headers, method=$method, params=$params, route=$route, additionalProperties=$additionalProperties}" + "Request{method=$method, route=$route, data=$data, headers=$headers, params=$params, additionalProperties=$additionalProperties}" + } + + /** + * The HTTP headers of the forwarded request's response, exactly as received from the underlying + * integration's API. + */ + class Headers + @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 [Headers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.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 [Headers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Headers = 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 other is Headers && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Headers{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -563,19 +1218,19 @@ private constructor( } return other is RequestForwardingForwardResponse && - data == other.data && - headers == other.headers && request == other.request && statusCode == other.statusCode && + data == other.data && + headers == other.headers && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(data, headers, request, statusCode, additionalProperties) + Objects.hash(request, statusCode, data, headers, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "RequestForwardingForwardResponse{data=$data, headers=$headers, request=$request, statusCode=$statusCode, additionalProperties=$additionalProperties}" + "RequestForwardingForwardResponse{request=$request, statusCode=$statusCode, data=$data, headers=$headers, additionalProperties=$additionalProperties}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleCreateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleCreateResponse.kt index 63d2b949..c4eb0bbd 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleCreateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleCreateResponse.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class RuleCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val attributes: JsonField, @@ -488,6 +489,7 @@ private constructor( /** Specifies the fields to be applied when the condition is met. */ class Attributes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val metadata: JsonField, private val additionalProperties: MutableMap, @@ -741,6 +743,7 @@ private constructor( } class Condition + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val field: JsonField, private val operator: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleDeleteResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleDeleteResponse.kt index 65c5bef8..70cb5d14 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleDeleteResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleDeleteResponse.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class RuleDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val attributes: JsonField, @@ -527,6 +528,7 @@ private constructor( /** Specifies the fields to be applied when the condition is met. */ class Attributes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val metadata: JsonField, private val additionalProperties: MutableMap, @@ -780,6 +782,7 @@ private constructor( } class Condition + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val field: JsonField, private val operator: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleListResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleListResponse.kt index af31eea7..c9996f2f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleListResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleListResponse.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class RuleListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val attributes: JsonField, @@ -488,6 +489,7 @@ private constructor( /** Specifies the fields to be applied when the condition is met. */ class Attributes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val metadata: JsonField, private val additionalProperties: MutableMap, @@ -741,6 +743,7 @@ private constructor( } class Condition + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val field: JsonField, private val operator: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleUpdateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleUpdateResponse.kt index 25f91bf6..ad6615d1 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleUpdateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RuleUpdateResponse.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class RuleUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val attributes: JsonField, @@ -488,6 +489,7 @@ private constructor( /** Specifies the fields to be applied when the condition is met. */ class Attributes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val metadata: JsonField, private val additionalProperties: MutableMap, @@ -741,6 +743,7 @@ private constructor( } class Condition + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val field: JsonField, private val operator: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParams.kt index fd507a89..00f8cb0b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParams.kt @@ -513,6 +513,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class CompanyWithoutId + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accounts: JsonField>, private val departments: JsonField>, @@ -1059,6 +1060,7 @@ private constructor( } class Account + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val accountName: JsonField, private val accountNumber: JsonField, @@ -1552,6 +1554,7 @@ private constructor( } class Department + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val parent: JsonField, @@ -1716,6 +1719,7 @@ private constructor( /** The parent department, if present. */ class Parent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val additionalProperties: MutableMap, @@ -1882,6 +1886,7 @@ private constructor( /** The entity type object. */ class Entity + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val subtype: JsonField, private val type: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountCreateParams.kt index e7b78e6c..b6ba6114 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountCreateParams.kt @@ -348,6 +348,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val companyId: JsonField, private val providerId: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountUpdateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountUpdateParams.kt index f380d654..03817012 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountUpdateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountUpdateParams.kt @@ -243,6 +243,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val connectionStatus: JsonField, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionCreateParams.kt index 05e0ebdd..ebb96764 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionCreateParams.kt @@ -345,6 +345,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val providerId: JsonField, private val authenticationType: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParams.kt index 85d38ba1..237ef935 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParams.kt @@ -1375,6 +1375,7 @@ private constructor( (if (title.asKnown().isPresent) 1 else 0) class CustomField + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val value: JsonValue, @@ -1529,6 +1530,7 @@ private constructor( /** The department object. */ class Department + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val additionalProperties: MutableMap, @@ -1675,6 +1677,7 @@ private constructor( } class Email + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, private val type: JsonField, @@ -1982,6 +1985,7 @@ private constructor( /** The employment object. */ class Employment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val subtype: JsonField, private val type: JsonField, @@ -2944,6 +2948,7 @@ private constructor( /** The manager object representing the manager of the individual within the org. */ class Manager + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, @@ -3086,6 +3091,7 @@ private constructor( } class PhoneNumber + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, private val type: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParams.kt index 1adb5a13..e5d64459 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParams.kt @@ -812,6 +812,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class EmploymentWithoutId + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val classCode: JsonField, private val customFields: JsonField>, @@ -1755,6 +1756,7 @@ private constructor( } class CustomField + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val value: JsonValue, @@ -1905,6 +1907,7 @@ private constructor( /** The department object. */ class Department + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, private val additionalProperties: MutableMap, @@ -2049,6 +2052,7 @@ private constructor( /** The employment object. */ class Employment + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val subtype: JsonField, private val type: JsonField, @@ -2684,6 +2688,7 @@ private constructor( /** The manager object representing the manager of the individual within the org. */ class Manager + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParams.kt index 9c2d5143..276396de 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParams.kt @@ -613,6 +613,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class IndividualWithoutId + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val dob: JsonField, private val emails: JsonField>, @@ -1279,6 +1280,7 @@ private constructor( } class Email + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, private val type: JsonField, @@ -1879,6 +1881,7 @@ private constructor( } class PhoneNumber + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, private val type: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfiguration.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfiguration.kt index 3dc9a6ab..0488cedc 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfiguration.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfiguration.kt @@ -18,6 +18,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull class SandboxJobConfiguration +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val completionStatus: JsonField, private val type: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobCreateParams.kt index 47532a13..d36ad948 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobCreateParams.kt @@ -244,6 +244,7 @@ private constructor( override fun _queryParams(): QueryParams = additionalQueryParams class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val type: JsonField, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt index 62c92824..05b710f3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt @@ -307,6 +307,7 @@ private constructor( * are optional. */ class CreateSandboxPaymentRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val endDate: JsonField, private val payStatements: JsonField>, @@ -550,6 +551,7 @@ private constructor( } class PayStatement + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val individualId: JsonField, private val earnings: JsonField>, @@ -1084,6 +1086,7 @@ private constructor( (type.asKnown().getOrNull()?.validity() ?: 0) class Earning + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val hours: JsonField, @@ -1518,6 +1521,7 @@ private constructor( } class EmployeeDeduction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val name: JsonField, @@ -1998,6 +2002,7 @@ private constructor( } class EmployerContribution + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val name: JsonField, @@ -2576,6 +2581,7 @@ private constructor( } class Tax + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val employer: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionNewResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionNewResponse.kt index bd2bcdbe..474bd063 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionNewResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionNewResponse.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class SessionNewResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val connectUrl: JsonField, private val sessionId: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionReauthenticateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionReauthenticateResponse.kt index 060e9c11..98d56b70 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionReauthenticateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionReauthenticateResponse.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class SessionReauthenticateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val connectUrl: JsonField, private val sessionId: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportPerBenefitType.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportPerBenefitType.kt index e6f73fd3..d84b5fc5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportPerBenefitType.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportPerBenefitType.kt @@ -17,6 +17,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class SupportPerBenefitType +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val companyBenefits: JsonField, private val individualBenefits: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportedBenefit.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportedBenefit.kt index 92af6a43..a0cbb364 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportedBenefit.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportedBenefit.kt @@ -21,6 +21,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull class SupportedBenefit +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val annualMaximum: JsonField, private val companyContribution: JsonField>, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividualBenefitResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividualBenefitResponse.kt index dd8c3f24..fee505b4 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividualBenefitResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividualBenefitResponse.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class UnenrolledIndividualBenefitResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val jobId: JsonField, private val additionalProperties: MutableMap, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponse.kt index a1e68e89..3538aceb 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponse.kt @@ -16,6 +16,7 @@ import java.util.Collections import java.util.Objects class UpdateCompanyBenefitResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val benefitId: JsonField, private val jobId: JsonField, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42005.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42005.kt index f37045a6..4a7396c3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42005.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42005.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 @@ -22,6 +23,7 @@ import kotlin.jvm.optionals.getOrNull * dependents, and withholding details. */ class W42005 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, private val type: JsonField, @@ -39,26 +41,26 @@ private constructor( /** * Detailed information specific to the 2005 W4 form. * - * @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(): Data = data.getRequired("data") /** * Specifies the form type, indicating that this document is a 2005 W4 form. * - * @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 type(): Optional = type.getOptional("type") + fun type(): Type = type.getRequired("type") /** * The tax year this W4 document applies to. * - * @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 year(): Optional = year.getOptional("year") + fun year(): Double = year.getRequired("year") /** * Returns the raw JSON value of [data]. @@ -95,16 +97,25 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [W42005]. */ + /** + * Returns a mutable builder for constructing an instance of [W42005]. + * + * The following fields are required: + * ```java + * .data() + * .type() + * .year() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [W42005]. */ class Builder internal constructor() { - private var data: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() + private var data: JsonField? = null + private var type: JsonField? = null + private var year: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -138,17 +149,7 @@ private constructor( fun type(type: JsonField) = apply { this.type = type } /** The tax year this W4 document applies to. */ - fun year(year: Double?) = year(JsonField.ofNullable(year)) - - /** - * Alias for [Builder.year]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun year(year: Double) = year(year as Double?) - - /** Alias for calling [Builder.year] with `year.orElse(null)`. */ - fun year(year: Optional) = year(year.getOrNull()) + fun year(year: Double) = year(JsonField.of(year)) /** * Sets [Builder.year] to an arbitrary JSON value. @@ -181,8 +182,23 @@ private constructor( * Returns an immutable instance of [W42005]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .type() + * .year() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): W42005 = W42005(data, type, year, additionalProperties.toMutableMap()) + fun build(): W42005 = + W42005( + checkRequired("data", data), + checkRequired("type", type), + checkRequired("year", year), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -192,8 +208,8 @@ private constructor( return@apply } - data().ifPresent { it.validate() } - type().ifPresent { it.validate() } + data().validate() + type().validate() year() validated = true } @@ -219,6 +235,7 @@ private constructor( /** Detailed information specific to the 2005 W4 form. */ class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val additionalWithholding: JsonField, private val exemption: JsonField, @@ -257,11 +274,11 @@ private constructor( /** * Additional withholding amount (in cents). * - * @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 additionalWithholding(): Optional = - additionalWithholding.getOptional("additional_withholding") + fun additionalWithholding(): Long = + additionalWithholding.getRequired("additional_withholding") /** * Indicates exemption status from federal tax withholding. @@ -282,19 +299,19 @@ private constructor( /** * The unique identifier for the individual associated with this 2005 W4 form. * - * @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") /** * Total number of allowances claimed (in cents). * - * @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 totalNumberOfAllowances(): Optional = - totalNumberOfAllowances.getOptional("total_number_of_allowances") + fun totalNumberOfAllowances(): Long = + totalNumberOfAllowances.getRequired("total_number_of_allowances") /** * Returns the raw JSON value of [additionalWithholding]. @@ -359,18 +376,29 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Data]. */ + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .additionalWithholding() + * .exemption() + * .filingStatus() + * .individualId() + * .totalNumberOfAllowances() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Data]. */ class Builder internal constructor() { - private var additionalWithholding: JsonField = JsonMissing.of() - private var exemption: JsonField = JsonMissing.of() - private var filingStatus: JsonField = JsonMissing.of() - private var individualId: JsonField = JsonMissing.of() - private var totalNumberOfAllowances: JsonField = JsonMissing.of() + private var additionalWithholding: JsonField? = null + private var exemption: JsonField? = null + private var filingStatus: JsonField? = null + private var individualId: JsonField? = null + private var totalNumberOfAllowances: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -384,23 +412,8 @@ private constructor( } /** Additional withholding amount (in cents). */ - fun additionalWithholding(additionalWithholding: Long?) = - additionalWithholding(JsonField.ofNullable(additionalWithholding)) - - /** - * Alias for [Builder.additionalWithholding]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ fun additionalWithholding(additionalWithholding: Long) = - additionalWithholding(additionalWithholding as Long?) - - /** - * Alias for calling [Builder.additionalWithholding] with - * `additionalWithholding.orElse(null)`. - */ - fun additionalWithholding(additionalWithholding: Optional) = - additionalWithholding(additionalWithholding.getOrNull()) + additionalWithholding(JsonField.of(additionalWithholding)) /** * Sets [Builder.additionalWithholding] to an arbitrary JSON value. @@ -414,7 +427,10 @@ private constructor( } /** Indicates exemption status from federal tax withholding. */ - fun exemption(exemption: Exemption) = exemption(JsonField.of(exemption)) + fun exemption(exemption: Exemption?) = exemption(JsonField.ofNullable(exemption)) + + /** Alias for calling [Builder.exemption] with `exemption.orElse(null)`. */ + fun exemption(exemption: Optional) = exemption(exemption.getOrNull()) /** * Sets [Builder.exemption] to an arbitrary JSON value. @@ -459,23 +475,8 @@ private constructor( } /** Total number of allowances claimed (in cents). */ - fun totalNumberOfAllowances(totalNumberOfAllowances: Long?) = - totalNumberOfAllowances(JsonField.ofNullable(totalNumberOfAllowances)) - - /** - * Alias for [Builder.totalNumberOfAllowances]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ fun totalNumberOfAllowances(totalNumberOfAllowances: Long) = - totalNumberOfAllowances(totalNumberOfAllowances as Long?) - - /** - * Alias for calling [Builder.totalNumberOfAllowances] with - * `totalNumberOfAllowances.orElse(null)`. - */ - fun totalNumberOfAllowances(totalNumberOfAllowances: Optional) = - totalNumberOfAllowances(totalNumberOfAllowances.getOrNull()) + totalNumberOfAllowances(JsonField.of(totalNumberOfAllowances)) /** * Sets [Builder.totalNumberOfAllowances] to an arbitrary JSON value. @@ -511,14 +512,25 @@ private constructor( * Returns an immutable instance of [Data]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .additionalWithholding() + * .exemption() + * .filingStatus() + * .individualId() + * .totalNumberOfAllowances() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Data = Data( - additionalWithholding, - exemption, - filingStatus, - individualId, - totalNumberOfAllowances, + checkRequired("additionalWithholding", additionalWithholding), + checkRequired("exemption", exemption), + checkRequired("filingStatus", filingStatus), + checkRequired("individualId", individualId), + checkRequired("totalNumberOfAllowances", totalNumberOfAllowances), additionalProperties.toMutableMap(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42020.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42020.kt index 98aa80b7..038aadf0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42020.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42020.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 @@ -22,6 +23,7 @@ import kotlin.jvm.optionals.getOrNull * dependents, and withholding details. */ class W42020 +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField, private val type: JsonField, @@ -39,26 +41,26 @@ private constructor( /** * Detailed information specific to the 2020 W4 form. * - * @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(): Data = data.getRequired("data") /** * Specifies the form type, indicating that this document is a 2020 W4 form. * - * @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 type(): Optional = type.getOptional("type") + fun type(): Type = type.getRequired("type") /** * The tax year this W4 document applies to. * - * @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 year(): Optional = year.getOptional("year") + fun year(): Double = year.getRequired("year") /** * Returns the raw JSON value of [data]. @@ -95,16 +97,25 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [W42020]. */ + /** + * Returns a mutable builder for constructing an instance of [W42020]. + * + * The following fields are required: + * ```java + * .data() + * .type() + * .year() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [W42020]. */ class Builder internal constructor() { - private var data: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var year: JsonField = JsonMissing.of() + private var data: JsonField? = null + private var type: JsonField? = null + private var year: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -138,17 +149,7 @@ private constructor( fun type(type: JsonField) = apply { this.type = type } /** The tax year this W4 document applies to. */ - fun year(year: Double?) = year(JsonField.ofNullable(year)) - - /** - * Alias for [Builder.year]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun year(year: Double) = year(year as Double?) - - /** Alias for calling [Builder.year] with `year.orElse(null)`. */ - fun year(year: Optional) = year(year.getOrNull()) + fun year(year: Double) = year(JsonField.of(year)) /** * Sets [Builder.year] to an arbitrary JSON value. @@ -181,8 +182,23 @@ private constructor( * Returns an immutable instance of [W42020]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .type() + * .year() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): W42020 = W42020(data, type, year, additionalProperties.toMutableMap()) + fun build(): W42020 = + W42020( + checkRequired("data", data), + checkRequired("type", type), + checkRequired("year", year), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -192,8 +208,8 @@ private constructor( return@apply } - data().ifPresent { it.validate() } - type().ifPresent { it.validate() } + data().validate() + type().validate() year() validated = true } @@ -219,6 +235,7 @@ private constructor( /** Detailed information specific to the 2020 W4 form. */ class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amountForOtherDependents: JsonField, private val amountForQualifyingChildrenUnder17: JsonField, @@ -272,38 +289,38 @@ private constructor( /** * Amount claimed for dependents other than qualifying children under 17 (in cents). * - * @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 amountForOtherDependents(): Optional = - amountForOtherDependents.getOptional("amount_for_other_dependents") + fun amountForOtherDependents(): Long = + amountForOtherDependents.getRequired("amount_for_other_dependents") /** * Amount claimed for dependents under 17 years old (in cents). * - * @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 amountForQualifyingChildrenUnder17(): Optional = - amountForQualifyingChildrenUnder17.getOptional( + fun amountForQualifyingChildrenUnder17(): Long = + amountForQualifyingChildrenUnder17.getRequired( "amount_for_qualifying_children_under_17" ) /** * Deductible expenses (in cents). * - * @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 deductions(): Optional = deductions.getOptional("deductions") + fun deductions(): Long = deductions.getRequired("deductions") /** * Additional withholding amount (in cents). * - * @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 extraWithholding(): Optional = extraWithholding.getOptional("extra_withholding") + fun extraWithholding(): Long = extraWithholding.getRequired("extra_withholding") /** * The individual's filing status for tax purposes. @@ -316,27 +333,27 @@ private constructor( /** * The unique identifier for the individual associated with this document. * - * @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") /** * Additional income from sources outside of primary employment (in cents). * - * @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 otherIncome(): Optional = otherIncome.getOptional("other_income") + fun otherIncome(): Long = otherIncome.getRequired("other_income") /** * Total amount claimed for dependents and other credits (in cents). * - * @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 totalClaimDependentAndOtherCredits(): Optional = - totalClaimDependentAndOtherCredits.getOptional( + fun totalClaimDependentAndOtherCredits(): Long = + totalClaimDependentAndOtherCredits.getRequired( "total_claim_dependent_and_other_credits" ) @@ -432,21 +449,35 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Data]. */ + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .amountForOtherDependents() + * .amountForQualifyingChildrenUnder17() + * .deductions() + * .extraWithholding() + * .filingStatus() + * .individualId() + * .otherIncome() + * .totalClaimDependentAndOtherCredits() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Data]. */ class Builder internal constructor() { - private var amountForOtherDependents: JsonField = JsonMissing.of() - private var amountForQualifyingChildrenUnder17: JsonField = JsonMissing.of() - private var deductions: JsonField = JsonMissing.of() - private var extraWithholding: JsonField = JsonMissing.of() - private var filingStatus: JsonField = JsonMissing.of() - private var individualId: JsonField = JsonMissing.of() - private var otherIncome: JsonField = JsonMissing.of() - private var totalClaimDependentAndOtherCredits: JsonField = JsonMissing.of() + private var amountForOtherDependents: JsonField? = null + private var amountForQualifyingChildrenUnder17: JsonField? = null + private var deductions: JsonField? = null + private var extraWithholding: JsonField? = null + private var filingStatus: JsonField? = null + private var individualId: JsonField? = null + private var otherIncome: JsonField? = null + private var totalClaimDependentAndOtherCredits: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -463,23 +494,8 @@ private constructor( } /** Amount claimed for dependents other than qualifying children under 17 (in cents). */ - fun amountForOtherDependents(amountForOtherDependents: Long?) = - amountForOtherDependents(JsonField.ofNullable(amountForOtherDependents)) - - /** - * Alias for [Builder.amountForOtherDependents]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ fun amountForOtherDependents(amountForOtherDependents: Long) = - amountForOtherDependents(amountForOtherDependents as Long?) - - /** - * Alias for calling [Builder.amountForOtherDependents] with - * `amountForOtherDependents.orElse(null)`. - */ - fun amountForOtherDependents(amountForOtherDependents: Optional) = - amountForOtherDependents(amountForOtherDependents.getOrNull()) + amountForOtherDependents(JsonField.of(amountForOtherDependents)) /** * Sets [Builder.amountForOtherDependents] to an arbitrary JSON value. @@ -493,26 +509,8 @@ private constructor( } /** Amount claimed for dependents under 17 years old (in cents). */ - fun amountForQualifyingChildrenUnder17(amountForQualifyingChildrenUnder17: Long?) = - amountForQualifyingChildrenUnder17( - JsonField.ofNullable(amountForQualifyingChildrenUnder17) - ) - - /** - * Alias for [Builder.amountForQualifyingChildrenUnder17]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ fun amountForQualifyingChildrenUnder17(amountForQualifyingChildrenUnder17: Long) = - amountForQualifyingChildrenUnder17(amountForQualifyingChildrenUnder17 as Long?) - - /** - * Alias for calling [Builder.amountForQualifyingChildrenUnder17] with - * `amountForQualifyingChildrenUnder17.orElse(null)`. - */ - fun amountForQualifyingChildrenUnder17( - amountForQualifyingChildrenUnder17: Optional - ) = amountForQualifyingChildrenUnder17(amountForQualifyingChildrenUnder17.getOrNull()) + amountForQualifyingChildrenUnder17(JsonField.of(amountForQualifyingChildrenUnder17)) /** * Sets [Builder.amountForQualifyingChildrenUnder17] to an arbitrary JSON value. @@ -528,17 +526,7 @@ private constructor( } /** Deductible expenses (in cents). */ - fun deductions(deductions: Long?) = deductions(JsonField.ofNullable(deductions)) - - /** - * Alias for [Builder.deductions]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun deductions(deductions: Long) = deductions(deductions as Long?) - - /** Alias for calling [Builder.deductions] with `deductions.orElse(null)`. */ - fun deductions(deductions: Optional) = deductions(deductions.getOrNull()) + fun deductions(deductions: Long) = deductions(JsonField.of(deductions)) /** * Sets [Builder.deductions] to an arbitrary JSON value. @@ -550,22 +538,8 @@ private constructor( fun deductions(deductions: JsonField) = apply { this.deductions = deductions } /** Additional withholding amount (in cents). */ - fun extraWithholding(extraWithholding: Long?) = - extraWithholding(JsonField.ofNullable(extraWithholding)) - - /** - * Alias for [Builder.extraWithholding]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ fun extraWithholding(extraWithholding: Long) = - extraWithholding(extraWithholding as Long?) - - /** - * Alias for calling [Builder.extraWithholding] with `extraWithholding.orElse(null)`. - */ - fun extraWithholding(extraWithholding: Optional) = - extraWithholding(extraWithholding.getOrNull()) + extraWithholding(JsonField.of(extraWithholding)) /** * Sets [Builder.extraWithholding] to an arbitrary JSON value. @@ -612,17 +586,7 @@ private constructor( } /** Additional income from sources outside of primary employment (in cents). */ - fun otherIncome(otherIncome: Long?) = otherIncome(JsonField.ofNullable(otherIncome)) - - /** - * Alias for [Builder.otherIncome]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun otherIncome(otherIncome: Long) = otherIncome(otherIncome as Long?) - - /** Alias for calling [Builder.otherIncome] with `otherIncome.orElse(null)`. */ - fun otherIncome(otherIncome: Optional) = otherIncome(otherIncome.getOrNull()) + fun otherIncome(otherIncome: Long) = otherIncome(JsonField.of(otherIncome)) /** * Sets [Builder.otherIncome] to an arbitrary JSON value. @@ -634,26 +598,8 @@ private constructor( fun otherIncome(otherIncome: JsonField) = apply { this.otherIncome = otherIncome } /** Total amount claimed for dependents and other credits (in cents). */ - fun totalClaimDependentAndOtherCredits(totalClaimDependentAndOtherCredits: Long?) = - totalClaimDependentAndOtherCredits( - JsonField.ofNullable(totalClaimDependentAndOtherCredits) - ) - - /** - * Alias for [Builder.totalClaimDependentAndOtherCredits]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ fun totalClaimDependentAndOtherCredits(totalClaimDependentAndOtherCredits: Long) = - totalClaimDependentAndOtherCredits(totalClaimDependentAndOtherCredits as Long?) - - /** - * Alias for calling [Builder.totalClaimDependentAndOtherCredits] with - * `totalClaimDependentAndOtherCredits.orElse(null)`. - */ - fun totalClaimDependentAndOtherCredits( - totalClaimDependentAndOtherCredits: Optional - ) = totalClaimDependentAndOtherCredits(totalClaimDependentAndOtherCredits.getOrNull()) + totalClaimDependentAndOtherCredits(JsonField.of(totalClaimDependentAndOtherCredits)) /** * Sets [Builder.totalClaimDependentAndOtherCredits] to an arbitrary JSON value. @@ -691,17 +637,37 @@ private constructor( * Returns an immutable instance of [Data]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amountForOtherDependents() + * .amountForQualifyingChildrenUnder17() + * .deductions() + * .extraWithholding() + * .filingStatus() + * .individualId() + * .otherIncome() + * .totalClaimDependentAndOtherCredits() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Data = Data( - amountForOtherDependents, - amountForQualifyingChildrenUnder17, - deductions, - extraWithholding, - filingStatus, - individualId, - otherIncome, - totalClaimDependentAndOtherCredits, + checkRequired("amountForOtherDependents", amountForOtherDependents), + checkRequired( + "amountForQualifyingChildrenUnder17", + amountForQualifyingChildrenUnder17, + ), + checkRequired("deductions", deductions), + checkRequired("extraWithholding", extraWithholding), + checkRequired("filingStatus", filingStatus), + checkRequired("individualId", individualId), + checkRequired("otherIncome", otherIncome), + checkRequired( + "totalClaimDependentAndOtherCredits", + totalClaimDependentAndOtherCredits, + ), additionalProperties.toMutableMap(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsyncImpl.kt index ceae5f3b..bee420b4 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsyncImpl.kt @@ -14,9 +14,9 @@ import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepareAsync -import com.tryfinch.api.models.Provider import com.tryfinch.api.models.ProviderListPageAsync import com.tryfinch.api.models.ProviderListParams +import com.tryfinch.api.models.ProviderListResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -52,8 +52,8 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C clientOptions.toBuilder().apply(modifier::accept).build() ) - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) override fun list( params: ProviderListParams, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt index 6d1e37e0..46f7dd8b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt @@ -30,7 +30,7 @@ interface SessionServiceAsync { fun new_(params: ConnectSessionNewParams): CompletableFuture = new_(params, RequestOptions.none()) - /** @see new\_ */ + /** @see new_ */ fun new_( params: ConnectSessionNewParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -71,7 +71,7 @@ interface SessionServiceAsync { ): CompletableFuture> = new_(params, RequestOptions.none()) - /** @see new\_ */ + /** @see new_ */ fun new_( params: ConnectSessionNewParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt index 3f8d98ce..732dff37 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt @@ -40,7 +40,7 @@ interface AutomatedServiceAsync { * `w4_form_employee_sync`: Enqueues a job for sync W-4 data for a particular individual, * identified by `individual_id`. This feature is currently in beta. * - * This endpoint is available for _Scale_ tier customers as an add-on. To request access to this + * This endpoint is available for *Scale* tier customers as an add-on. To request access to this * endpoint, please contact your Finch account manager. */ fun create(): CompletableFuture = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt index 5152768a..7d3129b1 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt @@ -56,6 +56,24 @@ interface ConfigurationServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see update */ + fun update( + sandboxJobConfiguration: SandboxJobConfiguration, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update( + SandboxJobConfigurationUpdateParams.builder() + .sandboxJobConfiguration(sandboxJobConfiguration) + .build(), + requestOptions, + ) + + /** @see update */ + fun update( + sandboxJobConfiguration: SandboxJobConfiguration + ): CompletableFuture = + update(sandboxJobConfiguration, RequestOptions.none()) + /** * A view of [ConfigurationServiceAsync] that provides access to raw HTTP responses for each * method. @@ -112,5 +130,23 @@ interface ConfigurationServiceAsync { params: SandboxJobConfigurationUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see update */ + fun update( + sandboxJobConfiguration: SandboxJobConfiguration, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update( + SandboxJobConfigurationUpdateParams.builder() + .sandboxJobConfiguration(sandboxJobConfiguration) + .build(), + requestOptions, + ) + + /** @see update */ + fun update( + sandboxJobConfiguration: SandboxJobConfiguration + ): CompletableFuture> = + update(sandboxJobConfiguration, RequestOptions.none()) } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderServiceImpl.kt index 0d14316b..28b0539e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderServiceImpl.kt @@ -14,9 +14,9 @@ import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare -import com.tryfinch.api.models.Provider import com.tryfinch.api.models.ProviderListPage import com.tryfinch.api.models.ProviderListParams +import com.tryfinch.api.models.ProviderListResponse import java.util.function.Consumer class ProviderServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -51,8 +51,8 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client clientOptions.toBuilder().apply(modifier::accept).build() ) - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) override fun list( params: ProviderListParams, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionService.kt index e83b7a29..886d4517 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionService.kt @@ -30,7 +30,7 @@ interface SessionService { fun new_(params: ConnectSessionNewParams): SessionNewResponse = new_(params, RequestOptions.none()) - /** @see new\_ */ + /** @see new_ */ fun new_( params: ConnectSessionNewParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -64,7 +64,7 @@ interface SessionService { fun new_(params: ConnectSessionNewParams): HttpResponseFor = new_(params, RequestOptions.none()) - /** @see new\_ */ + /** @see new_ */ @MustBeClosed fun new_( params: ConnectSessionNewParams, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedService.kt index 71bf6cb1..a9cef18d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedService.kt @@ -40,7 +40,7 @@ interface AutomatedService { * `w4_form_employee_sync`: Enqueues a job for sync W-4 data for a particular individual, * identified by `individual_id`. This feature is currently in beta. * - * This endpoint is available for _Scale_ tier customers as an add-on. To request access to this + * This endpoint is available for *Scale* tier customers as an add-on. To request access to this * endpoint, please contact your Finch account manager. */ fun create(): AutomatedCreateResponse = create(JobAutomatedCreateParams.none()) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationService.kt index e8623714..3b94103d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationService.kt @@ -55,6 +55,22 @@ interface ConfigurationService { requestOptions: RequestOptions = RequestOptions.none(), ): SandboxJobConfiguration + /** @see update */ + fun update( + sandboxJobConfiguration: SandboxJobConfiguration, + requestOptions: RequestOptions = RequestOptions.none(), + ): SandboxJobConfiguration = + update( + SandboxJobConfigurationUpdateParams.builder() + .sandboxJobConfiguration(sandboxJobConfiguration) + .build(), + requestOptions, + ) + + /** @see update */ + fun update(sandboxJobConfiguration: SandboxJobConfiguration): SandboxJobConfiguration = + update(sandboxJobConfiguration, RequestOptions.none()) + /** * A view of [ConfigurationService] that provides access to raw HTTP responses for each method. */ @@ -114,5 +130,25 @@ interface ConfigurationService { params: SandboxJobConfigurationUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see update */ + @MustBeClosed + fun update( + sandboxJobConfiguration: SandboxJobConfiguration, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update( + SandboxJobConfigurationUpdateParams.builder() + .sandboxJobConfiguration(sandboxJobConfiguration) + .build(), + requestOptions, + ) + + /** @see update */ + @MustBeClosed + fun update( + sandboxJobConfiguration: SandboxJobConfiguration + ): HttpResponseFor = + update(sandboxJobConfiguration, RequestOptions.none()) } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/core/http/RetryingHttpClientTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/core/http/RetryingHttpClientTest.kt index c4a3af5b..22477264 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/core/http/RetryingHttpClientTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/core/http/RetryingHttpClientTest.kt @@ -6,6 +6,7 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario import com.tryfinch.api.client.okhttp.OkHttpClient import com.tryfinch.api.core.RequestOptions +import com.tryfinch.api.core.Sleeper import com.tryfinch.api.errors.FinchRetryableException import java.io.InputStream import java.time.Duration @@ -294,12 +295,14 @@ internal class RetryingHttpClientTest { .httpClient(failingHttpClient) .maxRetries(2) .sleeper( - object : RetryingHttpClient.Sleeper { + object : Sleeper { override fun sleep(duration: Duration) {} override fun sleepAsync(duration: Duration): CompletableFuture = CompletableFuture.completedFuture(null) + + override fun close() {} } ) .build() @@ -333,12 +336,14 @@ internal class RetryingHttpClientTest { .httpClient(httpClient) // Use a no-op `Sleeper` to make the test fast. .sleeper( - object : RetryingHttpClient.Sleeper { + object : Sleeper { override fun sleep(duration: Duration) {} override fun sleepAsync(duration: Duration): CompletableFuture = CompletableFuture.completedFuture(null) + + override fun close() {} } ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccessTokenCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccessTokenCreateParamsTest.kt index f1b2d6f2..6124f50c 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccessTokenCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccessTokenCreateParamsTest.kt @@ -10,10 +10,10 @@ internal class AccessTokenCreateParamsTest { @Test fun create() { AccessTokenCreateParams.builder() - .code("") + .code("code") .clientId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .clientSecret("") - .redirectUri("https://example.com") + .clientSecret("client_secret") + .redirectUri("redirect_uri") .build() } @@ -21,26 +21,26 @@ internal class AccessTokenCreateParamsTest { fun body() { val params = AccessTokenCreateParams.builder() - .code("") + .code("code") .clientId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .clientSecret("") - .redirectUri("https://example.com") + .clientSecret("client_secret") + .redirectUri("redirect_uri") .build() val body = params._body() - assertThat(body.code()).isEqualTo("") + assertThat(body.code()).isEqualTo("code") assertThat(body.clientId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.clientSecret()).contains("") - assertThat(body.redirectUri()).contains("https://example.com") + assertThat(body.clientSecret()).contains("client_secret") + assertThat(body.redirectUri()).contains("redirect_uri") } @Test fun bodyWithoutOptionalFields() { - val params = AccessTokenCreateParams.builder().code("").build() + val params = AccessTokenCreateParams.builder().code("code").build() val body = params._body() - assertThat(body.code()).isEqualTo("") + assertThat(body.code()).isEqualTo("code") } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CreateAccessTokenResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CreateAccessTokenResponseTest.kt index 70c06a3b..b81709a4 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CreateAccessTokenResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CreateAccessTokenResponseTest.kt @@ -14,29 +14,29 @@ internal class CreateAccessTokenResponseTest { val createAccessTokenResponse = CreateAccessTokenResponse.builder() .accessToken("access_token") - .accountId("account_id") - .clientType(CreateAccessTokenResponse.ClientType.PRODUCTION) - .companyId("company_id") + .clientType(CreateAccessTokenResponse.ClientType.DEVELOPMENT) .connectionId("connection_id") - .connectionType(CreateAccessTokenResponse.ConnectionType.PROVIDER) + .connectionType(CreateAccessTokenResponse.ConnectionType.FINCH) .addProduct("string") .providerId("provider_id") - .customerId("customer_id") .tokenType("token_type") + .accountId("account_id") + .companyId("company_id") + .customerId("customer_id") .build() assertThat(createAccessTokenResponse.accessToken()).isEqualTo("access_token") - assertThat(createAccessTokenResponse.accountId()).isEqualTo("account_id") assertThat(createAccessTokenResponse.clientType()) - .isEqualTo(CreateAccessTokenResponse.ClientType.PRODUCTION) - assertThat(createAccessTokenResponse.companyId()).isEqualTo("company_id") + .isEqualTo(CreateAccessTokenResponse.ClientType.DEVELOPMENT) assertThat(createAccessTokenResponse.connectionId()).isEqualTo("connection_id") assertThat(createAccessTokenResponse.connectionType()) - .isEqualTo(CreateAccessTokenResponse.ConnectionType.PROVIDER) + .isEqualTo(CreateAccessTokenResponse.ConnectionType.FINCH) assertThat(createAccessTokenResponse.products()).containsExactly("string") assertThat(createAccessTokenResponse.providerId()).isEqualTo("provider_id") + assertThat(createAccessTokenResponse.tokenType()).isEqualTo("token_type") + assertThat(createAccessTokenResponse.accountId()).contains("account_id") + assertThat(createAccessTokenResponse.companyId()).contains("company_id") assertThat(createAccessTokenResponse.customerId()).contains("customer_id") - assertThat(createAccessTokenResponse.tokenType()).contains("token_type") } @Test @@ -45,15 +45,15 @@ internal class CreateAccessTokenResponseTest { val createAccessTokenResponse = CreateAccessTokenResponse.builder() .accessToken("access_token") - .accountId("account_id") - .clientType(CreateAccessTokenResponse.ClientType.PRODUCTION) - .companyId("company_id") + .clientType(CreateAccessTokenResponse.ClientType.DEVELOPMENT) .connectionId("connection_id") - .connectionType(CreateAccessTokenResponse.ConnectionType.PROVIDER) + .connectionType(CreateAccessTokenResponse.ConnectionType.FINCH) .addProduct("string") .providerId("provider_id") - .customerId("customer_id") .tokenType("token_type") + .accountId("account_id") + .companyId("company_id") + .customerId("customer_id") .build() val roundtrippedCreateAccessTokenResponse = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DocumentResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DocumentResponseTest.kt index b44bd5da..eb8beebd 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DocumentResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DocumentResponseTest.kt @@ -20,11 +20,11 @@ internal class DocumentResponseTest { .year(0.0) .build() - assertThat(documentResponse.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(documentResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(documentResponse.individualId()).contains("individual_id") - assertThat(documentResponse.type()).contains(DocumentResponse.Type.W4_2020) - assertThat(documentResponse.url()).contains("https://example.com") - assertThat(documentResponse.year()).contains(0.0) + assertThat(documentResponse.type()).isEqualTo(DocumentResponse.Type.W4_2020) + assertThat(documentResponse.url()).isEqualTo("https://example.com") + assertThat(documentResponse.year()).isEqualTo(0.0) } @Test 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 7f376d05..59c25559 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 @@ -38,18 +38,11 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .metadata( PayStatement.Earning.Attributes.Metadata .builder() - .metadata( - PayStatement.Earning.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), ) .build() ) @@ -72,19 +65,11 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .Attributes .Metadata .builder() - .metadata( - PayStatement.EmployeeDeduction - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), ) .build() ) @@ -106,20 +91,11 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .Attributes .Metadata .builder() - .metadata( - PayStatement - .EmployerContribution - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), ) .build() ) @@ -147,18 +123,11 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .metadata( PayStatement.Tax.Attributes.Metadata .builder() - .metadata( - PayStatement.Tax.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), ) .build() ) @@ -203,18 +172,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .metadata( PayStatement.Earning.Attributes.Metadata .builder() - .metadata( - PayStatement.Earning.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -235,19 +195,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { PayStatement.EmployeeDeduction.Attributes .Metadata .builder() - .metadata( - PayStatement.EmployeeDeduction - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -268,19 +218,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { PayStatement.EmployerContribution.Attributes .Metadata .builder() - .metadata( - PayStatement.EmployerContribution - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -306,17 +246,9 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .metadata( PayStatement.Tax.Attributes.Metadata .builder() - .metadata( - PayStatement.Tax.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -365,18 +297,11 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .metadata( PayStatement.Earning.Attributes.Metadata .builder() - .metadata( - PayStatement.Earning.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), ) .build() ) @@ -399,19 +324,11 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .Attributes .Metadata .builder() - .metadata( - PayStatement.EmployeeDeduction - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), ) .build() ) @@ -433,20 +350,11 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .Attributes .Metadata .builder() - .metadata( - PayStatement - .EmployerContribution - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), ) .build() ) @@ -474,18 +382,11 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .metadata( PayStatement.Tax.Attributes.Metadata .builder() - .metadata( - PayStatement.Tax.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IntrospectionTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IntrospectionTest.kt index 79792152..10201bda 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IntrospectionTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IntrospectionTest.kt @@ -5,6 +5,7 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.jsonMapper import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,77 +16,82 @@ internal class IntrospectionTest { val introspection = Introspection.builder() .id("id") + .clientId("client_id") + .clientType(Introspection.ClientType.DEVELOPMENT) + .connectionId("connection_id") + .connectionStatus( + Introspection.ConnectionStatusDetail.builder() + .status(ConnectionStatusType.PENDING) + .lastSuccessfulSync(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .message("message") + .build() + ) + .connectionType(Introspection.ConnectionType.FINCH) + .addProduct("string") + .providerId("provider_id") .accountId("account_id") .addAuthenticationMethod( - Introspection.AuthenticationMethod.builder() + Introspection.AuthenticationMethodDetail.builder() + .type(Introspection.AuthenticationMethodDetail.Type.ASSISTED) .connectionStatus( - Introspection.AuthenticationMethod.ConnectionStatus.builder() - .message("message") + Introspection.AuthenticationMethodDetail.ConnectionStatusDetail + .builder() .status(ConnectionStatusType.PENDING) + .lastSuccessfulSync( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .message("message") .build() ) .addProduct("string") - .type(Introspection.AuthenticationMethod.Type.ASSISTED) .build() ) - .clientId("client_id") - .clientType(Introspection.ClientType.PRODUCTION) .companyId("company_id") - .connectionId("connection_id") - .connectionStatus( - Introspection.ConnectionStatus.builder() - .lastSuccessfulSync(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .message("message") - .status(ConnectionStatusType.PENDING) - .build() - ) - .connectionType(Introspection.ConnectionType.PROVIDER) .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") .manual(true) .payrollProviderId("payroll_provider_id") - .addProduct("string") - .providerId("provider_id") .username("username") .build() assertThat(introspection.id()).isEqualTo("id") - assertThat(introspection.accountId()).isEqualTo("account_id") - assertThat(introspection.authenticationMethods()) - .containsExactly( - Introspection.AuthenticationMethod.builder() - .connectionStatus( - Introspection.AuthenticationMethod.ConnectionStatus.builder() - .message("message") - .status(ConnectionStatusType.PENDING) - .build() - ) - .addProduct("string") - .type(Introspection.AuthenticationMethod.Type.ASSISTED) - .build() - ) assertThat(introspection.clientId()).isEqualTo("client_id") - assertThat(introspection.clientType()).isEqualTo(Introspection.ClientType.PRODUCTION) - assertThat(introspection.companyId()).isEqualTo("company_id") + assertThat(introspection.clientType()).isEqualTo(Introspection.ClientType.DEVELOPMENT) assertThat(introspection.connectionId()).isEqualTo("connection_id") assertThat(introspection.connectionStatus()) .isEqualTo( - Introspection.ConnectionStatus.builder() + Introspection.ConnectionStatusDetail.builder() + .status(ConnectionStatusType.PENDING) .lastSuccessfulSync(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .message("message") - .status(ConnectionStatusType.PENDING) .build() ) - assertThat(introspection.connectionType()).isEqualTo(Introspection.ConnectionType.PROVIDER) + assertThat(introspection.connectionType()).isEqualTo(Introspection.ConnectionType.FINCH) + assertThat(introspection.products()).containsExactly("string") + assertThat(introspection.providerId()).isEqualTo("provider_id") + assertThat(introspection.accountId()).contains("account_id") + assertThat(introspection.authenticationMethods().getOrNull()) + .containsExactly( + Introspection.AuthenticationMethodDetail.builder() + .type(Introspection.AuthenticationMethodDetail.Type.ASSISTED) + .connectionStatus( + Introspection.AuthenticationMethodDetail.ConnectionStatusDetail.builder() + .status(ConnectionStatusType.PENDING) + .lastSuccessfulSync(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .message("message") + .build() + ) + .addProduct("string") + .build() + ) + assertThat(introspection.companyId()).contains("company_id") assertThat(introspection.customerEmail()).contains("customer_email") assertThat(introspection.customerId()).contains("customer_id") assertThat(introspection.customerName()).contains("customer_name") - assertThat(introspection.manual()).isEqualTo(true) - assertThat(introspection.payrollProviderId()).isEqualTo("payroll_provider_id") - assertThat(introspection.products()).containsExactly("string") - assertThat(introspection.providerId()).isEqualTo("provider_id") - assertThat(introspection.username()).isEqualTo("username") + assertThat(introspection.manual()).contains(true) + assertThat(introspection.payrollProviderId()).contains("payroll_provider_id") + assertThat(introspection.username()).contains("username") } @Test @@ -94,38 +100,42 @@ internal class IntrospectionTest { val introspection = Introspection.builder() .id("id") + .clientId("client_id") + .clientType(Introspection.ClientType.DEVELOPMENT) + .connectionId("connection_id") + .connectionStatus( + Introspection.ConnectionStatusDetail.builder() + .status(ConnectionStatusType.PENDING) + .lastSuccessfulSync(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .message("message") + .build() + ) + .connectionType(Introspection.ConnectionType.FINCH) + .addProduct("string") + .providerId("provider_id") .accountId("account_id") .addAuthenticationMethod( - Introspection.AuthenticationMethod.builder() + Introspection.AuthenticationMethodDetail.builder() + .type(Introspection.AuthenticationMethodDetail.Type.ASSISTED) .connectionStatus( - Introspection.AuthenticationMethod.ConnectionStatus.builder() - .message("message") + Introspection.AuthenticationMethodDetail.ConnectionStatusDetail + .builder() .status(ConnectionStatusType.PENDING) + .lastSuccessfulSync( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .message("message") .build() ) .addProduct("string") - .type(Introspection.AuthenticationMethod.Type.ASSISTED) .build() ) - .clientId("client_id") - .clientType(Introspection.ClientType.PRODUCTION) .companyId("company_id") - .connectionId("connection_id") - .connectionStatus( - Introspection.ConnectionStatus.builder() - .lastSuccessfulSync(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .message("message") - .status(ConnectionStatusType.PENDING) - .build() - ) - .connectionType(Introspection.ConnectionType.PROVIDER) .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") .manual(true) .payrollProviderId("payroll_provider_id") - .addProduct("string") - .providerId("provider_id") .username("username") .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedListParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedListParamsTest.kt index b88567a2..a6a42d5d 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedListParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedListParamsTest.kt @@ -10,32 +10,17 @@ internal class JobAutomatedListParamsTest { @Test fun create() { - JobAutomatedListParams.builder() - .entityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .offset(0L) - .build() + JobAutomatedListParams.builder().limit(0L).offset(0L).build() } @Test fun queryParams() { - val params = - JobAutomatedListParams.builder() - .entityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .offset(0L) - .build() + val params = JobAutomatedListParams.builder().limit(0L).offset(0L).build() val queryParams = params._queryParams() assertThat(queryParams) - .isEqualTo( - QueryParams.builder() - .put("entity_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .put("limit", "0") - .put("offset", "0") - .build() - ) + .isEqualTo(QueryParams.builder().put("limit", "0").put("offset", "0").build()) } @Test diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedRetrieveParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedRetrieveParamsTest.kt index 38985812..d8c03a77 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedRetrieveParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedRetrieveParamsTest.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.models -import com.tryfinch.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -10,10 +9,7 @@ internal class JobAutomatedRetrieveParamsTest { @Test fun create() { - JobAutomatedRetrieveParams.builder() - .jobId("job_id") - .entityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + JobAutomatedRetrieveParams.builder().jobId("job_id").build() } @Test @@ -24,31 +20,4 @@ internal class JobAutomatedRetrieveParamsTest { // out-of-bound path param assertThat(params._pathParam(1)).isEqualTo("") } - - @Test - fun queryParams() { - val params = - JobAutomatedRetrieveParams.builder() - .jobId("job_id") - .entityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo( - QueryParams.builder() - .put("entity_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = JobAutomatedRetrieveParams.builder().jobId("job_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobManualRetrieveParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobManualRetrieveParamsTest.kt index 42fee7d2..4d7590ce 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobManualRetrieveParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobManualRetrieveParamsTest.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.models -import com.tryfinch.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -10,10 +9,7 @@ internal class JobManualRetrieveParamsTest { @Test fun create() { - JobManualRetrieveParams.builder() - .jobId("job_id") - .entityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() + JobManualRetrieveParams.builder().jobId("job_id").build() } @Test @@ -24,31 +20,4 @@ internal class JobManualRetrieveParamsTest { // out-of-bound path param assertThat(params._pathParam(1)).isEqualTo("") } - - @Test - fun queryParams() { - val params = - JobManualRetrieveParams.builder() - .jobId("job_id") - .entityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo( - QueryParams.builder() - .put("entity_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = JobManualRetrieveParams.builder().jobId("job_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().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 9ea719d0..af1498ea 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 @@ -28,15 +28,9 @@ internal class PayStatementResponseBodyTest { PayStatement.Earning.Attributes.builder() .metadata( PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -56,16 +50,9 @@ internal class PayStatementResponseBodyTest { .metadata( PayStatement.EmployeeDeduction.Attributes.Metadata .builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -84,16 +71,9 @@ internal class PayStatementResponseBodyTest { .metadata( PayStatement.EmployerContribution.Attributes.Metadata .builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -116,15 +96,9 @@ internal class PayStatementResponseBodyTest { PayStatement.Tax.Attributes.builder() .metadata( PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -154,15 +128,9 @@ internal class PayStatementResponseBodyTest { PayStatement.Earning.Attributes.builder() .metadata( PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -181,15 +149,9 @@ internal class PayStatementResponseBodyTest { PayStatement.EmployeeDeduction.Attributes.builder() .metadata( PayStatement.EmployeeDeduction.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -208,16 +170,9 @@ internal class PayStatementResponseBodyTest { .metadata( PayStatement.EmployerContribution.Attributes.Metadata .builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -240,14 +195,9 @@ internal class PayStatementResponseBodyTest { PayStatement.Tax.Attributes.builder() .metadata( PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -280,15 +230,9 @@ internal class PayStatementResponseBodyTest { PayStatement.Earning.Attributes.builder() .metadata( PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -308,16 +252,9 @@ internal class PayStatementResponseBodyTest { .metadata( PayStatement.EmployeeDeduction.Attributes.Metadata .builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -336,16 +273,9 @@ internal class PayStatementResponseBodyTest { .metadata( PayStatement.EmployerContribution.Attributes.Metadata .builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -368,15 +298,9 @@ internal class PayStatementResponseBodyTest { PayStatement.Tax.Attributes.builder() .metadata( PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + 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 32b97305..720031e2 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,17 +33,9 @@ internal class PayStatementResponseTest { .metadata( PayStatement.Earning.Attributes.Metadata .builder() - .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -64,19 +56,9 @@ internal class PayStatementResponseTest { PayStatement.EmployeeDeduction.Attributes .Metadata .builder() - .metadata( - PayStatement.EmployeeDeduction - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -96,19 +78,9 @@ internal class PayStatementResponseTest { PayStatement.EmployerContribution.Attributes .Metadata .builder() - .metadata( - PayStatement.EmployerContribution - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -131,17 +103,9 @@ internal class PayStatementResponseTest { PayStatement.Tax.Attributes.builder() .metadata( PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -180,17 +144,9 @@ internal class PayStatementResponseTest { .metadata( PayStatement.Earning.Attributes.Metadata .builder() - .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -211,19 +167,9 @@ internal class PayStatementResponseTest { PayStatement.EmployeeDeduction.Attributes .Metadata .builder() - .metadata( - PayStatement.EmployeeDeduction - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -243,19 +189,9 @@ internal class PayStatementResponseTest { PayStatement.EmployerContribution.Attributes .Metadata .builder() - .metadata( - PayStatement.EmployerContribution - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -278,17 +214,9 @@ internal class PayStatementResponseTest { PayStatement.Tax.Attributes.builder() .metadata( PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -331,17 +259,9 @@ internal class PayStatementResponseTest { .metadata( PayStatement.Earning.Attributes.Metadata .builder() - .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -362,19 +282,9 @@ internal class PayStatementResponseTest { PayStatement.EmployeeDeduction.Attributes .Metadata .builder() - .metadata( - PayStatement.EmployeeDeduction - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -394,19 +304,9 @@ internal class PayStatementResponseTest { PayStatement.EmployerContribution.Attributes .Metadata .builder() - .metadata( - PayStatement.EmployerContribution - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -429,17 +329,9 @@ internal class PayStatementResponseTest { PayStatement.Tax.Attributes.builder() .metadata( PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf() - ), - ) - .build() + .putAdditionalProperty( + "foo", + 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 abd69775..9d70619b 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 @@ -26,14 +26,9 @@ internal class PayStatementTest { PayStatement.Earning.Attributes.builder() .metadata( PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -52,15 +47,9 @@ internal class PayStatementTest { PayStatement.EmployeeDeduction.Attributes.builder() .metadata( PayStatement.EmployeeDeduction.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -78,15 +67,9 @@ internal class PayStatementTest { PayStatement.EmployerContribution.Attributes.builder() .metadata( PayStatement.EmployerContribution.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployerContribution.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -109,14 +92,9 @@ internal class PayStatementTest { PayStatement.Tax.Attributes.builder() .metadata( PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -140,14 +118,9 @@ internal class PayStatementTest { PayStatement.Earning.Attributes.builder() .metadata( PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -167,15 +140,9 @@ internal class PayStatementTest { PayStatement.EmployeeDeduction.Attributes.builder() .metadata( PayStatement.EmployeeDeduction.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -194,15 +161,9 @@ internal class PayStatementTest { PayStatement.EmployerContribution.Attributes.builder() .metadata( PayStatement.EmployerContribution.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployerContribution.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -228,13 +189,9 @@ internal class PayStatementTest { PayStatement.Tax.Attributes.builder() .metadata( PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.InnerMetadata.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -262,14 +219,9 @@ internal class PayStatementTest { PayStatement.Earning.Attributes.builder() .metadata( PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -288,15 +240,9 @@ internal class PayStatementTest { PayStatement.EmployeeDeduction.Attributes.builder() .metadata( PayStatement.EmployeeDeduction.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -314,15 +260,9 @@ internal class PayStatementTest { PayStatement.EmployerContribution.Attributes.builder() .metadata( PayStatement.EmployerContribution.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployerContribution.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -345,14 +285,9 @@ internal class PayStatementTest { PayStatement.Tax.Attributes.builder() .metadata( PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderListResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderListResponseTest.kt new file mode 100644 index 00000000..599c5e86 --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderListResponseTest.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProviderListResponseTest { + + @Test + fun create() { + val providerListResponse = + ProviderListResponse.builder() + .id("id") + .displayName("display_name") + .addProduct("string") + .addAuthenticationMethod( + ProviderListResponse.AuthenticationMethod.builder() + .type(ProviderListResponse.AuthenticationMethod.Type.ASSISTED) + .benefitsSupport( + ProviderListResponse.AuthenticationMethod.BenefitsSupport.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .supportedFields( + ProviderListResponse.AuthenticationMethod.SupportedFields.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + .beta(true) + .icon("icon") + .logo("logo") + .manual(true) + .mfaRequired(true) + .primaryColor("primary_color") + .build() + + assertThat(providerListResponse.id()).isEqualTo("id") + assertThat(providerListResponse.displayName()).isEqualTo("display_name") + assertThat(providerListResponse.products()).containsExactly("string") + assertThat(providerListResponse.authenticationMethods().getOrNull()) + .containsExactly( + ProviderListResponse.AuthenticationMethod.builder() + .type(ProviderListResponse.AuthenticationMethod.Type.ASSISTED) + .benefitsSupport( + ProviderListResponse.AuthenticationMethod.BenefitsSupport.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .supportedFields( + ProviderListResponse.AuthenticationMethod.SupportedFields.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + assertThat(providerListResponse.beta()).contains(true) + assertThat(providerListResponse.icon()).contains("icon") + assertThat(providerListResponse.logo()).contains("logo") + assertThat(providerListResponse.manual()).contains(true) + assertThat(providerListResponse.mfaRequired()).contains(true) + assertThat(providerListResponse.primaryColor()).contains("primary_color") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val providerListResponse = + ProviderListResponse.builder() + .id("id") + .displayName("display_name") + .addProduct("string") + .addAuthenticationMethod( + ProviderListResponse.AuthenticationMethod.builder() + .type(ProviderListResponse.AuthenticationMethod.Type.ASSISTED) + .benefitsSupport( + ProviderListResponse.AuthenticationMethod.BenefitsSupport.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .supportedFields( + ProviderListResponse.AuthenticationMethod.SupportedFields.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + .beta(true) + .icon("icon") + .logo("logo") + .manual(true) + .mfaRequired(true) + .primaryColor("primary_color") + .build() + + val roundtrippedProviderListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(providerListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedProviderListResponse).isEqualTo(providerListResponse) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderTest.kt index ab8560ee..fa7b3995 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderTest.kt @@ -3,6 +3,7 @@ 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 org.assertj.core.api.Assertions.assertThat @@ -15,1684 +16,56 @@ internal class ProviderTest { val provider = Provider.builder() .id("id") + .displayName("display_name") + .addProduct("string") .addAuthenticationMethod( Provider.AuthenticationMethod.builder() + .type(Provider.AuthenticationMethod.Type.ASSISTED) .benefitsSupport( - BenefitsSupport.builder() - .commuter( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .customPostTax( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .customPreTax( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .fsaDependentCare( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .fsaMedical( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .hsaPost( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .hsaPre( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .s125Dental( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .s125Medical( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .s125Vision( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .simple( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .simpleIra( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) + Provider.AuthenticationMethod.BenefitsSupport.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .supportedFields( Provider.AuthenticationMethod.SupportedFields.builder() - .company( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .builder() - .id(true) - .accounts( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Accounts - .builder() - .accountName(true) - .accountNumber(true) - .accountType(true) - .institutionName(true) - .routingNumber(true) - .build() - ) - .departments( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Departments - .builder() - .name(true) - .parent( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Departments - .Parent - .builder() - .name(true) - .build() - ) - .build() - ) - .ein(true) - .entity( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Entity - .builder() - .subtype(true) - .type(true) - .build() - ) - .legalName(true) - .locations( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Locations - .builder() - .city(true) - .country(true) - .line1(true) - .line2(true) - .postalCode(true) - .state(true) - .build() - ) - .primaryEmail(true) - .primaryPhoneNumber(true) - .build() - ) - .directory( - Provider.AuthenticationMethod.SupportedFields - .SupportedDirectoryFields - .builder() - .individuals( - Provider.AuthenticationMethod.SupportedFields - .SupportedDirectoryFields - .Individuals - .builder() - .id(true) - .department(true) - .firstName(true) - .isActive(true) - .lastName(true) - .manager( - Provider.AuthenticationMethod.SupportedFields - .SupportedDirectoryFields - .Individuals - .Manager - .builder() - .id(true) - .build() - ) - .middleName(true) - .build() - ) - .paging( - Provider.AuthenticationMethod.SupportedFields - .SupportedDirectoryFields - .Paging - .builder() - .count(true) - .offset(true) - .build() - ) - .build() - ) - .employment( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .builder() - .id(true) - .classCode(true) - .customFields(true) - .department( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Department - .builder() - .name(true) - .build() - ) - .employment( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Employment - .builder() - .subtype(true) - .type(true) - .build() - ) - .employmentStatus(true) - .endDate(true) - .firstName(true) - .income( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Income - .builder() - .amount(true) - .currency(true) - .unit(true) - .build() - ) - .incomeHistory(true) - .isActive(true) - .lastName(true) - .location( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Location - .builder() - .city(true) - .country(true) - .line1(true) - .line2(true) - .postalCode(true) - .state(true) - .build() - ) - .manager( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Manager - .builder() - .id(true) - .build() - ) - .middleName(true) - .startDate(true) - .title(true) - .build() - ) - .individual( - Provider.AuthenticationMethod.SupportedFields - .SupportedIndividualFields - .builder() - .id(true) - .dob(true) - .emails( - Provider.AuthenticationMethod.SupportedFields - .SupportedIndividualFields - .Emails - .builder() - .data(true) - .type(true) - .build() - ) - .encryptedSsn(true) - .ethnicity(true) - .firstName(true) - .gender(true) - .lastName(true) - .middleName(true) - .phoneNumbers( - Provider.AuthenticationMethod.SupportedFields - .SupportedIndividualFields - .PhoneNumbers - .builder() - .data(true) - .type(true) - .build() - ) - .preferredName(true) - .residence( - Provider.AuthenticationMethod.SupportedFields - .SupportedIndividualFields - .Residence - .builder() - .city(true) - .country(true) - .line1(true) - .line2(true) - .postalCode(true) - .state(true) - .build() - ) - .ssn(true) - .build() - ) - .payGroup( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayGroupFields - .builder() - .id(true) - .individualIds(true) - .name(true) - .payFrequencies(true) - .build() - ) - .payStatement( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .builder() - .paging( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .Paging - .builder() - .count(true) - .offset(true) - .build() - ) - .payStatements( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .builder() - .earnings( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .Earnings - .builder() - .amount(true) - .currency(true) - .name(true) - .type(true) - .build() - ) - .employeeDeductions( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .EmployeeDeductions - .builder() - .amount(true) - .currency(true) - .name(true) - .preTax(true) - .type(true) - .build() - ) - .employerContributions( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .EmployerContributions - .builder() - .amount(true) - .currency(true) - .name(true) - .build() - ) - .grossPay(true) - .individualId(true) - .netPay(true) - .paymentMethod(true) - .taxes( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .Taxes - .builder() - .amount(true) - .currency(true) - .employer(true) - .name(true) - .type(true) - .build() - ) - .totalHours(true) - .type(true) - .build() - ) - .build() - ) - .payment( - Provider.AuthenticationMethod.SupportedFields - .SupportedPaymentFields - .builder() - .id(true) - .companyDebit(true) - .debitDate(true) - .employeeTaxes(true) - .employerTaxes(true) - .grossPay(true) - .individualIds(true) - .netPay(true) - .payDate(true) - .payFrequencies(true) - .payGroupIds(true) - .payPeriod( - Provider.AuthenticationMethod.SupportedFields - .SupportedPaymentFields - .PayPeriod - .builder() - .endDate(true) - .startDate(true) - .build() - ) - .build() - ) + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .type(Provider.AuthenticationMethod.Type.ASSISTED) .build() ) .beta(true) - .displayName("display_name") .icon("icon") .logo("logo") .manual(true) .mfaRequired(true) .primaryColor("primary_color") - .addProduct("string") .build() - assertThat(provider.id()).contains("id") + assertThat(provider.id()).isEqualTo("id") + assertThat(provider.displayName()).isEqualTo("display_name") + assertThat(provider.products()).containsExactly("string") assertThat(provider.authenticationMethods().getOrNull()) .containsExactly( Provider.AuthenticationMethod.builder() + .type(Provider.AuthenticationMethod.Type.ASSISTED) .benefitsSupport( - BenefitsSupport.builder() - .commuter( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .customPostTax( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .customPreTax( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .fsaDependentCare( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .fsaMedical( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .hsaPost( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .hsaPre( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .s125Dental( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .s125Medical( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .s125Vision( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .simple( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .simpleIra( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) + Provider.AuthenticationMethod.BenefitsSupport.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .supportedFields( Provider.AuthenticationMethod.SupportedFields.builder() - .company( - Provider.AuthenticationMethod.SupportedFields.SupportedCompanyFields - .builder() - .id(true) - .accounts( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Accounts - .builder() - .accountName(true) - .accountNumber(true) - .accountType(true) - .institutionName(true) - .routingNumber(true) - .build() - ) - .departments( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Departments - .builder() - .name(true) - .parent( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Departments - .Parent - .builder() - .name(true) - .build() - ) - .build() - ) - .ein(true) - .entity( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Entity - .builder() - .subtype(true) - .type(true) - .build() - ) - .legalName(true) - .locations( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Locations - .builder() - .city(true) - .country(true) - .line1(true) - .line2(true) - .postalCode(true) - .state(true) - .build() - ) - .primaryEmail(true) - .primaryPhoneNumber(true) - .build() - ) - .directory( - Provider.AuthenticationMethod.SupportedFields - .SupportedDirectoryFields - .builder() - .individuals( - Provider.AuthenticationMethod.SupportedFields - .SupportedDirectoryFields - .Individuals - .builder() - .id(true) - .department(true) - .firstName(true) - .isActive(true) - .lastName(true) - .manager( - Provider.AuthenticationMethod.SupportedFields - .SupportedDirectoryFields - .Individuals - .Manager - .builder() - .id(true) - .build() - ) - .middleName(true) - .build() - ) - .paging( - Provider.AuthenticationMethod.SupportedFields - .SupportedDirectoryFields - .Paging - .builder() - .count(true) - .offset(true) - .build() - ) - .build() - ) - .employment( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .builder() - .id(true) - .classCode(true) - .customFields(true) - .department( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Department - .builder() - .name(true) - .build() - ) - .employment( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Employment - .builder() - .subtype(true) - .type(true) - .build() - ) - .employmentStatus(true) - .endDate(true) - .firstName(true) - .income( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Income - .builder() - .amount(true) - .currency(true) - .unit(true) - .build() - ) - .incomeHistory(true) - .isActive(true) - .lastName(true) - .location( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Location - .builder() - .city(true) - .country(true) - .line1(true) - .line2(true) - .postalCode(true) - .state(true) - .build() - ) - .manager( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Manager - .builder() - .id(true) - .build() - ) - .middleName(true) - .startDate(true) - .title(true) - .build() - ) - .individual( - Provider.AuthenticationMethod.SupportedFields - .SupportedIndividualFields - .builder() - .id(true) - .dob(true) - .emails( - Provider.AuthenticationMethod.SupportedFields - .SupportedIndividualFields - .Emails - .builder() - .data(true) - .type(true) - .build() - ) - .encryptedSsn(true) - .ethnicity(true) - .firstName(true) - .gender(true) - .lastName(true) - .middleName(true) - .phoneNumbers( - Provider.AuthenticationMethod.SupportedFields - .SupportedIndividualFields - .PhoneNumbers - .builder() - .data(true) - .type(true) - .build() - ) - .preferredName(true) - .residence( - Provider.AuthenticationMethod.SupportedFields - .SupportedIndividualFields - .Residence - .builder() - .city(true) - .country(true) - .line1(true) - .line2(true) - .postalCode(true) - .state(true) - .build() - ) - .ssn(true) - .build() - ) - .payGroup( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayGroupFields - .builder() - .id(true) - .individualIds(true) - .name(true) - .payFrequencies(true) - .build() - ) - .payStatement( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .builder() - .paging( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .Paging - .builder() - .count(true) - .offset(true) - .build() - ) - .payStatements( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .builder() - .earnings( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .Earnings - .builder() - .amount(true) - .currency(true) - .name(true) - .type(true) - .build() - ) - .employeeDeductions( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .EmployeeDeductions - .builder() - .amount(true) - .currency(true) - .name(true) - .preTax(true) - .type(true) - .build() - ) - .employerContributions( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .EmployerContributions - .builder() - .amount(true) - .currency(true) - .name(true) - .build() - ) - .grossPay(true) - .individualId(true) - .netPay(true) - .paymentMethod(true) - .taxes( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .Taxes - .builder() - .amount(true) - .currency(true) - .employer(true) - .name(true) - .type(true) - .build() - ) - .totalHours(true) - .type(true) - .build() - ) - .build() - ) - .payment( - Provider.AuthenticationMethod.SupportedFields.SupportedPaymentFields - .builder() - .id(true) - .companyDebit(true) - .debitDate(true) - .employeeTaxes(true) - .employerTaxes(true) - .grossPay(true) - .individualIds(true) - .netPay(true) - .payDate(true) - .payFrequencies(true) - .payGroupIds(true) - .payPeriod( - Provider.AuthenticationMethod.SupportedFields - .SupportedPaymentFields - .PayPeriod - .builder() - .endDate(true) - .startDate(true) - .build() - ) - .build() - ) + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .type(Provider.AuthenticationMethod.Type.ASSISTED) .build() ) assertThat(provider.beta()).contains(true) - assertThat(provider.displayName()).contains("display_name") assertThat(provider.icon()).contains("icon") assertThat(provider.logo()).contains("logo") assertThat(provider.manual()).contains(true) assertThat(provider.mfaRequired()).contains(true) assertThat(provider.primaryColor()).contains("primary_color") - assertThat(provider.products().getOrNull()).containsExactly("string") } @Test @@ -1701,844 +74,29 @@ internal class ProviderTest { val provider = Provider.builder() .id("id") + .displayName("display_name") + .addProduct("string") .addAuthenticationMethod( Provider.AuthenticationMethod.builder() + .type(Provider.AuthenticationMethod.Type.ASSISTED) .benefitsSupport( - BenefitsSupport.builder() - .commuter( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .customPostTax( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .customPreTax( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .fsaDependentCare( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .fsaMedical( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .hsaPost( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .hsaPre( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .s125Dental( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .s125Medical( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .s125Vision( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .simple( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) - .simpleIra( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - SupportedBenefit.builder() - .annualMaximum(true) - .addCompanyContribution( - SupportedBenefit.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction( - SupportedBenefit.EmployeeDeduction.FIXED - ) - .addFrequency(BenefitFrequency.EVERY_PAYCHECK) - .catchUp(true) - .addHsaContributionLimit( - SupportedBenefit.HsaContributionLimit.FAMILY - ) - .build() - ) - .supportedOperations( - SupportPerBenefitType.builder() - .companyBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .individualBenefits( - OperationSupportMatrix.builder() - .create(OperationSupport.SUPPORTED) - .delete(OperationSupport.SUPPORTED) - .read(OperationSupport.SUPPORTED) - .update(OperationSupport.SUPPORTED) - .build() - ) - .build() - ) - .build() - ) + Provider.AuthenticationMethod.BenefitsSupport.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .supportedFields( Provider.AuthenticationMethod.SupportedFields.builder() - .company( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .builder() - .id(true) - .accounts( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Accounts - .builder() - .accountName(true) - .accountNumber(true) - .accountType(true) - .institutionName(true) - .routingNumber(true) - .build() - ) - .departments( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Departments - .builder() - .name(true) - .parent( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Departments - .Parent - .builder() - .name(true) - .build() - ) - .build() - ) - .ein(true) - .entity( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Entity - .builder() - .subtype(true) - .type(true) - .build() - ) - .legalName(true) - .locations( - Provider.AuthenticationMethod.SupportedFields - .SupportedCompanyFields - .Locations - .builder() - .city(true) - .country(true) - .line1(true) - .line2(true) - .postalCode(true) - .state(true) - .build() - ) - .primaryEmail(true) - .primaryPhoneNumber(true) - .build() - ) - .directory( - Provider.AuthenticationMethod.SupportedFields - .SupportedDirectoryFields - .builder() - .individuals( - Provider.AuthenticationMethod.SupportedFields - .SupportedDirectoryFields - .Individuals - .builder() - .id(true) - .department(true) - .firstName(true) - .isActive(true) - .lastName(true) - .manager( - Provider.AuthenticationMethod.SupportedFields - .SupportedDirectoryFields - .Individuals - .Manager - .builder() - .id(true) - .build() - ) - .middleName(true) - .build() - ) - .paging( - Provider.AuthenticationMethod.SupportedFields - .SupportedDirectoryFields - .Paging - .builder() - .count(true) - .offset(true) - .build() - ) - .build() - ) - .employment( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .builder() - .id(true) - .classCode(true) - .customFields(true) - .department( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Department - .builder() - .name(true) - .build() - ) - .employment( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Employment - .builder() - .subtype(true) - .type(true) - .build() - ) - .employmentStatus(true) - .endDate(true) - .firstName(true) - .income( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Income - .builder() - .amount(true) - .currency(true) - .unit(true) - .build() - ) - .incomeHistory(true) - .isActive(true) - .lastName(true) - .location( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Location - .builder() - .city(true) - .country(true) - .line1(true) - .line2(true) - .postalCode(true) - .state(true) - .build() - ) - .manager( - Provider.AuthenticationMethod.SupportedFields - .SupportedEmploymentFields - .Manager - .builder() - .id(true) - .build() - ) - .middleName(true) - .startDate(true) - .title(true) - .build() - ) - .individual( - Provider.AuthenticationMethod.SupportedFields - .SupportedIndividualFields - .builder() - .id(true) - .dob(true) - .emails( - Provider.AuthenticationMethod.SupportedFields - .SupportedIndividualFields - .Emails - .builder() - .data(true) - .type(true) - .build() - ) - .encryptedSsn(true) - .ethnicity(true) - .firstName(true) - .gender(true) - .lastName(true) - .middleName(true) - .phoneNumbers( - Provider.AuthenticationMethod.SupportedFields - .SupportedIndividualFields - .PhoneNumbers - .builder() - .data(true) - .type(true) - .build() - ) - .preferredName(true) - .residence( - Provider.AuthenticationMethod.SupportedFields - .SupportedIndividualFields - .Residence - .builder() - .city(true) - .country(true) - .line1(true) - .line2(true) - .postalCode(true) - .state(true) - .build() - ) - .ssn(true) - .build() - ) - .payGroup( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayGroupFields - .builder() - .id(true) - .individualIds(true) - .name(true) - .payFrequencies(true) - .build() - ) - .payStatement( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .builder() - .paging( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .Paging - .builder() - .count(true) - .offset(true) - .build() - ) - .payStatements( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .builder() - .earnings( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .Earnings - .builder() - .amount(true) - .currency(true) - .name(true) - .type(true) - .build() - ) - .employeeDeductions( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .EmployeeDeductions - .builder() - .amount(true) - .currency(true) - .name(true) - .preTax(true) - .type(true) - .build() - ) - .employerContributions( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .EmployerContributions - .builder() - .amount(true) - .currency(true) - .name(true) - .build() - ) - .grossPay(true) - .individualId(true) - .netPay(true) - .paymentMethod(true) - .taxes( - Provider.AuthenticationMethod.SupportedFields - .SupportedPayStatementFields - .PayStatements - .Taxes - .builder() - .amount(true) - .currency(true) - .employer(true) - .name(true) - .type(true) - .build() - ) - .totalHours(true) - .type(true) - .build() - ) - .build() - ) - .payment( - Provider.AuthenticationMethod.SupportedFields - .SupportedPaymentFields - .builder() - .id(true) - .companyDebit(true) - .debitDate(true) - .employeeTaxes(true) - .employerTaxes(true) - .grossPay(true) - .individualIds(true) - .netPay(true) - .payDate(true) - .payFrequencies(true) - .payGroupIds(true) - .payPeriod( - Provider.AuthenticationMethod.SupportedFields - .SupportedPaymentFields - .PayPeriod - .builder() - .endDate(true) - .startDate(true) - .build() - ) - .build() - ) + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .type(Provider.AuthenticationMethod.Type.ASSISTED) .build() ) .beta(true) - .displayName("display_name") .icon("icon") .logo("logo") .manual(true) .mfaRequired(true) .primaryColor("primary_color") - .addProduct("string") .build() val roundtrippedProvider = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RequestForwardingForwardParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RequestForwardingForwardParamsTest.kt index 38808fb4..25628829 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RequestForwardingForwardParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RequestForwardingForwardParamsTest.kt @@ -11,11 +11,19 @@ internal class RequestForwardingForwardParamsTest { @Test fun create() { RequestForwardingForwardParams.builder() - .method("POST") - .route("/people/search") - .data(null) - .headers(JsonValue.from(mapOf("content-type" to "application/json"))) - .params(JsonValue.from(mapOf("showInactive" to true, "humanReadable" to true))) + .method("method") + .route("route") + .data("data") + .headers( + RequestForwardingForwardParams.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .params( + RequestForwardingForwardParams.Params.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() } @@ -23,32 +31,48 @@ internal class RequestForwardingForwardParamsTest { fun body() { val params = RequestForwardingForwardParams.builder() - .method("POST") - .route("/people/search") - .data(null) - .headers(JsonValue.from(mapOf("content-type" to "application/json"))) - .params(JsonValue.from(mapOf("showInactive" to true, "humanReadable" to true))) + .method("method") + .route("route") + .data("data") + .headers( + RequestForwardingForwardParams.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .params( + RequestForwardingForwardParams.Params.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() val body = params._body() - assertThat(body.method()).isEqualTo("POST") - assertThat(body.route()).isEqualTo("/people/search") - assertThat(body.data()).isEmpty - assertThat(body._headers_()) - .isEqualTo(JsonValue.from(mapOf("content-type" to "application/json"))) - assertThat(body._params()) - .isEqualTo(JsonValue.from(mapOf("showInactive" to true, "humanReadable" to true))) + assertThat(body.method()).isEqualTo("method") + assertThat(body.route()).isEqualTo("route") + assertThat(body.data()).contains("data") + assertThat(body.headers()) + .contains( + RequestForwardingForwardParams.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.params()) + .contains( + RequestForwardingForwardParams.Params.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test fun bodyWithoutOptionalFields() { val params = - RequestForwardingForwardParams.builder().method("POST").route("/people/search").build() + RequestForwardingForwardParams.builder().method("method").route("route").build() val body = params._body() - assertThat(body.method()).isEqualTo("POST") - assertThat(body.route()).isEqualTo("/people/search") + assertThat(body.method()).isEqualTo("method") + assertThat(body.route()).isEqualTo("route") } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RequestForwardingForwardResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RequestForwardingForwardResponseTest.kt index 2645792c..073a64b2 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RequestForwardingForwardResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RequestForwardingForwardResponseTest.kt @@ -14,34 +14,58 @@ internal class RequestForwardingForwardResponseTest { fun create() { val requestForwardingForwardResponse = RequestForwardingForwardResponse.builder() - .data("data") - .headers(JsonValue.from(mapOf())) .request( RequestForwardingForwardResponse.Request.builder() - .data("data") - .headers(JsonValue.from(mapOf())) .method("method") - .params(JsonValue.from(mapOf())) .route("route") + .data("string") + .headers( + RequestForwardingForwardResponse.Request.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .params( + RequestForwardingForwardResponse.Request.Params.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .statusCode(0L) + .data("data") + .headers( + RequestForwardingForwardResponse.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() - assertThat(requestForwardingForwardResponse.data()).contains("data") - assertThat(requestForwardingForwardResponse._headers()) - .isEqualTo(JsonValue.from(mapOf())) assertThat(requestForwardingForwardResponse.request()) .isEqualTo( RequestForwardingForwardResponse.Request.builder() - .data("data") - .headers(JsonValue.from(mapOf())) .method("method") - .params(JsonValue.from(mapOf())) .route("route") + .data("string") + .headers( + RequestForwardingForwardResponse.Request.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .params( + RequestForwardingForwardResponse.Request.Params.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) assertThat(requestForwardingForwardResponse.statusCode()).isEqualTo(0L) + assertThat(requestForwardingForwardResponse.data()).contains("data") + assertThat(requestForwardingForwardResponse.headers()) + .contains( + RequestForwardingForwardResponse.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test @@ -49,18 +73,30 @@ internal class RequestForwardingForwardResponseTest { val jsonMapper = jsonMapper() val requestForwardingForwardResponse = RequestForwardingForwardResponse.builder() - .data("data") - .headers(JsonValue.from(mapOf())) .request( RequestForwardingForwardResponse.Request.builder() - .data("data") - .headers(JsonValue.from(mapOf())) .method("method") - .params(JsonValue.from(mapOf())) .route("route") + .data("string") + .headers( + RequestForwardingForwardResponse.Request.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .params( + RequestForwardingForwardResponse.Request.Params.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) .statusCode(0L) + .data("data") + .headers( + RequestForwardingForwardResponse.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() val roundtrippedRequestForwardingForwardResponse = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/W42005Test.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/W42005Test.kt index 83299435..4f4ae1cb 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/W42005Test.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/W42005Test.kt @@ -27,7 +27,7 @@ internal class W42005Test { .build() assertThat(w42005.data()) - .contains( + .isEqualTo( W42005.Data.builder() .additionalWithholding(0L) .exemption(W42005.Data.Exemption.EXEMPT) @@ -36,8 +36,8 @@ internal class W42005Test { .totalNumberOfAllowances(0L) .build() ) - assertThat(w42005.type()).contains(W42005.Type.W4_2005) - assertThat(w42005.year()).contains(0.0) + assertThat(w42005.type()).isEqualTo(W42005.Type.W4_2005) + assertThat(w42005.year()).isEqualTo(0.0) } @Test diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/W42020Test.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/W42020Test.kt index 40c7a6f5..6c89c6a7 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/W42020Test.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/W42020Test.kt @@ -30,7 +30,7 @@ internal class W42020Test { .build() assertThat(w42020.data()) - .contains( + .isEqualTo( W42020.Data.builder() .amountForOtherDependents(0L) .amountForQualifyingChildrenUnder17(0L) @@ -42,8 +42,8 @@ internal class W42020Test { .totalClaimDependentAndOtherCredits(0L) .build() ) - assertThat(w42020.type()).contains(W42020.Type.W4_2020) - assertThat(w42020.year()).contains(0.0) + assertThat(w42020.type()).isEqualTo(W42020.Type.W4_2020) + assertThat(w42020.year()).isEqualTo(0.0) } @Test diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncTest.kt index 2c9a0a83..2676d3a3 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncTest.kt @@ -23,10 +23,10 @@ internal class AccessTokenServiceAsyncTest { val createAccessTokenResponseFuture = accessTokenServiceAsync.create( AccessTokenCreateParams.builder() - .code("") - .clientId("6d28c315-5eaa-4071-8ea5-f030eb45edbc") - .clientSecret("") - .redirectUri("https://example.com") + .code("code") + .clientId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .clientSecret("client_secret") + .redirectUri("redirect_uri") .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncTest.kt index fe0ef7f9..8085f5b5 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncTest.kt @@ -24,11 +24,19 @@ internal class RequestForwardingServiceAsyncTest { val responseFuture = requestForwardingServiceAsync.forward( RequestForwardingForwardParams.builder() - .method("POST") - .route("/people/search") - .data(null) - .headers(JsonValue.from(mapOf("content-type" to "application/json"))) - .params(JsonValue.from(mapOf("showInactive" to true, "humanReadable" to true))) + .method("method") + .route("route") + .data("data") + .headers( + RequestForwardingForwardParams.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .params( + RequestForwardingForwardParams.Params.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) 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 7dd78c56..68909572 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 @@ -6,7 +6,6 @@ import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync import com.tryfinch.api.models.JobAutomatedCreateParams import com.tryfinch.api.models.JobAutomatedListParams -import com.tryfinch.api.models.JobAutomatedRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -40,13 +39,7 @@ internal class AutomatedServiceAsyncTest { .build() val automatedServiceAsync = client.jobs().automated() - val automatedAsyncJobFuture = - automatedServiceAsync.retrieve( - JobAutomatedRetrieveParams.builder() - .jobId("job_id") - .entityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val automatedAsyncJobFuture = automatedServiceAsync.retrieve("job_id") val automatedAsyncJob = automatedAsyncJobFuture.get() automatedAsyncJob.validate() @@ -63,11 +56,7 @@ internal class AutomatedServiceAsyncTest { val automatedsFuture = automatedServiceAsync.list( - JobAutomatedListParams.builder() - .entityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .offset(0L) - .build() + JobAutomatedListParams.builder().limit(0L).offset(0L).build() ) val automateds = automatedsFuture.get() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncTest.kt index f3aa0c98..87d73cfa 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncTest.kt @@ -4,7 +4,6 @@ package com.tryfinch.api.services.async.jobs import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync -import com.tryfinch.api.models.JobManualRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -20,13 +19,7 @@ internal class ManualServiceAsyncTest { .build() val manualServiceAsync = client.jobs().manual() - val manualAsyncJobFuture = - manualServiceAsync.retrieve( - JobManualRetrieveParams.builder() - .jobId("job_id") - .entityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val manualAsyncJobFuture = manualServiceAsync.retrieve("job_id") val manualAsyncJob = manualAsyncJobFuture.get() manualAsyncJob.validate() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncTest.kt index e7181ea2..d36f20ad 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncTest.kt @@ -5,7 +5,6 @@ package com.tryfinch.api.services.async.sandbox.jobs import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync import com.tryfinch.api.models.SandboxJobConfiguration -import com.tryfinch.api.models.SandboxJobConfigurationUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -38,13 +37,9 @@ internal class ConfigurationServiceAsyncTest { val sandboxJobConfigurationFuture = configurationServiceAsync.update( - SandboxJobConfigurationUpdateParams.builder() - .sandboxJobConfiguration( - SandboxJobConfiguration.builder() - .completionStatus(SandboxJobConfiguration.CompletionStatus.COMPLETE) - .type(SandboxJobConfiguration.Type.DATA_SYNC_ALL) - .build() - ) + SandboxJobConfiguration.builder() + .completionStatus(SandboxJobConfiguration.CompletionStatus.COMPLETE) + .type(SandboxJobConfiguration.Type.DATA_SYNC_ALL) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceTest.kt index 68a7c439..87839d1d 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceTest.kt @@ -23,10 +23,10 @@ internal class AccessTokenServiceTest { val createAccessTokenResponse = accessTokenService.create( AccessTokenCreateParams.builder() - .code("") + .code("code") .clientId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .clientSecret("") - .redirectUri("https://example.com") + .clientSecret("client_secret") + .redirectUri("redirect_uri") .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceTest.kt index a68eed63..e29c4489 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceTest.kt @@ -24,11 +24,19 @@ internal class RequestForwardingServiceTest { val response = requestForwardingService.forward( RequestForwardingForwardParams.builder() - .method("POST") - .route("/people/search") - .data(null) - .headers(JsonValue.from(mapOf("content-type" to "application/json"))) - .params(JsonValue.from(mapOf("showInactive" to true, "humanReadable" to true))) + .method("method") + .route("route") + .data("data") + .headers( + RequestForwardingForwardParams.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .params( + RequestForwardingForwardParams.Params.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) 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 6b576c1e..e4121bc5 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 @@ -6,7 +6,6 @@ import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClient import com.tryfinch.api.models.JobAutomatedCreateParams import com.tryfinch.api.models.JobAutomatedListParams -import com.tryfinch.api.models.JobAutomatedRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -37,13 +36,7 @@ internal class AutomatedServiceTest { .build() val automatedService = client.jobs().automated() - val automatedAsyncJob = - automatedService.retrieve( - JobAutomatedRetrieveParams.builder() - .jobId("job_id") - .entityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val automatedAsyncJob = automatedService.retrieve("job_id") automatedAsyncJob.validate() } @@ -58,13 +51,7 @@ internal class AutomatedServiceTest { val automatedService = client.jobs().automated() val automateds = - automatedService.list( - JobAutomatedListParams.builder() - .entityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .limit(0L) - .offset(0L) - .build() - ) + automatedService.list(JobAutomatedListParams.builder().limit(0L).offset(0L).build()) automateds.validate() } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceTest.kt index b3d4fc55..3ee64260 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceTest.kt @@ -4,7 +4,6 @@ package com.tryfinch.api.services.blocking.jobs import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClient -import com.tryfinch.api.models.JobManualRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -20,13 +19,7 @@ internal class ManualServiceTest { .build() val manualService = client.jobs().manual() - val manualAsyncJob = - manualService.retrieve( - JobManualRetrieveParams.builder() - .jobId("job_id") - .entityId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) + val manualAsyncJob = manualService.retrieve("job_id") manualAsyncJob.validate() } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceTest.kt index 64cd3fad..8232bd41 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceTest.kt @@ -5,7 +5,6 @@ package com.tryfinch.api.services.blocking.sandbox.jobs import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClient import com.tryfinch.api.models.SandboxJobConfiguration -import com.tryfinch.api.models.SandboxJobConfigurationUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -37,13 +36,9 @@ internal class ConfigurationServiceTest { val sandboxJobConfiguration = configurationService.update( - SandboxJobConfigurationUpdateParams.builder() - .sandboxJobConfiguration( - SandboxJobConfiguration.builder() - .completionStatus(SandboxJobConfiguration.CompletionStatus.COMPLETE) - .type(SandboxJobConfiguration.Type.DATA_SYNC_ALL) - .build() - ) + SandboxJobConfiguration.builder() + .completionStatus(SandboxJobConfiguration.CompletionStatus.COMPLETE) + .type(SandboxJobConfiguration.Type.DATA_SYNC_ALL) .build() ) diff --git a/finch-java-proguard-test/build.gradle.kts b/finch-java-proguard-test/build.gradle.kts index e7075df7..93e305a1 100644 --- a/finch-java-proguard-test/build.gradle.kts +++ b/finch-java-proguard-test/build.gradle.kts @@ -37,8 +37,6 @@ val proguardJar by tasks.registering(proguard.gradle.ProGuardTask::class) { outjars(proguardJarPath) printmapping("${layout.buildDirectory.get()}/proguard-mapping.txt") - dontwarn() - val javaHome = System.getProperty("java.home") if (System.getProperty("java.version").startsWith("1.")) { // Before Java 9, the runtime classes were packaged in a single jar file. diff --git a/finch-java-proguard-test/test.pro b/finch-java-proguard-test/test.pro index b7d5198d..d6f82f1a 100644 --- a/finch-java-proguard-test/test.pro +++ b/finch-java-proguard-test/test.pro @@ -5,4 +5,5 @@ -keep class org.junit.** { *; } # Many warnings don't apply for our testing purposes. +-dontnote -dontwarn \ No newline at end of file diff --git a/scripts/fast-format b/scripts/fast-format new file mode 100755 index 00000000..1b3bc473 --- /dev/null +++ b/scripts/fast-format @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +set -euo pipefail + +echo "Script started with $# arguments" +echo "Arguments: $*" +echo "Script location: $(dirname "$0")" + +cd "$(dirname "$0")/.." +echo "Changed to directory: $(pwd)" + +if [ $# -eq 0 ]; then + echo "Usage: $0 [additional-formatter-args...]" + echo "The file should contain one file path per line" + exit 1 +fi + +FILE_LIST="$1" + +echo "Looking for file: $FILE_LIST" + +if [ ! -f "$FILE_LIST" ]; then + echo "Error: File '$FILE_LIST' not found" + exit 1 +fi + +if ! command -v ktfmt-fast-format &> /dev/null; then + echo "Error: ktfmt-fast-format not found" + exit 1 +fi + +# Process Kotlin files +echo "==> Looking for Kotlin files" +kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/' || true) +echo "==> Done looking for Kotlin files" + +if [[ -n "$kt_files" ]]; then + echo "==> will format Kotlin files" + echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt-fast-format --kotlinlang-style "$@" +else + echo "No Kotlin files to format -- expected outcome during incremental formatting" +fi + +# TODO(mbudayr): support palantir-java-format +# Process Java files +# grep -E '\.java$' "$FILE_LIST" | grep -v './buildSrc/build/' | tr '\n' '\0' | xargs -0 -r palantir-java-format --palantir --replace "$@"