diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ff1c7af5..127ac87b 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.3.0" + ".": "4.0.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 3f80b45c..119fd722 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 40 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-77520f5037161db86208e3a9d3f36f39e971a8ee10b1d9972a22c084fcf21845.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-97bf4795deec23d1bfd3b0b5fd77c2a93c87f10e5fa3375ab30f4a877be97f53.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 77bea789..a564be15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,72 @@ # Changelog +## 4.0.0 (2025-02-05) + +Full Changelog: [v3.3.0...v4.0.0](https://github.com/Finch-API/finch-api-java/compare/v3.3.0...v4.0.0) + +### ⚠ BREAKING CHANGES + +* **client:** better union variant method and variable names ([#410](https://github.com/Finch-API/finch-api-java/issues/410)) + +### Features + +* **api:** api update ([#418](https://github.com/Finch-API/finch-api-java/issues/418)) ([1e88c1b](https://github.com/Finch-API/finch-api-java/commit/1e88c1b166a5a153372ee6bc5a6e1693822cc9fa)) +* **api:** api update ([#426](https://github.com/Finch-API/finch-api-java/issues/426)) ([77e6a73](https://github.com/Finch-API/finch-api-java/commit/77e6a7383806b0615a3bca5e25094b54cf427420)) +* **api:** api update ([#427](https://github.com/Finch-API/finch-api-java/issues/427)) ([daf9de7](https://github.com/Finch-API/finch-api-java/commit/daf9de711530f47caf431d316f682c82139cd26a)) +* **client:** add `_queryParams` and `_headers` methods ([#419](https://github.com/Finch-API/finch-api-java/issues/419)) ([2a3c658](https://github.com/Finch-API/finch-api-java/commit/2a3c6582c5179b922d9729535c47e9383efcb620)) +* **client:** add `close` method ([#412](https://github.com/Finch-API/finch-api-java/issues/412)) ([d9b722b](https://github.com/Finch-API/finch-api-java/commit/d9b722b1d27703dd7bb5a26b962ab7df102a030b)) +* **client:** better union variant method and variable names ([#410](https://github.com/Finch-API/finch-api-java/issues/410)) ([d0db606](https://github.com/Finch-API/finch-api-java/commit/d0db606cfd7914c13915861498bd32340ff9f9f3)) +* **client:** send client-side timeout headers ([#428](https://github.com/Finch-API/finch-api-java/issues/428)) ([d17227d](https://github.com/Finch-API/finch-api-java/commit/d17227dcce3a87afae057009635f749908e6397f)) + + +### Bug Fixes + +* **api:** add missing `@MustBeClosed` annotations ([#429](https://github.com/Finch-API/finch-api-java/issues/429)) ([abe41ab](https://github.com/Finch-API/finch-api-java/commit/abe41abe42c306d6c19df15151dcea02908a4e98)) +* **api:** switch `CompletableFuture<Void>` to `CompletableFuture` ([abe41ab](https://github.com/Finch-API/finch-api-java/commit/abe41abe42c306d6c19df15151dcea02908a4e98)) +* **client:** add missing validation calls on response ([abe41ab](https://github.com/Finch-API/finch-api-java/commit/abe41abe42c306d6c19df15151dcea02908a4e98)) +* **client:** always provide a body for `PATCH` methods ([abe41ab](https://github.com/Finch-API/finch-api-java/commit/abe41abe42c306d6c19df15151dcea02908a4e98)) +* **client:** compiler errors ([#422](https://github.com/Finch-API/finch-api-java/issues/422)) ([2694656](https://github.com/Finch-API/finch-api-java/commit/2694656b93676e6758c71fc55beccf74fe495e00)) +* **client:** don't leak responses when retrying ([#423](https://github.com/Finch-API/finch-api-java/issues/423)) ([1c877e6](https://github.com/Finch-API/finch-api-java/commit/1c877e649c7907d3140dbd1e5d437b45db01672f)) +* **client:** make service impl constructors internal ([#405](https://github.com/Finch-API/finch-api-java/issues/405)) ([38d434d](https://github.com/Finch-API/finch-api-java/commit/38d434d35ed917af6b4e699db6a7928e15f898a3)) +* **client:** make some classes and constructors non-public ([#416](https://github.com/Finch-API/finch-api-java/issues/416)) ([0a1b627](https://github.com/Finch-API/finch-api-java/commit/0a1b627cb52cf11b76f497ad379e98e30e1a9559)) + + +### Chores + +* add max retries to test ([#411](https://github.com/Finch-API/finch-api-java/issues/411)) ([e3831a7](https://github.com/Finch-API/finch-api-java/commit/e3831a7eec0fda1e05cc29ce5fbd77a23b05f308)) +* **internal:** add and tweak check functions ([#401](https://github.com/Finch-API/finch-api-java/issues/401)) ([a08f4ba](https://github.com/Finch-API/finch-api-java/commit/a08f4ba13b492b408550783c8306668039963250)) +* **internal:** codegen related update ([#394](https://github.com/Finch-API/finch-api-java/issues/394)) ([94b4589](https://github.com/Finch-API/finch-api-java/commit/94b45894c92283b2f24a8c0c9938dc456203e7e9)) +* **internal:** codegen related update ([#425](https://github.com/Finch-API/finch-api-java/issues/425)) ([84cd37e](https://github.com/Finch-API/finch-api-java/commit/84cd37eb0660362f57d92404e4ca17ad4c8340fa)) +* **internal:** extract a `checkRequired` function ([#400](https://github.com/Finch-API/finch-api-java/issues/400)) ([f0fec86](https://github.com/Finch-API/finch-api-java/commit/f0fec86853463134ddda5385e801c568de18487c)) +* **internal:** fix up root `build.gradle.kts` formatting ([#396](https://github.com/Finch-API/finch-api-java/issues/396)) ([595151c](https://github.com/Finch-API/finch-api-java/commit/595151c73573c47ce6d789431c35f3ad1665eac6)) +* **internal:** improve `RetryingHttpClientTest` ([#421](https://github.com/Finch-API/finch-api-java/issues/421)) ([6f997fe](https://github.com/Finch-API/finch-api-java/commit/6f997fed271b1d2ffab8c54c365d32993ea4b0b1)) +* **internal:** minor formatting/style changes ([abe41ab](https://github.com/Finch-API/finch-api-java/commit/abe41abe42c306d6c19df15151dcea02908a4e98)) +* **internal:** remove some unnecessary `constructor` keywords ([0a1b627](https://github.com/Finch-API/finch-api-java/commit/0a1b627cb52cf11b76f497ad379e98e30e1a9559)) +* **internal:** remove unused Gradle imports ([#397](https://github.com/Finch-API/finch-api-java/issues/397)) ([c5f656d](https://github.com/Finch-API/finch-api-java/commit/c5f656d35f9642c946d18330bec0a453b522f234)) +* **internal:** remove unused or unnecessary Gradle imports ([#398](https://github.com/Finch-API/finch-api-java/issues/398)) ([5d706bc](https://github.com/Finch-API/finch-api-java/commit/5d706bc05046466b2b7a3ee43ec85c21943cb731)) +* **internal:** rename some tests ([abe41ab](https://github.com/Finch-API/finch-api-java/commit/abe41abe42c306d6c19df15151dcea02908a4e98)) +* **internal:** swap `checkNotNull` to `checkRequired` ([#409](https://github.com/Finch-API/finch-api-java/issues/409)) ([4018e4c](https://github.com/Finch-API/finch-api-java/commit/4018e4c4154bba72bb09a8421c1c75128da64c9c)) +* **internal:** tweak client options nullability handling ([a08f4ba](https://github.com/Finch-API/finch-api-java/commit/a08f4ba13b492b408550783c8306668039963250)) +* **internal:** update some gradle formatting ([#399](https://github.com/Finch-API/finch-api-java/issues/399)) ([623b174](https://github.com/Finch-API/finch-api-java/commit/623b1747a63e47b165e18cf5428faa9c9baa8d98)) +* **internal:** upgrade kotlin compiler and gradle ([#403](https://github.com/Finch-API/finch-api-java/issues/403)) ([0d0766b](https://github.com/Finch-API/finch-api-java/commit/0d0766b6c48e7efd60dbb7f3e2306771d307526c)) +* simplify examples involving lists ([#402](https://github.com/Finch-API/finch-api-java/issues/402)) ([4520086](https://github.com/Finch-API/finch-api-java/commit/4520086fb9d7c43ffec2386fa585e3a56107f7ec)) + + +### Documentation + +* `async` and `sync` method comments ([#415](https://github.com/Finch-API/finch-api-java/issues/415)) ([ab65f2f](https://github.com/Finch-API/finch-api-java/commit/ab65f2fe56ddd3199441d48921ef60f94eda85bb)) +* add client documentation ([#414](https://github.com/Finch-API/finch-api-java/issues/414)) ([d4b8051](https://github.com/Finch-API/finch-api-java/commit/d4b805129069eaa3d584abc78274f8b017dce885)) +* add more documentation ([#404](https://github.com/Finch-API/finch-api-java/issues/404)) ([1cef90d](https://github.com/Finch-API/finch-api-java/commit/1cef90d50b2920f67b9455c0b1a1cdad5d86a0d0)) +* builder, enum, and union comments ([#417](https://github.com/Finch-API/finch-api-java/issues/417)) ([1e1e28e](https://github.com/Finch-API/finch-api-java/commit/1e1e28e262030d8a05af6a9c3736f91650bede4f)) +* fix incorrect additional properties info ([#424](https://github.com/Finch-API/finch-api-java/issues/424)) ([856e1c9](https://github.com/Finch-API/finch-api-java/commit/856e1c9f646fb80df8f6751634d6f39ccdf633b7)) +* move up requirements section ([#408](https://github.com/Finch-API/finch-api-java/issues/408)) ([a595f32](https://github.com/Finch-API/finch-api-java/commit/a595f323b1bc0d26ef4ffda2b16f747c7d062660)) +* update readme ([#406](https://github.com/Finch-API/finch-api-java/issues/406)) ([31e854c](https://github.com/Finch-API/finch-api-java/commit/31e854c04ea5f0e9271d40b96e3fb313155de390)) + + +### Refactors + +* **internal:** extract request preparation logic ([2a3c658](https://github.com/Finch-API/finch-api-java/commit/2a3c6582c5179b922d9729535c47e9383efcb620)) + ## 3.3.0 (2025-01-09) Full Changelog: [v3.2.0...v3.3.0](https://github.com/Finch-API/finch-api-java/compare/v3.2.0...v3.3.0) diff --git a/README.md b/README.md index bd7aed71..47531877 100644 --- a/README.md +++ b/README.md @@ -2,46 +2,48 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/3.3.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/4.0.0) -The Finch Java SDK provides convenient access to the Finch REST API from applications written in Java. It includes helper classes with helpful types and documentation for every request and response property. +The Finch Java SDK provides convenient access to the Finch REST API from applications written in Java. The Finch Java SDK is similar to the Finch Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions. It is generated with [Stainless](https://www.stainlessapi.com/). -## Documentation - The REST API documentation can be found [in the Finch Documentation Center](https://developer.tryfinch.com/). --- -## Getting started - -### Install dependencies - -#### Gradle +## Installation +### Gradle + ```kotlin -implementation("com.tryfinch.api:finch-java:3.3.0") +implementation("com.tryfinch.api:finch-java:4.0.0") ``` -#### Maven +### Maven ```xml com.tryfinch.api finch-java - 3.3.0 + 4.0.0 ``` +## Requirements + +This library requires Java 8 or later. + +## Usage + ### Configure the client Use `FinchOkHttpClient.builder()` to configure the client. @@ -130,19 +132,7 @@ See [Pagination](#pagination) below for more information on transparently workin To make a request to the Finch API, you generally build an instance of the appropriate `Params` class. -In [Example: creating a resource](#example-creating-a-resource) above, we used the `HrisDirectoryListParams.builder()` to pass to the `list` method of the `directory` service. - -Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, you can attach them using the `putAdditionalProperty` method. - -```java -import com.tryfinch.api.core.JsonValue; -import com.tryfinch.api.models.HrisDirectoryListParams; - -HrisDirectoryListParams params = HrisDirectoryListParams.builder() - // ... normal properties - .putAdditionalProperty("secret_param", JsonValue.from("4242")) - .build(); -``` +See [Undocumented request params](#undocumented-request-params) for how to send arbitrary parameters. ## Responses @@ -336,18 +326,26 @@ This library is typed for convenient access to the documented API. If you need t ### Undocumented request params -To make requests using undocumented parameters, you can provide or override parameters on the params object while building it. +In [Example: creating a resource](#example-creating-a-resource) above, we used the `HrisDirectoryListParams.builder()` to pass to the `list` method of the `directory` service. + +Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, you can attach them using raw setters: ```java -FooCreateParams address = FooCreateParams.builder() - .id("my_id") - .putAdditionalProperty("secret_prop", JsonValue.from("hello")) +import com.tryfinch.api.core.JsonValue; +import com.tryfinch.api.models.HrisDirectoryListParams; + +HrisDirectoryListParams params = HrisDirectoryListParams.builder() + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) .build(); ``` +You can also use the `putAdditionalProperty` method on nested headers, query params, or body objects. + ### Undocumented response properties -To access undocumented response properties, you can use `res._additionalProperties()` on a response object to get a map of untyped fields of type `Map`. You can then access fields like `._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type. +To access undocumented response properties, you can use `res._additionalProperties()` on a response object to get a map of untyped fields of type `Map`. You can then access fields like `res._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type. ## Logging @@ -375,7 +373,3 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. We are keen for your feedback; please open an [issue](https://www.github.com/Finch-API/finch-api-java/issues) with questions, bugs, or suggestions. - -## Requirements - -This library requires Java 8 or later. diff --git a/build.gradle.kts b/build.gradle.kts index 8134b3c5..4f584e64 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,4 @@ -plugins { - -} - allprojects { group = "com.tryfinch.api" - version = "3.3.0" // x-release-please-version + version = "4.0.0" // x-release-please-version } - - diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 493cb327..8a1d7a10 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,6 +1,6 @@ plugins { `kotlin-dsl` - kotlin("jvm") version "1.9.22" + kotlin("jvm") version "2.1.0" id("com.vanniktech.maven.publish") version "0.28.0" } diff --git a/buildSrc/src/main/kotlin/finch.java.gradle.kts b/buildSrc/src/main/kotlin/finch.java.gradle.kts index 32a150ed..a2c35b93 100644 --- a/buildSrc/src/main/kotlin/finch.java.gradle.kts +++ b/buildSrc/src/main/kotlin/finch.java.gradle.kts @@ -1,9 +1,5 @@ import com.diffplug.gradle.spotless.SpotlessExtension import org.gradle.api.tasks.testing.logging.TestExceptionFormat -import com.vanniktech.maven.publish.JavaLibrary -import com.vanniktech.maven.publish.JavadocJar -import com.vanniktech.maven.publish.MavenPublishBaseExtension -import com.vanniktech.maven.publish.SonatypeHost plugins { `java-library` diff --git a/buildSrc/src/main/kotlin/finch.kotlin.gradle.kts b/buildSrc/src/main/kotlin/finch.kotlin.gradle.kts index 02304634..c431ae27 100644 --- a/buildSrc/src/main/kotlin/finch.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/finch.kotlin.gradle.kts @@ -1,6 +1,5 @@ import com.diffplug.gradle.spotless.SpotlessExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import com.vanniktech.maven.publish.* plugins { id("finch.java") @@ -22,8 +21,12 @@ configure { tasks.withType().configureEach { kotlinOptions { - allWarningsAsErrors = true - freeCompilerArgs = listOf("-Xjvm-default=all", "-Xjdk-release=1.8") + freeCompilerArgs = listOf( + "-Xjvm-default=all", + "-Xjdk-release=1.8", + // Suppress deprecation warnings because we may still reference and test deprecated members. + "-Xsuppress-warning=DEPRECATION" + ) jvmTarget = "1.8" } } diff --git a/buildSrc/src/main/kotlin/finch.publish.gradle.kts b/buildSrc/src/main/kotlin/finch.publish.gradle.kts index dd28e5e0..e193185b 100644 --- a/buildSrc/src/main/kotlin/finch.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/finch.publish.gradle.kts @@ -1,10 +1,3 @@ -import org.gradle.api.publish.PublishingExtension -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.register -import org.gradle.kotlin.dsl.get -import com.vanniktech.maven.publish.JavaLibrary -import com.vanniktech.maven.publish.JavadocJar import com.vanniktech.maven.publish.MavenPublishBaseExtension import com.vanniktech.maven.publish.SonatypeHost @@ -25,7 +18,7 @@ configure { signAllPublications() publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) - this.coordinates(project.group.toString(), project.name, project.version.toString()) + coordinates(project.group.toString(), project.name, project.version.toString()) pom { name.set("API Reference") 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 786e65de..9cb8ed19 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 @@ -22,7 +22,8 @@ class FinchOkHttpClient private constructor() { @JvmStatic fun fromEnv(): FinchClient = builder().fromEnv().build() } - class Builder { + /** A builder for [FinchOkHttpClient]. */ + class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var baseUrl: String = ClientOptions.PRODUCTION_URL 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 9ce013bb..29934ab4 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 @@ -22,7 +22,8 @@ class FinchOkHttpClientAsync private constructor() { @JvmStatic fun fromEnv(): FinchClientAsync = builder().fromEnv().build() } - class Builder { + /** A builder for [FinchOkHttpClientAsync]. */ + class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var baseUrl: String = ClientOptions.PRODUCTION_URL diff --git a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/OkHttpClient.kt b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/OkHttpClient.kt index c34c5d11..cd06aa82 100644 --- a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/OkHttpClient.kt +++ b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/OkHttpClient.kt @@ -1,6 +1,7 @@ package com.tryfinch.api.client.okhttp import com.tryfinch.api.core.RequestOptions +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.HttpClient import com.tryfinch.api.core.http.HttpMethod @@ -30,38 +31,11 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : HttpClient { - private fun getClient(requestOptions: RequestOptions): okhttp3.OkHttpClient { - val clientBuilder = okHttpClient.newBuilder() - - val logLevel = - when (System.getenv("FINCH_LOG")?.lowercase()) { - "info" -> HttpLoggingInterceptor.Level.BASIC - "debug" -> HttpLoggingInterceptor.Level.BODY - else -> null - } - if (logLevel != null) { - clientBuilder.addNetworkInterceptor( - HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } - ) - } - - val timeout = requestOptions.timeout - if (timeout != null) { - clientBuilder - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) - } - - return clientBuilder.build() - } - override fun execute( request: HttpRequest, requestOptions: RequestOptions, ): HttpResponse { - val call = getClient(requestOptions).newCall(request.toRequest()) + val call = newCall(request, requestOptions) return try { call.execute().toResponse() @@ -80,18 +54,18 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val request.body?.run { future.whenComplete { _, _ -> close() } } - val call = getClient(requestOptions).newCall(request.toRequest()) - call.enqueue( - object : Callback { - override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) - } + newCall(request, requestOptions) + .enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } - override fun onFailure(call: Call, e: IOException) { - future.completeExceptionally(FinchIoException("Request failed", e)) + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(FinchIoException("Request failed", e)) + } } - } - ) + ) return future } @@ -102,10 +76,37 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val okHttpClient.cache?.close() } - private fun HttpRequest.toRequest(): Request { + private fun newCall(request: HttpRequest, requestOptions: RequestOptions): Call { + val clientBuilder = okHttpClient.newBuilder() + + val logLevel = + when (System.getenv("FINCH_LOG")?.lowercase()) { + "info" -> HttpLoggingInterceptor.Level.BASIC + "debug" -> HttpLoggingInterceptor.Level.BODY + else -> null + } + if (logLevel != null) { + clientBuilder.addNetworkInterceptor( + HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } + ) + } + + val timeout = requestOptions.timeout + if (timeout != null) { + clientBuilder + .connectTimeout(timeout) + .readTimeout(timeout) + .writeTimeout(timeout) + .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + } + + val client = clientBuilder.build() + return client.newCall(request.toRequest(client)) + } + + private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient): Request { var body: RequestBody? = body?.toRequestBody() - // OkHttpClient always requires a request body for PUT and POST methods. - if (body == null && (method == HttpMethod.PUT || method == HttpMethod.POST)) { + if (body == null && requiresBody(method)) { body = "".toRequestBody() } @@ -114,9 +115,33 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val headers.values(name).forEach { builder.header(name, it) } } + if ( + !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 + ) { + builder.header( + "X-Stainless-Read-Timeout", + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString() + ) + } + if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { + builder.header( + "X-Stainless-Timeout", + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString() + ) + } + return builder.build() } + /** `OkHttpClient` always requires a request body for some methods. */ + private fun requiresBody(method: HttpMethod): Boolean = + when (method) { + HttpMethod.POST, + HttpMethod.PUT, + HttpMethod.PATCH -> true + else -> false + } + private fun HttpRequest.toUrl(): String { url?.let { return it @@ -170,7 +195,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var baseUrl: HttpUrl? = null // The default timeout is 1 minute. @@ -192,7 +217,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) .proxy(proxy) .build(), - checkNotNull(baseUrl) { "`baseUrl` is required but was not set" }, + checkRequired("baseUrl", baseUrl), ) } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClient.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClient.kt index a1518f6a..424046b4 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClient.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClient.kt @@ -14,8 +14,28 @@ import com.tryfinch.api.services.blocking.RequestForwardingService import com.tryfinch.api.services.blocking.SandboxService import com.tryfinch.api.services.blocking.WebhookService +/** + * A client for interacting with the Finch REST API synchronously. You can also switch to + * asynchronous execution via the [async] method. + * + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. + * + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. + */ interface FinchClient { + /** + * Returns a version of this client that uses asynchronous execution. + * + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. + */ fun async(): FinchClientAsync fun accessTokens(): AccessTokenService @@ -67,4 +87,17 @@ interface FinchClient { @JsonProperty("products") val products: List, @JsonProperty("provider_id") val providerId: String, ) + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsync.kt index 6f57c432..fcba9566 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsync.kt @@ -15,8 +15,28 @@ import com.tryfinch.api.services.async.SandboxServiceAsync import com.tryfinch.api.services.async.WebhookServiceAsync import java.util.concurrent.CompletableFuture +/** + * A client for interacting with the Finch REST API asynchronously. You can also switch to + * synchronous execution via the [sync] method. + * + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. + * + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. + */ interface FinchClientAsync { + /** + * Returns a version of this client that uses synchronous execution. + * + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. + */ fun sync(): FinchClient fun accessTokens(): AccessTokenServiceAsync @@ -68,4 +88,17 @@ interface FinchClientAsync { @JsonProperty("products") val products: List, @JsonProperty("provider_id") val providerId: String, ) + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt index 0bfac953..2e0e7395 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt @@ -38,8 +38,7 @@ import com.tryfinch.api.services.async.WebhookServiceAsyncImpl import java.net.URLEncoder import java.util.concurrent.CompletableFuture -class FinchClientAsyncImpl -constructor( +class FinchClientAsyncImpl( private val clientOptions: ClientOptions, ) : FinchClientAsync { @@ -195,4 +194,6 @@ constructor( @JsonProperty("products") val products: List, @JsonProperty("provider_id") val providerId: String, ) + + override fun close() = clientOptions.httpClient.close() } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt index e8cbf482..84439057 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt @@ -37,8 +37,7 @@ import com.tryfinch.api.services.blocking.WebhookService import com.tryfinch.api.services.blocking.WebhookServiceImpl import java.net.URLEncoder -class FinchClientImpl -constructor( +class FinchClientImpl( private val clientOptions: ClientOptions, ) : FinchClient { @@ -184,4 +183,6 @@ constructor( @JsonProperty("products") val products: List, @JsonProperty("provider_id") val providerId: String, ) + + override fun close() = clientOptions.httpClient.close() } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Check.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Check.kt new file mode 100644 index 00000000..38ad8b3e --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Check.kt @@ -0,0 +1,29 @@ +@file:JvmName("Check") + +package com.tryfinch.api.core + +fun checkRequired(name: String, value: T?): T = + checkNotNull(value) { "`$name` is required, but was not set" } + +@JvmSynthetic +internal fun checkLength(name: String, value: String, length: Int): String = + value.also { + check(it.length == length) { "`$name` must have length $length, but was ${it.length}" } + } + +@JvmSynthetic +internal fun checkMinLength(name: String, value: String, minLength: Int): String = + value.also { + check(it.length >= minLength) { + if (minLength == 1) "`$name` must be non-empty, but was empty" + else "`$name` must have at least length $minLength, but was ${it.length}" + } + } + +@JvmSynthetic +internal fun checkMaxLength(name: String, value: String, maxLength: Int): String = + value.also { + check(it.length <= maxLength) { + "`$name` must have at most length $maxLength, but was ${it.length}" + } + } 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 b397c26c..15542787 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 @@ -40,7 +40,8 @@ private constructor( @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() } - class Builder { + /** A builder for [ClientOptions]. */ + class Builder internal constructor() { private var httpClient: HttpClient? = null private var jsonMapper: JsonMapper = jsonMapper() @@ -189,7 +190,7 @@ private constructor( } fun build(): ClientOptions { - checkNotNull(httpClient) { "`httpClient` is required but was not set" } + val httpClient = checkRequired("httpClient", httpClient) val headers = Headers.builder() val queryParams = QueryParams.builder() @@ -220,10 +221,10 @@ private constructor( queryParams.replaceAll(this.queryParams.build()) return ClientOptions( - httpClient!!, + httpClient, PhantomReachableClosingHttpClient( RetryingHttpClient.builder() - .httpClient(httpClient!!) + .httpClient(httpClient) .clock(clock) .maxRetries(maxRetries) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Params.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Params.kt new file mode 100644 index 00000000..37fa6a31 --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Params.kt @@ -0,0 +1,16 @@ +package com.tryfinch.api.core + +import com.tryfinch.api.core.http.Headers +import com.tryfinch.api.core.http.QueryParams + +/** An interface representing parameters passed to a service method. */ +interface Params { + /** The full set of headers in the parameters, including both fixed and additional headers. */ + fun _headers(): Headers + + /** + * The full set of query params in the parameters, including both fixed and additional query + * params. + */ + fun _queryParams(): QueryParams +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/PrepareRequest.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/PrepareRequest.kt new file mode 100644 index 00000000..974ae9d8 --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/PrepareRequest.kt @@ -0,0 +1,24 @@ +@file:JvmName("PrepareRequest") + +package com.tryfinch.api.core + +import com.tryfinch.api.core.http.HttpRequest +import java.util.concurrent.CompletableFuture + +@JvmSynthetic +internal fun HttpRequest.prepare(clientOptions: ClientOptions, params: Params): HttpRequest = + toBuilder() + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params._queryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params._headers()) + .build() + +@JvmSynthetic +internal fun HttpRequest.prepareAsync( + clientOptions: ClientOptions, + params: Params +): CompletableFuture = + // This async version exists to make it easier to add async specific preparation logic in the + // future. + CompletableFuture.completedFuture(prepare(clientOptions, params)) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/RequestOptions.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/RequestOptions.kt index b1706dda..b31943e2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/RequestOptions.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/RequestOptions.kt @@ -23,7 +23,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { + private var responseValidation: Boolean? = null private var timeout: Duration? = null diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Values.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Values.kt index d5b5fa8a..16ad91e7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Values.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Values.kt @@ -117,6 +117,8 @@ sealed class JsonField { is JsonValue -> this } + @JvmSynthetic fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + fun accept(visitor: Visitor): R = when (this) { is KnownValue -> visitor.visitKnown(value) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/Headers.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/Headers.kt index 267dac4e..1a95b473 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/Headers.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/Headers.kt @@ -22,7 +22,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private val map: MutableMap> = TreeMap(String.CASE_INSENSITIVE_ORDER) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/HttpRequest.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/HttpRequest.kt index 314b55ed..c75e9fb9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/HttpRequest.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/HttpRequest.kt @@ -1,5 +1,6 @@ package com.tryfinch.api.core.http +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.toImmutable class HttpRequest @@ -21,7 +22,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var method: HttpMethod? = null private var url: String? = null @@ -134,7 +135,7 @@ private constructor( fun build(): HttpRequest = HttpRequest( - checkNotNull(method) { "`method` is required but was not set" }, + checkRequired("method", method), url, pathSegments.toImmutable(), headers.build(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/QueryParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/QueryParams.kt index 38a46c18..73766d6a 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/QueryParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/QueryParams.kt @@ -21,7 +21,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private val map: MutableMap> = mutableMapOf() private var size: Int = 0 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 d3c26021..29095887 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,7 @@ package com.tryfinch.api.core.http import com.tryfinch.api.core.RequestOptions +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.errors.FinchIoException import java.io.IOException import java.time.Clock @@ -56,15 +57,17 @@ private constructor( } response - } catch (t: Throwable) { - if (++retries > maxRetries || !shouldRetry(t)) { - throw t + } catch (throwable: Throwable) { + if (++retries > maxRetries || !shouldRetry(throwable)) { + throw throwable } null } val backoffMillis = getRetryBackoffMillis(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() Thread.sleep(backoffMillis.toMillis()) } } @@ -112,6 +115,8 @@ private constructor( } val backoffMillis = getRetryBackoffMillis(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() return sleepAsync(backoffMillis.toMillis()).thenCompose { executeWithRetries(requestWithRetryCount, requestOptions) } @@ -222,27 +227,27 @@ private constructor( return Duration.ofNanos((TimeUnit.SECONDS.toNanos(1) * backoffSeconds * jitter).toLong()) } - private fun sleepAsync(millis: Long): CompletableFuture { - val future = CompletableFuture() - TIMER.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - millis - ) - return future - } - companion object { private val TIMER = Timer("RetryingHttpClient", true) + private fun sleepAsync(millis: Long): CompletableFuture { + val future = CompletableFuture() + TIMER.schedule( + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + millis + ) + return future + } + @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var httpClient: HttpClient? = null private var clock: Clock = Clock.systemUTC() @@ -259,7 +264,7 @@ private constructor( fun build(): HttpClient = RetryingHttpClient( - checkNotNull(httpClient) { "`httpClient` is required but was not set" }, + checkRequired("httpClient", httpClient), clock, maxRetries, idempotencyHeader, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/errors/FinchError.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/errors/FinchError.kt index da8d7b2e..7a51327d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/errors/FinchError.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/errors/FinchError.kt @@ -30,7 +30,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [FinchError]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() 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 726764c7..c45bcbb2 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 @@ -11,6 +11,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -20,11 +22,11 @@ import java.util.Optional /** Exchange the authorization code for an access token */ class AccessTokenCreateParams -constructor( +private constructor( private val body: AccessTokenCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun code(): String = body.code() @@ -48,11 +50,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): AccessTokenCreateBody = body + @JvmSynthetic internal fun _body(): AccessTokenCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect class AccessTokenCreateBody @@ -103,13 +105,15 @@ constructor( private var validated: Boolean = false fun validate(): AccessTokenCreateBody = apply { - if (!validated) { - code() - clientId() - clientSecret() - redirectUri() - validated = true + if (validated) { + return@apply } + + code() + clientId() + clientSecret() + redirectUri() + validated = true } fun toBuilder() = Builder().from(this) @@ -119,7 +123,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AccessTokenCreateBody]. */ + class Builder internal constructor() { private var code: JsonField? = null private var clientId: JsonField = JsonMissing.of() @@ -177,7 +182,7 @@ constructor( fun build(): AccessTokenCreateBody = AccessTokenCreateBody( - checkNotNull(code) { "`code` is required but was not set" }, + checkRequired("code", code), clientId, clientSecret, redirectUri, @@ -210,8 +215,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AccessTokenCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: AccessTokenCreateBody.Builder = AccessTokenCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() 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 253bb585..030c0f24 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -48,13 +49,13 @@ private constructor( fun accessToken(): String = accessToken.getRequired("access_token") /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - fun accountId(): String = accountId.getRequired("account_id") + @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") fun authenticationType(): AuthenticationType = authenticationType.getRequired("authentication_type") /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - fun companyId(): String = companyId.getRequired("company_id") + @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") /** The ID of the new connection */ fun connectionId(): String = connectionId.getRequired("connection_id") @@ -69,14 +70,20 @@ private constructor( fun _accessToken(): JsonField = accessToken /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId @JsonProperty("authentication_type") @ExcludeMissing fun _authenticationType(): JsonField = authenticationType /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId /** The ID of the new connection */ @JsonProperty("connection_id") @@ -95,16 +102,18 @@ private constructor( private var validated: Boolean = false fun validate(): AccountCreateResponse = apply { - if (!validated) { - accessToken() - accountId() - authenticationType() - companyId() - connectionId() - products() - providerId() - validated = true + if (validated) { + return@apply } + + accessToken() + accountId() + authenticationType() + companyId() + connectionId() + products() + providerId() + validated = true } fun toBuilder() = Builder().from(this) @@ -114,7 +123,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AccountCreateResponse]. */ + class Builder internal constructor() { private var accessToken: JsonField? = null private var accountId: JsonField? = null @@ -142,9 +152,11 @@ private constructor( fun accessToken(accessToken: JsonField) = apply { this.accessToken = accessToken } /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ + @Deprecated("deprecated") fun accountId(accountId: String) = accountId(JsonField.of(accountId)) /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ + @Deprecated("deprecated") fun accountId(accountId: JsonField) = apply { this.accountId = accountId } fun authenticationType(authenticationType: AuthenticationType) = @@ -155,9 +167,11 @@ private constructor( } /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ + @Deprecated("deprecated") fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ + @Deprecated("deprecated") fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** The ID of the new connection */ @@ -214,16 +228,13 @@ private constructor( fun build(): AccountCreateResponse = AccountCreateResponse( - checkNotNull(accessToken) { "`accessToken` is required but was not set" }, - checkNotNull(accountId) { "`accountId` is required but was not set" }, - checkNotNull(authenticationType) { - "`authenticationType` is required but was not set" - }, - checkNotNull(companyId) { "`companyId` is required but was not set" }, - checkNotNull(connectionId) { "`connectionId` is required but was not set" }, - checkNotNull(products) { "`products` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(providerId) { "`providerId` is required but was not set" }, + checkRequired("accessToken", accessToken), + checkRequired("accountId", accountId), + checkRequired("authenticationType", authenticationType), + checkRequired("companyId", companyId), + checkRequired("connectionId", connectionId), + checkRequired("products", products).map { it.toImmutable() }, + checkRequired("providerId", providerId), additionalProperties.toImmutable(), ) } @@ -234,6 +245,14 @@ 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 { @@ -249,6 +268,7 @@ private constructor( @JvmStatic fun of(value: String) = AuthenticationType(JsonField.of(value)) } + /** An enum containing [AuthenticationType]'s known values. */ enum class Known { CREDENTIAL, API_TOKEN, @@ -256,14 +276,34 @@ private constructor( ASSISTED, } + /** + * An enum containing [AuthenticationType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AuthenticationType] 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 { CREDENTIAL, API_TOKEN, OAUTH, ASSISTED, + /** + * An enum member indicating that [AuthenticationType] 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) { CREDENTIAL -> Value.CREDENTIAL @@ -273,6 +313,14 @@ private constructor( 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) { CREDENTIAL -> Known.CREDENTIAL diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountDisconnectParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountDisconnectParams.kt index 4fc38a12..8edd0cba 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountDisconnectParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountDisconnectParams.kt @@ -4,6 +4,7 @@ package com.tryfinch.api.models import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import com.tryfinch.api.core.toImmutable @@ -12,11 +13,11 @@ import java.util.Optional /** Disconnect one or more `access_token`s from your application. */ class AccountDisconnectParams -constructor( +private constructor( private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { fun _additionalHeaders(): Headers = additionalHeaders @@ -25,12 +26,12 @@ constructor( fun _additionalBodyProperties(): Map = additionalBodyProperties @JvmSynthetic - internal fun getBody(): Optional> = + internal fun _body(): Optional> = Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -39,8 +40,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AccountDisconnectParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountIntrospectParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountIntrospectParams.kt index c2e0cc27..0f3ddc95 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountIntrospectParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountIntrospectParams.kt @@ -3,24 +3,25 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import java.util.Objects /** Read account information associated with an `access_token` */ class AccountIntrospectParams -constructor( +private constructor( private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -29,8 +30,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [AccountIntrospectParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 c01ee175..7b811c69 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -42,13 +43,13 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - fun accountId(): String = accountId.getRequired("account_id") + @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - fun companyId(): String = companyId.getRequired("company_id") + @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") /** Unique Finch ID of the connection associated with the webhook event. */ fun connectionId(): Optional = @@ -62,13 +63,19 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ @JsonProperty("connection_id") @@ -93,14 +100,16 @@ private constructor( private var validated: Boolean = false fun validate(): AccountUpdateEvent = apply { - if (!validated) { - accountId() - companyId() - connectionId() - data().map { it.validate() } - eventType() - validated = true + if (validated) { + return@apply } + + accountId() + companyId() + connectionId() + data().ifPresent { it.validate() } + eventType() + validated = true } fun toBuilder() = Builder().from(this) @@ -110,7 +119,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AccountUpdateEvent]. */ + class Builder internal constructor() { private var accountId: JsonField? = null private var companyId: JsonField? = null @@ -133,24 +143,28 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: String) = accountId(JsonField.of(accountId)) /** * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: JsonField) = apply { this.accountId = accountId } /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** Unique Finch ID of the connection associated with the webhook event. */ @@ -190,8 +204,8 @@ private constructor( fun build(): AccountUpdateEvent = AccountUpdateEvent( - checkNotNull(accountId) { "`accountId` is required but was not set" }, - checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkRequired("accountId", accountId), + checkRequired("companyId", companyId), connectionId, data, eventType, @@ -233,11 +247,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - authenticationMethod().validate() - status() - validated = true + if (validated) { + return@apply } + + authenticationMethod().validate() + status() + validated = true } fun toBuilder() = Builder().from(this) @@ -247,7 +263,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { private var authenticationMethod: JsonField? = null private var status: JsonField? = null @@ -293,10 +310,8 @@ private constructor( fun build(): Data = Data( - checkNotNull(authenticationMethod) { - "`authenticationMethod` is required but was not set" - }, - checkNotNull(status) { "`status` is required but was not set" }, + checkRequired("authenticationMethod", authenticationMethod), + checkRequired("status", status), additionalProperties.toImmutable(), ) } @@ -355,12 +370,14 @@ private constructor( private var validated: Boolean = false fun validate(): AuthenticationMethod = apply { - if (!validated) { - benefitsSupport().map { it.validate() } - supportedFields().map { it.validate() } - type() - validated = true + if (validated) { + return@apply } + + benefitsSupport().ifPresent { it.validate() } + supportedFields().ifPresent { it.validate() } + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -370,7 +387,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AuthenticationMethod]. */ + class Builder internal constructor() { private var benefitsSupport: JsonField = JsonMissing.of() private var supportedFields: JsonField = JsonMissing.of() @@ -543,16 +561,18 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedFields = apply { - if (!validated) { - company().map { it.validate() } - directory().map { it.validate() } - employment().map { it.validate() } - individual().map { it.validate() } - payGroup().map { it.validate() } - payStatement().map { it.validate() } - payment().map { it.validate() } - validated = true + 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 toBuilder() = Builder().from(this) @@ -562,7 +582,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedFields]. */ + class Builder internal constructor() { private var company: JsonField = JsonMissing.of() private var directory: JsonField = JsonMissing.of() @@ -767,18 +788,20 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedCompanyFields = apply { - if (!validated) { - id() - accounts().map { it.validate() } - departments().map { it.validate() } - ein() - entity().map { it.validate() } - legalName() - locations().map { it.validate() } - primaryEmail() - primaryPhoneNumber() - validated = true - } + 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 toBuilder() = Builder().from(this) @@ -788,7 +811,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedCompanyFields]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var accounts: JsonField = JsonMissing.of() @@ -971,14 +995,16 @@ private constructor( private var validated: Boolean = false fun validate(): Accounts = apply { - if (!validated) { - accountName() - accountNumber() - accountType() - institutionName() - routingNumber() - validated = true + if (validated) { + return@apply } + + accountName() + accountNumber() + accountType() + institutionName() + routingNumber() + validated = true } fun toBuilder() = Builder().from(this) @@ -988,7 +1014,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Accounts]. */ + class Builder internal constructor() { private var accountName: JsonField = JsonMissing.of() private var accountNumber: JsonField = JsonMissing.of() @@ -1128,11 +1155,13 @@ private constructor( private var validated: Boolean = false fun validate(): Departments = apply { - if (!validated) { - name() - parent().map { it.validate() } - validated = true + if (validated) { + return@apply } + + name() + parent().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -1142,7 +1171,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Departments]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var parent: JsonField = JsonMissing.of() @@ -1222,10 +1252,12 @@ private constructor( private var validated: Boolean = false fun validate(): Parent = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -1235,7 +1267,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Parent]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = @@ -1349,11 +1382,13 @@ private constructor( private var validated: Boolean = false fun validate(): Entity = apply { - if (!validated) { - subtype() - type() - validated = true + if (validated) { + return@apply } + + subtype() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1363,7 +1398,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entity]. */ + class Builder internal constructor() { private var subtype: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -1509,15 +1545,17 @@ private constructor( private var validated: Boolean = false fun validate(): Locations = apply { - if (!validated) { - city() - country() - line1() - line2() - postalCode() - state() - validated = true + if (validated) { + return@apply } + + city() + country() + line1() + line2() + postalCode() + state() + validated = true } fun toBuilder() = Builder().from(this) @@ -1527,7 +1565,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Locations]. */ + class Builder internal constructor() { private var city: JsonField = JsonMissing.of() private var country: JsonField = JsonMissing.of() @@ -1683,11 +1722,13 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedDirectoryFields = apply { - if (!validated) { - individuals().map { it.validate() } - paging().map { it.validate() } - validated = true + if (validated) { + return@apply } + + individuals().ifPresent { it.validate() } + paging().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -1697,7 +1738,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedDirectoryFields]. */ + class Builder internal constructor() { private var individuals: JsonField = JsonMissing.of() private var paging: JsonField = JsonMissing.of() @@ -1837,16 +1879,18 @@ private constructor( private var validated: Boolean = false fun validate(): Individuals = apply { - if (!validated) { - id() - department() - firstName() - isActive() - lastName() - manager().map { it.validate() } - middleName() - validated = true + if (validated) { + return@apply } + + id() + department() + firstName() + isActive() + lastName() + manager().ifPresent { it.validate() } + middleName() + validated = true } fun toBuilder() = Builder().from(this) @@ -1856,7 +1900,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Individuals]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var department: JsonField = JsonMissing.of() @@ -1982,10 +2027,12 @@ private constructor( private var validated: Boolean = false fun validate(): Manager = apply { - if (!validated) { - id() - validated = true + if (validated) { + return@apply } + + id() + validated = true } fun toBuilder() = Builder().from(this) @@ -1995,7 +2042,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Manager]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = @@ -2111,11 +2159,13 @@ private constructor( private var validated: Boolean = false fun validate(): Paging = apply { - if (!validated) { - count() - offset() - validated = true + if (validated) { + return@apply } + + count() + offset() + validated = true } fun toBuilder() = Builder().from(this) @@ -2125,7 +2175,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Paging]. */ + class Builder internal constructor() { private var count: JsonField = JsonMissing.of() private var offset: JsonField = JsonMissing.of() @@ -2392,26 +2443,28 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedEmploymentFields = apply { - if (!validated) { - id() - classCode() - customFields() - department().map { it.validate() } - employment().map { it.validate() } - employmentStatus() - endDate() - firstName() - income().map { it.validate() } - incomeHistory() - isActive() - lastName() - location().map { it.validate() } - manager().map { it.validate() } - middleName() - startDate() - title() - validated = true - } + 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 toBuilder() = Builder().from(this) @@ -2421,7 +2474,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedEmploymentFields]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var classCode: JsonField = JsonMissing.of() @@ -2633,10 +2687,12 @@ private constructor( private var validated: Boolean = false fun validate(): Department = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -2646,7 +2702,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Department]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = @@ -2741,11 +2798,13 @@ private constructor( private var validated: Boolean = false fun validate(): Employment = apply { - if (!validated) { - subtype() - type() - validated = true + if (validated) { + return@apply } + + subtype() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -2755,7 +2814,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Employment]. */ + class Builder internal constructor() { private var subtype: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -2872,12 +2932,14 @@ private constructor( private var validated: Boolean = false fun validate(): Income = apply { - if (!validated) { - amount() - currency() - unit() - validated = true + if (validated) { + return@apply } + + amount() + currency() + unit() + validated = true } fun toBuilder() = Builder().from(this) @@ -2887,7 +2949,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Income]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -3040,15 +3103,17 @@ private constructor( private var validated: Boolean = false fun validate(): Location = apply { - if (!validated) { - city() - country() - line1() - line2() - postalCode() - state() - validated = true + if (validated) { + return@apply } + + city() + country() + line1() + line2() + postalCode() + state() + validated = true } fun toBuilder() = Builder().from(this) @@ -3058,7 +3123,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Location]. */ + class Builder internal constructor() { private var city: JsonField = JsonMissing.of() private var country: JsonField = JsonMissing.of() @@ -3184,10 +3250,12 @@ private constructor( private var validated: Boolean = false fun validate(): Manager = apply { - if (!validated) { - id() - validated = true + if (validated) { + return@apply } + + id() + validated = true } fun toBuilder() = Builder().from(this) @@ -3197,7 +3265,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Manager]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = @@ -3410,22 +3479,24 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedIndividualFields = apply { - if (!validated) { - id() - dob() - emails().map { it.validate() } - encryptedSsn() - ethnicity() - firstName() - gender() - lastName() - middleName() - phoneNumbers().map { it.validate() } - preferredName() - residence().map { it.validate() } - ssn() - validated = true - } + 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 toBuilder() = Builder().from(this) @@ -3435,7 +3506,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedIndividualFields]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var dob: JsonField = JsonMissing.of() @@ -3617,11 +3689,13 @@ private constructor( private var validated: Boolean = false fun validate(): Emails = apply { - if (!validated) { - data() - type() - validated = true + if (validated) { + return@apply } + + data() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -3631,7 +3705,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Emails]. */ + class Builder internal constructor() { private var data: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -3733,11 +3808,13 @@ private constructor( private var validated: Boolean = false fun validate(): PhoneNumbers = apply { - if (!validated) { - data() - type() - validated = true + if (validated) { + return@apply } + + data() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -3747,7 +3824,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PhoneNumbers]. */ + class Builder internal constructor() { private var data: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -3892,15 +3970,17 @@ private constructor( private var validated: Boolean = false fun validate(): Residence = apply { - if (!validated) { - city() - country() - line1() - line2() - postalCode() - state() - validated = true + if (validated) { + return@apply } + + city() + country() + line1() + line2() + postalCode() + state() + validated = true } fun toBuilder() = Builder().from(this) @@ -3910,7 +3990,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Residence]. */ + class Builder internal constructor() { private var city: JsonField = JsonMissing.of() private var country: JsonField = JsonMissing.of() @@ -4080,13 +4161,15 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedPayGroupFields = apply { - if (!validated) { - id() - individualIds() - name() - payFrequencies() - validated = true + if (validated) { + return@apply } + + id() + individualIds() + name() + payFrequencies() + validated = true } fun toBuilder() = Builder().from(this) @@ -4096,7 +4179,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedPayGroupFields]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var individualIds: JsonField = JsonMissing.of() @@ -4223,11 +4307,13 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedPayStatementFields = apply { - if (!validated) { - paging().map { it.validate() } - payStatements().map { it.validate() } - validated = true + if (validated) { + return@apply } + + paging().ifPresent { it.validate() } + payStatements().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -4237,7 +4323,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedPayStatementFields]. */ + class Builder internal constructor() { private var paging: JsonField = JsonMissing.of() private var payStatements: JsonField = JsonMissing.of() @@ -4329,11 +4416,13 @@ private constructor( private var validated: Boolean = false fun validate(): Paging = apply { - if (!validated) { - count() - offset() - validated = true + if (validated) { + return@apply } + + count() + offset() + validated = true } fun toBuilder() = Builder().from(this) @@ -4343,7 +4432,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Paging]. */ + class Builder internal constructor() { private var count: JsonField? = null private var offset: JsonField? = null @@ -4389,8 +4479,8 @@ private constructor( fun build(): Paging = Paging( - checkNotNull(count) { "`count` is required but was not set" }, - checkNotNull(offset) { "`offset` is required but was not set" }, + checkRequired("count", count), + checkRequired("offset", offset), additionalProperties.toImmutable(), ) } @@ -4535,19 +4625,21 @@ private constructor( private var validated: Boolean = false fun validate(): PayStatements = apply { - if (!validated) { - earnings().map { it.validate() } - employeeDeductions().map { it.validate() } - employerContributions().map { it.validate() } - grossPay() - individualId() - netPay() - paymentMethod() - taxes().map { it.validate() } - totalHours() - type() - validated = true + 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 toBuilder() = Builder().from(this) @@ -4557,7 +4649,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PayStatements]. */ + class Builder internal constructor() { private var earnings: JsonField = JsonMissing.of() private var employeeDeductions: JsonField = @@ -4745,13 +4838,15 @@ private constructor( private var validated: Boolean = false fun validate(): Earnings = apply { - if (!validated) { - amount() - currency() - name() - type() - validated = true + if (validated) { + return@apply } + + amount() + currency() + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -4761,7 +4856,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Earnings]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -4918,14 +5014,16 @@ private constructor( private var validated: Boolean = false fun validate(): EmployeeDeductions = apply { - if (!validated) { - amount() - currency() - name() - preTax() - type() - validated = true + if (validated) { + return@apply } + + amount() + currency() + name() + preTax() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -4935,7 +5033,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EmployeeDeductions]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -5081,12 +5180,14 @@ private constructor( private var validated: Boolean = false fun validate(): EmployerContributions = apply { - if (!validated) { - amount() - currency() - name() - validated = true + if (validated) { + return@apply } + + amount() + currency() + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -5096,7 +5197,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EmployerContributions]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -5248,14 +5350,16 @@ private constructor( private var validated: Boolean = false fun validate(): Taxes = apply { - if (!validated) { - amount() - currency() - employer() - name() - type() - validated = true + if (validated) { + return@apply } + + amount() + currency() + employer() + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -5265,7 +5369,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Taxes]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -5531,21 +5636,23 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedPaymentFields = apply { - if (!validated) { - id() - companyDebit() - debitDate() - employeeTaxes() - employerTaxes() - grossPay() - individualIds() - netPay() - payDate() - payFrequencies() - payGroupIds() - payPeriod().map { it.validate() } - validated = true - } + if (validated) { + return@apply + } + + id() + companyDebit() + debitDate() + employeeTaxes() + employerTaxes() + grossPay() + individualIds() + netPay() + payDate() + payFrequencies() + payGroupIds() + payPeriod().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -5555,7 +5662,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedPaymentFields]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var companyDebit: JsonField = JsonMissing.of() @@ -5738,11 +5846,13 @@ private constructor( private var validated: Boolean = false fun validate(): PayPeriod = apply { - if (!validated) { - endDate() - startDate() - validated = true + if (validated) { + return@apply } + + endDate() + startDate() + validated = true } fun toBuilder() = Builder().from(this) @@ -5752,7 +5862,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PayPeriod]. */ + class Builder internal constructor() { private var endDate: JsonField = JsonMissing.of() private var startDate: JsonField = JsonMissing.of() @@ -5862,12 +5973,21 @@ private constructor( "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 { @@ -5885,6 +6005,7 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { ASSISTED, CREDENTIAL, @@ -5893,15 +6014,34 @@ private constructor( 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 @@ -5912,6 +6052,15 @@ private constructor( 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 @@ -5979,6 +6128,14 @@ 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 { @@ -5988,21 +6145,49 @@ private constructor( @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) } + /** An enum containing [EventType]'s known values. */ enum class Known { ACCOUNT_UPDATED, } + /** + * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventType] 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 { ACCOUNT_UPDATED, + /** + * An enum member indicating that [EventType] 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) { ACCOUNT_UPDATED -> Value.ACCOUNT_UPDATED 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) { ACCOUNT_UPDATED -> Known.ACCOUNT_UPDATED 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 1883927b..0d82edfa 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -44,13 +45,13 @@ private constructor( ) { /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - fun accountId(): String = accountId.getRequired("account_id") + @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") fun authenticationType(): AuthenticationType = authenticationType.getRequired("authentication_type") /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - fun companyId(): String = companyId.getRequired("company_id") + @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") fun products(): List = products.getRequired("products") @@ -62,14 +63,20 @@ private constructor( Optional.ofNullable(connectionId.getNullable("connection_id")) /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId @JsonProperty("authentication_type") @ExcludeMissing fun _authenticationType(): JsonField = authenticationType /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId @JsonProperty("products") @ExcludeMissing fun _products(): JsonField> = products @@ -88,15 +95,17 @@ private constructor( private var validated: Boolean = false fun validate(): AccountUpdateResponse = apply { - if (!validated) { - accountId() - authenticationType() - companyId() - products() - providerId() - connectionId() - validated = true + if (validated) { + return@apply } + + accountId() + authenticationType() + companyId() + products() + providerId() + connectionId() + validated = true } fun toBuilder() = Builder().from(this) @@ -106,7 +115,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AccountUpdateResponse]. */ + class Builder internal constructor() { private var accountId: JsonField? = null private var authenticationType: JsonField? = null @@ -128,9 +138,11 @@ private constructor( } /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ + @Deprecated("deprecated") fun accountId(accountId: String) = accountId(JsonField.of(accountId)) /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ + @Deprecated("deprecated") fun accountId(accountId: JsonField) = apply { this.accountId = accountId } fun authenticationType(authenticationType: AuthenticationType) = @@ -141,9 +153,11 @@ private constructor( } /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ + @Deprecated("deprecated") fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ + @Deprecated("deprecated") fun companyId(companyId: JsonField) = apply { this.companyId = companyId } fun products(products: List) = products(JsonField.of(products)) @@ -200,14 +214,11 @@ private constructor( fun build(): AccountUpdateResponse = AccountUpdateResponse( - checkNotNull(accountId) { "`accountId` is required but was not set" }, - checkNotNull(authenticationType) { - "`authenticationType` is required but was not set" - }, - checkNotNull(companyId) { "`companyId` is required but was not set" }, - checkNotNull(products) { "`products` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(providerId) { "`providerId` is required but was not set" }, + checkRequired("accountId", accountId), + checkRequired("authenticationType", authenticationType), + checkRequired("companyId", companyId), + checkRequired("products", products).map { it.toImmutable() }, + checkRequired("providerId", providerId), connectionId, additionalProperties.toImmutable(), ) @@ -219,6 +230,14 @@ 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 { @@ -234,6 +253,7 @@ private constructor( @JvmStatic fun of(value: String) = AuthenticationType(JsonField.of(value)) } + /** An enum containing [AuthenticationType]'s known values. */ enum class Known { CREDENTIAL, API_TOKEN, @@ -241,14 +261,34 @@ private constructor( ASSISTED, } + /** + * An enum containing [AuthenticationType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AuthenticationType] 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 { CREDENTIAL, API_TOKEN, OAUTH, ASSISTED, + /** + * An enum member indicating that [AuthenticationType] 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) { CREDENTIAL -> Value.CREDENTIAL @@ -258,6 +298,14 @@ private constructor( 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) { CREDENTIAL -> Known.CREDENTIAL 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 64fb9241..83f762e9 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -33,6 +34,9 @@ private constructor( @JsonProperty("job_url") @ExcludeMissing private val jobUrl: JsonField = JsonMissing.of(), + @JsonProperty("params") + @ExcludeMissing + private val params: JsonField = JsonMissing.of(), @JsonProperty("scheduled_at") @ExcludeMissing private val scheduledAt: JsonField = JsonMissing.of(), @@ -62,6 +66,9 @@ private constructor( /** The url that can be used to retrieve the job status */ fun jobUrl(): String = jobUrl.getRequired("job_url") + /** The input parameters for the job. */ + fun params(): Optional = Optional.ofNullable(params.getNullable("params")) + /** * The datetime a job is scheduled to be run. For scheduled jobs, this datetime can be in the * future if the job has not yet been enqueued. For ad-hoc jobs, this field will be null. @@ -75,7 +82,7 @@ private constructor( fun status(): Status = status.getRequired("status") - /** Only `data_sync_all` currently supported */ + /** The type of automated job */ fun type(): Type = type.getRequired("type") /** The datetime the job completed. */ @@ -97,6 +104,9 @@ private constructor( /** The url that can be used to retrieve the job status */ @JsonProperty("job_url") @ExcludeMissing fun _jobUrl(): JsonField = jobUrl + /** The input parameters for the job. */ + @JsonProperty("params") @ExcludeMissing fun _params(): JsonField = params + /** * The datetime a job is scheduled to be run. For scheduled jobs, this datetime can be in the * future if the job has not yet been enqueued. For ad-hoc jobs, this field will be null. @@ -112,7 +122,7 @@ private constructor( @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - /** Only `data_sync_all` currently supported */ + /** The type of automated job */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @@ -122,17 +132,20 @@ private constructor( private var validated: Boolean = false fun validate(): AutomatedAsyncJob = apply { - if (!validated) { - completedAt() - createdAt() - jobId() - jobUrl() - scheduledAt() - startedAt() - status() - type() - validated = true + if (validated) { + return@apply } + + completedAt() + createdAt() + jobId() + jobUrl() + params().ifPresent { it.validate() } + scheduledAt() + startedAt() + status() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -142,12 +155,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AutomatedAsyncJob]. */ + class Builder internal constructor() { private var completedAt: JsonField? = null private var createdAt: JsonField? = null private var jobId: JsonField? = null private var jobUrl: JsonField? = null + private var params: JsonField? = null private var scheduledAt: JsonField? = null private var startedAt: JsonField? = null private var status: JsonField? = null @@ -160,6 +175,7 @@ private constructor( createdAt = automatedAsyncJob.createdAt jobId = automatedAsyncJob.jobId jobUrl = automatedAsyncJob.jobUrl + params = automatedAsyncJob.params scheduledAt = automatedAsyncJob.scheduledAt startedAt = automatedAsyncJob.startedAt status = automatedAsyncJob.status @@ -206,6 +222,15 @@ private constructor( /** The url that can be used to retrieve the job status */ fun jobUrl(jobUrl: JsonField) = apply { this.jobUrl = jobUrl } + /** The input parameters for the job. */ + fun params(params: Params?) = params(JsonField.ofNullable(params)) + + /** The input parameters for the job. */ + fun params(params: Optional) = params(params.orElse(null)) + + /** The input parameters for the job. */ + fun params(params: JsonField) = apply { this.params = params } + /** * The datetime a job is scheduled to be run. For scheduled jobs, this datetime can be in * the future if the job has not yet been enqueued. For ad-hoc jobs, this field will @@ -244,10 +269,10 @@ private constructor( fun status(status: JsonField) = apply { this.status = status } - /** Only `data_sync_all` currently supported */ + /** The type of automated job */ fun type(type: Type) = type(JsonField.of(type)) - /** Only `data_sync_all` currently supported */ + /** The type of automated job */ fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { @@ -271,24 +296,136 @@ private constructor( fun build(): AutomatedAsyncJob = AutomatedAsyncJob( - checkNotNull(completedAt) { "`completedAt` is required but was not set" }, - checkNotNull(createdAt) { "`createdAt` is required but was not set" }, - checkNotNull(jobId) { "`jobId` is required but was not set" }, - checkNotNull(jobUrl) { "`jobUrl` is required but was not set" }, - checkNotNull(scheduledAt) { "`scheduledAt` is required but was not set" }, - checkNotNull(startedAt) { "`startedAt` is required but was not set" }, - checkNotNull(status) { "`status` is required but was not set" }, - checkNotNull(type) { "`type` is required but was not set" }, + checkRequired("completedAt", completedAt), + checkRequired("createdAt", createdAt), + checkRequired("jobId", jobId), + checkRequired("jobUrl", jobUrl), + checkRequired("params", params), + checkRequired("scheduledAt", scheduledAt), + checkRequired("startedAt", startedAt), + checkRequired("status", status), + checkRequired("type", type), additionalProperties.toImmutable(), ) } + /** The input parameters for the job. */ + @NoAutoDetect + class Params + @JsonCreator + private constructor( + @JsonProperty("individual_id") + @ExcludeMissing + private val individualId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The ID of the individual that the job was completed for. */ + fun individualId(): Optional = + Optional.ofNullable(individualId.getNullable("individual_id")) + + /** The ID of the individual that the job was completed for. */ + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Params = apply { + if (validated) { + return@apply + } + + individualId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Params]. */ + class Builder internal constructor() { + + private var individualId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(params: Params) = apply { + individualId = params.individualId + additionalProperties = params.additionalProperties.toMutableMap() + } + + /** The ID of the individual that the job was completed for. */ + fun individualId(individualId: String) = individualId(JsonField.of(individualId)) + + /** The ID of the individual that the job was completed for. */ + fun individualId(individualId: JsonField) = apply { + this.individualId = individualId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Params = Params(individualId, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Params && individualId == other.individualId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(individualId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Params{individualId=$individualId, additionalProperties=$additionalProperties}" + } + class Status @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 { @@ -308,6 +445,7 @@ private constructor( @JvmStatic fun of(value: String) = Status(JsonField.of(value)) } + /** An enum containing [Status]'s known values. */ enum class Known { PENDING, IN_PROGRESS, @@ -317,6 +455,15 @@ private constructor( PERMISSIONS_ERROR, } + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { PENDING, IN_PROGRESS, @@ -324,9 +471,17 @@ private constructor( ERROR, REAUTH_ERROR, PERMISSIONS_ERROR, + /** An enum member indicating that [Status] 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) { PENDING -> Value.PENDING @@ -338,6 +493,14 @@ private constructor( 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) { PENDING -> Known.PENDING @@ -364,39 +527,80 @@ private constructor( override fun toString() = value.toString() } + /** The type of automated job */ class Type @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @JvmField val DATA_SYNC_ALL = of("data_sync_all") + @JvmField val W4_FORM_EMPLOYEE_SYNC = of("w4_form_employee_sync") + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { DATA_SYNC_ALL, + W4_FORM_EMPLOYEE_SYNC, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { DATA_SYNC_ALL, + W4_FORM_EMPLOYEE_SYNC, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { DATA_SYNC_ALL -> Value.DATA_SYNC_ALL + W4_FORM_EMPLOYEE_SYNC -> Value.W4_FORM_EMPLOYEE_SYNC else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { DATA_SYNC_ALL -> Known.DATA_SYNC_ALL + W4_FORM_EMPLOYEE_SYNC -> Known.W4_FORM_EMPLOYEE_SYNC else -> throw FinchInvalidDataException("Unknown Type: $value") } @@ -420,15 +624,15 @@ private constructor( return true } - return /* spotless:off */ other is AutomatedAsyncJob && completedAt == other.completedAt && createdAt == other.createdAt && jobId == other.jobId && jobUrl == other.jobUrl && scheduledAt == other.scheduledAt && startedAt == other.startedAt && status == other.status && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AutomatedAsyncJob && completedAt == other.completedAt && createdAt == other.createdAt && jobId == other.jobId && jobUrl == other.jobUrl && params == other.params && scheduledAt == other.scheduledAt && startedAt == other.startedAt && status == other.status && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(completedAt, createdAt, jobId, jobUrl, scheduledAt, startedAt, status, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(completedAt, createdAt, jobId, jobUrl, params, scheduledAt, startedAt, status, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "AutomatedAsyncJob{completedAt=$completedAt, createdAt=$createdAt, jobId=$jobId, jobUrl=$jobUrl, scheduledAt=$scheduledAt, startedAt=$startedAt, status=$status, type=$type, additionalProperties=$additionalProperties}" + "AutomatedAsyncJob{completedAt=$completedAt, createdAt=$createdAt, jobId=$jobId, jobUrl=$jobUrl, params=$params, scheduledAt=$scheduledAt, startedAt=$startedAt, status=$status, type=$type, additionalProperties=$additionalProperties}" } 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 ed868f17..ea36d6ea 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import java.util.Objects @@ -67,13 +68,15 @@ private constructor( private var validated: Boolean = false fun validate(): AutomatedCreateResponse = apply { - if (!validated) { - allowedRefreshes() - jobId() - jobUrl() - remainingRefreshes() - validated = true + if (validated) { + return@apply } + + allowedRefreshes() + jobId() + jobUrl() + remainingRefreshes() + validated = true } fun toBuilder() = Builder().from(this) @@ -83,7 +86,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AutomatedCreateResponse]. */ + class Builder internal constructor() { private var allowedRefreshes: JsonField? = null private var jobId: JsonField? = null @@ -151,12 +155,10 @@ private constructor( fun build(): AutomatedCreateResponse = AutomatedCreateResponse( - checkNotNull(allowedRefreshes) { "`allowedRefreshes` is required but was not set" }, - checkNotNull(jobId) { "`jobId` is required but was not set" }, - checkNotNull(jobUrl) { "`jobUrl` is required but was not set" }, - checkNotNull(remainingRefreshes) { - "`remainingRefreshes` is required but was not set" - }, + checkRequired("allowedRefreshes", allowedRefreshes), + checkRequired("jobId", jobId), + checkRequired("jobUrl", jobUrl), + checkRequired("remainingRefreshes", remainingRefreshes), additionalProperties.toImmutable(), ) } 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 74d2e8aa..51555300 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import java.util.Objects @@ -36,13 +37,13 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - fun accountId(): String = accountId.getRequired("account_id") + @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - fun companyId(): String = companyId.getRequired("company_id") + @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") /** Unique Finch ID of the connection associated with the webhook event. */ fun connectionId(): Optional = @@ -52,13 +53,19 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ @JsonProperty("connection_id") @@ -72,12 +79,14 @@ private constructor( private var validated: Boolean = false fun validate(): BaseWebhookEvent = apply { - if (!validated) { - accountId() - companyId() - connectionId() - validated = true + if (validated) { + return@apply } + + accountId() + companyId() + connectionId() + validated = true } fun toBuilder() = Builder().from(this) @@ -87,7 +96,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [BaseWebhookEvent]. */ + class Builder internal constructor() { private var accountId: JsonField? = null private var companyId: JsonField? = null @@ -106,24 +116,28 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: String) = accountId(JsonField.of(accountId)) /** * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: JsonField) = apply { this.accountId = accountId } /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** Unique Finch ID of the connection associated with the webhook event. */ @@ -155,8 +169,8 @@ private constructor( fun build(): BaseWebhookEvent = BaseWebhookEvent( - checkNotNull(accountId) { "`accountId` is required but was not set" }, - checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkRequired("accountId", accountId), + checkRequired("companyId", companyId), connectionId, additionalProperties.toImmutable(), ) 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 60809abe..dc207e16 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 @@ -46,11 +46,13 @@ private constructor( private var validated: Boolean = false fun validate(): BenefitContribution = apply { - if (!validated) { - amount() - type() - validated = true + if (validated) { + return@apply } + + amount() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -60,7 +62,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [BenefitContribution]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -122,12 +125,21 @@ private constructor( ) } + /** Contribution type. */ 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 { @@ -139,17 +151,35 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { FIXED, PERCENT, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { FIXED, PERCENT, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { FIXED -> Value.FIXED @@ -157,6 +187,14 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { FIXED -> Known.FIXED 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 f09e3ce1..6a1b7702 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 @@ -52,11 +52,13 @@ private constructor( private var validated: Boolean = false fun validate(): BenefitFeaturesAndOperations = apply { - if (!validated) { - supportedFeatures().map { it.validate() } - supportedOperations().map { it.validate() } - validated = true + if (validated) { + return@apply } + + supportedFeatures().ifPresent { it.validate() } + supportedOperations().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -66,7 +68,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [BenefitFeaturesAndOperations]. */ + class Builder internal constructor() { private var supportedFeatures: JsonField = JsonMissing.of() private var supportedOperations: JsonField = JsonMissing.of() @@ -230,16 +233,18 @@ private constructor( private var validated: Boolean = false fun validate(): BenefitFeature = apply { - if (!validated) { - annualMaximum() - catchUp() - companyContribution() - description() - employeeDeduction() - frequencies() - hsaContributionLimit() - validated = true + if (validated) { + return@apply } + + annualMaximum() + catchUp() + companyContribution() + description() + employeeDeduction() + frequencies() + hsaContributionLimit() + validated = true } fun toBuilder() = Builder().from(this) @@ -249,7 +254,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [BenefitFeature]. */ + class Builder internal constructor() { private var annualMaximum: JsonField = JsonMissing.of() private var catchUp: JsonField = JsonMissing.of() @@ -491,6 +497,14 @@ 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 { @@ -502,17 +516,40 @@ private constructor( @JvmStatic fun of(value: String) = CompanyContribution(JsonField.of(value)) } + /** An enum containing [CompanyContribution]'s known values. */ enum class Known { FIXED, PERCENT, } + /** + * An enum containing [CompanyContribution]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [CompanyContribution] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { FIXED, PERCENT, + /** + * An enum member indicating that [CompanyContribution] was instantiated with an + * unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { FIXED -> Value.FIXED @@ -520,6 +557,15 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { FIXED -> Known.FIXED @@ -548,6 +594,14 @@ 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 { @@ -559,17 +613,39 @@ private constructor( @JvmStatic fun of(value: String) = EmployeeDeduction(JsonField.of(value)) } + /** An enum containing [EmployeeDeduction]'s known values. */ enum class Known { FIXED, PERCENT, } + /** + * An enum containing [EmployeeDeduction]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [EmployeeDeduction] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { FIXED, PERCENT, + /** + * An enum member indicating that [EmployeeDeduction] was instantiated with an + * unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { FIXED -> Value.FIXED @@ -577,6 +653,15 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { FIXED -> Known.FIXED @@ -605,6 +690,14 @@ 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 { @@ -616,17 +709,40 @@ private constructor( @JvmStatic fun of(value: String) = HsaContributionLimit(JsonField.of(value)) } + /** An enum containing [HsaContributionLimit]'s known values. */ enum class Known { INDIVIDUAL, FAMILY, } + /** + * An enum containing [HsaContributionLimit]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [HsaContributionLimit] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { INDIVIDUAL, FAMILY, + /** + * An enum member indicating that [HsaContributionLimit] was instantiated with an + * unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { INDIVIDUAL -> Value.INDIVIDUAL @@ -634,6 +750,15 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { INDIVIDUAL -> Known.INDIVIDUAL diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitFrequency.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitFrequency.kt index 9a552373..a574a104 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitFrequency.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitFrequency.kt @@ -13,6 +13,13 @@ 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 { @@ -26,19 +33,39 @@ private constructor( @JvmStatic fun of(value: String) = BenefitFrequency(JsonField.of(value)) } + /** An enum containing [BenefitFrequency]'s known values. */ enum class Known { ONE_TIME, EVERY_PAYCHECK, MONTHLY, } + /** + * An enum containing [BenefitFrequency]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BenefitFrequency] 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 { ONE_TIME, EVERY_PAYCHECK, MONTHLY, + /** + * An enum member indicating that [BenefitFrequency] 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) { ONE_TIME -> Value.ONE_TIME @@ -47,6 +74,14 @@ private constructor( 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) { ONE_TIME -> Known.ONE_TIME diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitType.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitType.kt index baaacc1b..dd5abd4c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitType.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitType.kt @@ -7,12 +7,20 @@ import com.tryfinch.api.core.Enum import com.tryfinch.api.core.JsonField import com.tryfinch.api.errors.FinchInvalidDataException +/** Type of benefit. */ class BenefitType @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 { @@ -58,6 +66,7 @@ private constructor( @JvmStatic fun of(value: String) = BenefitType(JsonField.of(value)) } + /** An enum containing [BenefitType]'s known values. */ enum class Known { _401K, _401K_ROTH, @@ -80,6 +89,15 @@ private constructor( CUSTOM_PRE_TAX, } + /** + * An enum containing [BenefitType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BenefitType] 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 { _401K, _401K_ROTH, @@ -100,9 +118,17 @@ private constructor( COMMUTER, CUSTOM_POST_TAX, CUSTOM_PRE_TAX, + /** An enum member indicating that [BenefitType] 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) { _401K -> Value._401K @@ -127,6 +153,14 @@ private constructor( 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) { _401K -> Known._401K 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 814f1c40..80e52ec7 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 @@ -154,21 +154,23 @@ private constructor( private var validated: Boolean = false fun validate(): BenefitsSupport = apply { - if (!validated) { - commuter().map { it.validate() } - customPostTax().map { it.validate() } - customPreTax().map { it.validate() } - fsaDependentCare().map { it.validate() } - fsaMedical().map { it.validate() } - hsaPost().map { it.validate() } - hsaPre().map { it.validate() } - s125Dental().map { it.validate() } - s125Medical().map { it.validate() } - s125Vision().map { it.validate() } - simple().map { it.validate() } - simpleIra().map { it.validate() } - validated = true + if (validated) { + return@apply } + + commuter().ifPresent { it.validate() } + customPostTax().ifPresent { it.validate() } + customPreTax().ifPresent { it.validate() } + fsaDependentCare().ifPresent { it.validate() } + fsaMedical().ifPresent { it.validate() } + hsaPost().ifPresent { it.validate() } + hsaPre().ifPresent { it.validate() } + s125Dental().ifPresent { it.validate() } + s125Medical().ifPresent { it.validate() } + s125Vision().ifPresent { it.validate() } + simple().ifPresent { it.validate() } + simpleIra().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -178,7 +180,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [BenefitsSupport]. */ + class Builder internal constructor() { private var commuter: JsonField = JsonMissing.of() private var customPostTax: JsonField = JsonMissing.of() 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 a1cdba5f..0314da32 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -119,18 +120,20 @@ private constructor( private var validated: Boolean = false fun validate(): Company = apply { - if (!validated) { - id() - accounts().map { it.forEach { it.validate() } } - departments().map { it.forEach { it?.validate() } } - ein() - entity().map { it.validate() } - legalName() - locations().map { it.forEach { it?.validate() } } - primaryEmail() - primaryPhoneNumber() - validated = true + if (validated) { + return@apply } + + id() + accounts().ifPresent { it.forEach { it.validate() } } + departments().ifPresent { it.forEach { it?.validate() } } + ein() + entity().ifPresent { it.validate() } + legalName() + locations().ifPresent { it.forEach { it?.validate() } } + primaryEmail() + primaryPhoneNumber() + validated = true } fun toBuilder() = Builder().from(this) @@ -140,7 +143,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Company]. */ + class Builder internal constructor() { private var id: JsonField? = null private var accounts: JsonField>? = null @@ -318,20 +322,15 @@ private constructor( fun build(): Company = Company( - checkNotNull(id) { "`id` is required but was not set" }, - checkNotNull(accounts) { "`accounts` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(departments) { "`departments` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(ein) { "`ein` is required but was not set" }, - checkNotNull(entity) { "`entity` is required but was not set" }, - checkNotNull(legalName) { "`legalName` is required but was not set" }, - checkNotNull(locations) { "`locations` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(primaryEmail) { "`primaryEmail` is required but was not set" }, - checkNotNull(primaryPhoneNumber) { - "`primaryPhoneNumber` is required but was not set" - }, + checkRequired("id", id), + checkRequired("accounts", accounts).map { it.toImmutable() }, + checkRequired("departments", departments).map { it.toImmutable() }, + checkRequired("ein", ein), + checkRequired("entity", entity), + checkRequired("legalName", legalName), + checkRequired("locations", locations).map { it.toImmutable() }, + checkRequired("primaryEmail", primaryEmail), + checkRequired("primaryPhoneNumber", primaryPhoneNumber), additionalProperties.toImmutable(), ) } @@ -415,14 +414,16 @@ private constructor( private var validated: Boolean = false fun validate(): Account = apply { - if (!validated) { - accountName() - accountNumber() - accountType() - institutionName() - routingNumber() - validated = true + if (validated) { + return@apply } + + accountName() + accountNumber() + accountType() + institutionName() + routingNumber() + validated = true } fun toBuilder() = Builder().from(this) @@ -432,7 +433,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Account]. */ + class Builder internal constructor() { private var accountName: JsonField = JsonMissing.of() private var accountNumber: JsonField = JsonMissing.of() @@ -553,12 +555,21 @@ private constructor( ) } + /** The type of bank account. */ class AccountType @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 { @@ -570,17 +581,38 @@ private constructor( @JvmStatic fun of(value: String) = AccountType(JsonField.of(value)) } + /** An enum containing [AccountType]'s known values. */ enum class Known { CHECKING, SAVINGS, } + /** + * An enum containing [AccountType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AccountType] 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 { CHECKING, SAVINGS, + /** + * An enum member indicating that [AccountType] 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) { CHECKING -> Value.CHECKING @@ -588,6 +620,15 @@ private constructor( 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) { CHECKING -> Known.CHECKING @@ -661,11 +702,13 @@ private constructor( private var validated: Boolean = false fun validate(): Department = apply { - if (!validated) { - name() - parent().map { it.validate() } - validated = true + if (validated) { + return@apply } + + name() + parent().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -675,7 +718,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Department]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var parent: JsonField = JsonMissing.of() @@ -758,10 +802,12 @@ private constructor( private var validated: Boolean = false fun validate(): Parent = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -771,7 +817,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Parent]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -884,11 +931,13 @@ private constructor( private var validated: Boolean = false fun validate(): Entity = apply { - if (!validated) { - subtype() - type() - validated = true + if (validated) { + return@apply } + + subtype() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -898,7 +947,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entity]. */ + class Builder internal constructor() { private var subtype: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -956,12 +1006,21 @@ private constructor( ) } + /** The tax payer subtype of the company. */ class Subtype @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -975,19 +1034,39 @@ private constructor( @JvmStatic fun of(value: String) = Subtype(JsonField.of(value)) } + /** An enum containing [Subtype]'s known values. */ enum class Known { S_CORPORATION, C_CORPORATION, B_CORPORATION, } + /** + * An enum containing [Subtype]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Subtype] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { S_CORPORATION, C_CORPORATION, B_CORPORATION, + /** + * An enum member indicating that [Subtype] was instantiated with an unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { S_CORPORATION -> Value.S_CORPORATION @@ -996,6 +1075,15 @@ private constructor( 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) { S_CORPORATION -> Known.S_CORPORATION @@ -1019,12 +1107,21 @@ private constructor( override fun toString() = value.toString() } + /** The tax payer type of the company. */ 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 { @@ -1046,6 +1143,7 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { LLC, LP, @@ -1056,6 +1154,15 @@ private constructor( COOPERATIVE, } + /** + * 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 { LLC, LP, @@ -1064,9 +1171,17 @@ private constructor( NON_PROFIT, PARTNERSHIP, COOPERATIVE, + /** 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) { LLC -> Value.LLC @@ -1079,6 +1194,15 @@ private constructor( 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) { LLC -> Known.LLC 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 b7d1a27e..9f519ebf 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import java.util.Objects @@ -64,13 +65,15 @@ private constructor( private var validated: Boolean = false fun validate(): CompanyBenefit = apply { - if (!validated) { - benefitId() - description() - frequency() - type() - validated = true + if (validated) { + return@apply } + + benefitId() + description() + frequency() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -80,7 +83,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [CompanyBenefit]. */ + class Builder internal constructor() { private var benefitId: JsonField? = null private var description: JsonField? = null @@ -143,10 +147,10 @@ private constructor( fun build(): CompanyBenefit = CompanyBenefit( - checkNotNull(benefitId) { "`benefitId` is required but was not set" }, - checkNotNull(description) { "`description` is required but was not set" }, - checkNotNull(frequency) { "`frequency` is required but was not set" }, - checkNotNull(type) { "`type` is required but was not set" }, + checkRequired("benefitId", benefitId), + checkRequired("description", description), + checkRequired("frequency", frequency), + checkRequired("type", type), additionalProperties.toImmutable(), ) } 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 e411a503..1b603827 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -42,13 +43,13 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - fun accountId(): String = accountId.getRequired("account_id") + @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - fun companyId(): String = companyId.getRequired("company_id") + @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") /** Unique Finch ID of the connection associated with the webhook event. */ fun connectionId(): Optional = @@ -62,13 +63,19 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ @JsonProperty("connection_id") @@ -93,14 +100,16 @@ private constructor( private var validated: Boolean = false fun validate(): CompanyEvent = apply { - if (!validated) { - accountId() - companyId() - connectionId() - data().map { it.validate() } - eventType() - validated = true + if (validated) { + return@apply } + + accountId() + companyId() + connectionId() + data().ifPresent { it.validate() } + eventType() + validated = true } fun toBuilder() = Builder().from(this) @@ -110,7 +119,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [CompanyEvent]. */ + class Builder internal constructor() { private var accountId: JsonField? = null private var companyId: JsonField? = null @@ -133,24 +143,28 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: String) = accountId(JsonField.of(accountId)) /** * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: JsonField) = apply { this.accountId = accountId } /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** Unique Finch ID of the connection associated with the webhook event. */ @@ -192,8 +206,8 @@ private constructor( fun build(): CompanyEvent = CompanyEvent( - checkNotNull(accountId) { "`accountId` is required but was not set" }, - checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkRequired("accountId", accountId), + checkRequired("companyId", companyId), connectionId, data, eventType, @@ -216,9 +230,11 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - validated = true + if (validated) { + return@apply } + + validated = true } fun toBuilder() = Builder().from(this) @@ -228,7 +244,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @@ -282,6 +299,14 @@ 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 { @@ -291,21 +316,49 @@ private constructor( @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) } + /** An enum containing [EventType]'s known values. */ enum class Known { COMPANY_UPDATED, } + /** + * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventType] 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 { COMPANY_UPDATED, + /** + * An enum member indicating that [EventType] 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) { COMPANY_UPDATED -> Value.COMPANY_UPDATED 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) { COMPANY_UPDATED -> Known.COMPANY_UPDATED 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 50137d22..94219b90 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -112,17 +113,19 @@ private constructor( private var validated: Boolean = false fun validate(): CompanyUpdateResponse = apply { - if (!validated) { - accounts().map { it.forEach { it.validate() } } - departments().map { it.forEach { it?.validate() } } - ein() - entity().map { it.validate() } - legalName() - locations().map { it.forEach { it?.validate() } } - primaryEmail() - primaryPhoneNumber() - validated = true + if (validated) { + return@apply } + + accounts().ifPresent { it.forEach { it.validate() } } + departments().ifPresent { it.forEach { it?.validate() } } + ein() + entity().ifPresent { it.validate() } + legalName() + locations().ifPresent { it.forEach { it?.validate() } } + primaryEmail() + primaryPhoneNumber() + validated = true } fun toBuilder() = Builder().from(this) @@ -132,7 +135,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [CompanyUpdateResponse]. */ + class Builder internal constructor() { private var accounts: JsonField>? = null private var departments: JsonField>? = null @@ -302,19 +306,14 @@ private constructor( fun build(): CompanyUpdateResponse = CompanyUpdateResponse( - checkNotNull(accounts) { "`accounts` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(departments) { "`departments` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(ein) { "`ein` is required but was not set" }, - checkNotNull(entity) { "`entity` is required but was not set" }, - checkNotNull(legalName) { "`legalName` is required but was not set" }, - checkNotNull(locations) { "`locations` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(primaryEmail) { "`primaryEmail` is required but was not set" }, - checkNotNull(primaryPhoneNumber) { - "`primaryPhoneNumber` is required but was not set" - }, + checkRequired("accounts", accounts).map { it.toImmutable() }, + checkRequired("departments", departments).map { it.toImmutable() }, + checkRequired("ein", ein), + checkRequired("entity", entity), + checkRequired("legalName", legalName), + checkRequired("locations", locations).map { it.toImmutable() }, + checkRequired("primaryEmail", primaryEmail), + checkRequired("primaryPhoneNumber", primaryPhoneNumber), additionalProperties.toImmutable(), ) } @@ -398,14 +397,16 @@ private constructor( private var validated: Boolean = false fun validate(): Account = apply { - if (!validated) { - accountName() - accountNumber() - accountType() - institutionName() - routingNumber() - validated = true + if (validated) { + return@apply } + + accountName() + accountNumber() + accountType() + institutionName() + routingNumber() + validated = true } fun toBuilder() = Builder().from(this) @@ -415,7 +416,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Account]. */ + class Builder internal constructor() { private var accountName: JsonField = JsonMissing.of() private var accountNumber: JsonField = JsonMissing.of() @@ -536,12 +538,21 @@ private constructor( ) } + /** The type of bank account. */ class AccountType @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 { @@ -553,17 +564,38 @@ private constructor( @JvmStatic fun of(value: String) = AccountType(JsonField.of(value)) } + /** An enum containing [AccountType]'s known values. */ enum class Known { CHECKING, SAVINGS, } + /** + * An enum containing [AccountType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AccountType] 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 { CHECKING, SAVINGS, + /** + * An enum member indicating that [AccountType] 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) { CHECKING -> Value.CHECKING @@ -571,6 +603,15 @@ private constructor( 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) { CHECKING -> Known.CHECKING @@ -644,11 +685,13 @@ private constructor( private var validated: Boolean = false fun validate(): Department = apply { - if (!validated) { - name() - parent().map { it.validate() } - validated = true + if (validated) { + return@apply } + + name() + parent().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -658,7 +701,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Department]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var parent: JsonField = JsonMissing.of() @@ -741,10 +785,12 @@ private constructor( private var validated: Boolean = false fun validate(): Parent = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -754,7 +800,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Parent]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -867,11 +914,13 @@ private constructor( private var validated: Boolean = false fun validate(): Entity = apply { - if (!validated) { - subtype() - type() - validated = true + if (validated) { + return@apply } + + subtype() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -881,7 +930,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entity]. */ + class Builder internal constructor() { private var subtype: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -939,12 +989,21 @@ private constructor( ) } + /** The tax payer subtype of the company. */ class Subtype @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -958,19 +1017,39 @@ private constructor( @JvmStatic fun of(value: String) = Subtype(JsonField.of(value)) } + /** An enum containing [Subtype]'s known values. */ enum class Known { S_CORPORATION, C_CORPORATION, B_CORPORATION, } + /** + * An enum containing [Subtype]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Subtype] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { S_CORPORATION, C_CORPORATION, B_CORPORATION, + /** + * An enum member indicating that [Subtype] was instantiated with an unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { S_CORPORATION -> Value.S_CORPORATION @@ -979,6 +1058,15 @@ private constructor( 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) { S_CORPORATION -> Known.S_CORPORATION @@ -1002,12 +1090,21 @@ private constructor( override fun toString() = value.toString() } + /** The tax payer type of the company. */ 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 { @@ -1029,6 +1126,7 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { LLC, LP, @@ -1039,6 +1137,15 @@ private constructor( COOPERATIVE, } + /** + * 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 { LLC, LP, @@ -1047,9 +1154,17 @@ private constructor( NON_PROFIT, PARTNERSHIP, COOPERATIVE, + /** 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) { LLC -> Value.LLC @@ -1062,6 +1177,15 @@ private constructor( 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) { LLC -> Known.LLC 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 98dd4ae6..29c5f4e9 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 @@ -12,6 +12,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -22,11 +24,11 @@ import java.util.Optional /** Create a new connect session for an employer */ class ConnectSessionNewParams -constructor( +private constructor( private val body: ConnectSessionNewBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun customerId(): String = body.customerId() @@ -40,7 +42,7 @@ constructor( fun manual(): Optional = body.manual() - /** The number of minutes until the session expires (defaults to 20,160, which is 14 days) */ + /** The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ fun minutesToExpire(): Optional = body.minutesToExpire() fun redirectUri(): Optional = body.redirectUri() @@ -59,7 +61,7 @@ constructor( fun _manual(): JsonField = body._manual() - /** The number of minutes until the session expires (defaults to 20,160, which is 14 days) */ + /** The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ fun _minutesToExpire(): JsonField = body._minutesToExpire() fun _redirectUri(): JsonField = body._redirectUri() @@ -72,11 +74,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): ConnectSessionNewBody = body + @JvmSynthetic internal fun _body(): ConnectSessionNewBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect class ConnectSessionNewBody @@ -128,7 +130,7 @@ constructor( fun manual(): Optional = Optional.ofNullable(manual.getNullable("manual")) /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + * The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ fun minutesToExpire(): Optional = Optional.ofNullable(minutesToExpire.getNullable("minutes_to_expire")) @@ -161,7 +163,7 @@ constructor( @JsonProperty("manual") @ExcludeMissing fun _manual(): JsonField = manual /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + * The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ @JsonProperty("minutes_to_expire") @ExcludeMissing @@ -180,18 +182,20 @@ constructor( private var validated: Boolean = false fun validate(): ConnectSessionNewBody = apply { - if (!validated) { - customerId() - customerName() - products() - customerEmail() - integration().map { it.validate() } - manual() - minutesToExpire() - redirectUri() - sandbox() - validated = true + if (validated) { + return@apply } + + customerId() + customerName() + products() + customerEmail() + integration().ifPresent { it.validate() } + manual() + minutesToExpire() + redirectUri() + sandbox() + validated = true } fun toBuilder() = Builder().from(this) @@ -201,7 +205,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ConnectSessionNewBody]. */ + class Builder internal constructor() { private var customerId: JsonField? = null private var customerName: JsonField? = null @@ -287,21 +292,21 @@ constructor( fun manual(manual: JsonField) = apply { this.manual = manual } /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 + * The number of minutes until the session expires (defaults to 43,200, which is 30 * days) */ fun minutesToExpire(minutesToExpire: Double?) = minutesToExpire(JsonField.ofNullable(minutesToExpire)) /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 + * The number of minutes until the session expires (defaults to 43,200, which is 30 * days) */ fun minutesToExpire(minutesToExpire: Double) = minutesToExpire(minutesToExpire as Double?) /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 + * The number of minutes until the session expires (defaults to 43,200, which is 30 * days) */ @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 @@ -309,7 +314,7 @@ constructor( minutesToExpire(minutesToExpire.orElse(null) as Double?) /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 + * The number of minutes until the session expires (defaults to 43,200, which is 30 * days) */ fun minutesToExpire(minutesToExpire: JsonField) = apply { @@ -351,10 +356,9 @@ constructor( fun build(): ConnectSessionNewBody = ConnectSessionNewBody( - checkNotNull(customerId) { "`customerId` is required but was not set" }, - checkNotNull(customerName) { "`customerName` is required but was not set" }, - checkNotNull(products) { "`products` is required but was not set" } - .map { it.toImmutable() }, + checkRequired("customerId", customerId), + checkRequired("customerName", customerName), + checkRequired("products", products).map { it.toImmutable() }, customerEmail, integration, manual, @@ -390,8 +394,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ConnectSessionNewParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: ConnectSessionNewBody.Builder = ConnectSessionNewBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() @@ -447,26 +452,26 @@ constructor( fun manual(manual: JsonField) = apply { body.manual(manual) } /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + * The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ fun minutesToExpire(minutesToExpire: Double?) = apply { body.minutesToExpire(minutesToExpire) } /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + * The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ fun minutesToExpire(minutesToExpire: Double) = minutesToExpire(minutesToExpire as Double?) /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + * The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun minutesToExpire(minutesToExpire: Optional) = minutesToExpire(minutesToExpire.orElse(null) as Double?) /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + * The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ fun minutesToExpire(minutesToExpire: JsonField) = apply { body.minutesToExpire(minutesToExpire) @@ -609,12 +614,21 @@ constructor( ) } + /** The Finch products that can be requested during the Connect flow. */ class ConnectProducts @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 { @@ -638,6 +652,7 @@ constructor( @JvmStatic fun of(value: String) = ConnectProducts(JsonField.of(value)) } + /** An enum containing [ConnectProducts]'s known values. */ enum class Known { COMPANY, DIRECTORY, @@ -649,6 +664,15 @@ constructor( SSN, } + /** + * An enum containing [ConnectProducts]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ConnectProducts] 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 { COMPANY, DIRECTORY, @@ -658,9 +682,20 @@ constructor( PAY_STATEMENT, BENEFITS, SSN, + /** + * An enum member indicating that [ConnectProducts] 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) { COMPANY -> Value.COMPANY @@ -674,6 +709,14 @@ constructor( 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) { COMPANY -> Known.COMPANY @@ -734,11 +777,13 @@ constructor( private var validated: Boolean = false fun validate(): Integration = apply { - if (!validated) { - authMethod() - provider() - validated = true + if (validated) { + return@apply } + + authMethod() + provider() + validated = true } fun toBuilder() = Builder().from(this) @@ -748,7 +793,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Integration]. */ + class Builder internal constructor() { private var authMethod: JsonField = JsonMissing.of() private var provider: JsonField = JsonMissing.of() @@ -808,6 +854,14 @@ 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 { @@ -823,6 +877,7 @@ constructor( @JvmStatic fun of(value: String) = AuthMethod(JsonField.of(value)) } + /** An enum containing [AuthMethod]'s known values. */ enum class Known { ASSISTED, CREDENTIAL, @@ -830,14 +885,34 @@ constructor( API_TOKEN, } + /** + * An enum containing [AuthMethod]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AuthMethod] 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, OAUTH, API_TOKEN, + /** + * An enum member indicating that [AuthMethod] 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 @@ -847,6 +922,15 @@ constructor( 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 @@ -895,6 +979,14 @@ 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 { @@ -906,17 +998,35 @@ constructor( @JvmStatic fun of(value: String) = Sandbox(JsonField.of(value)) } + /** An enum containing [Sandbox]'s known values. */ enum class Known { FINCH, PROVIDER, } + /** + * An enum containing [Sandbox]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Sandbox] 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 { FINCH, PROVIDER, + /** An enum member indicating that [Sandbox] 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) { FINCH -> Value.FINCH @@ -924,6 +1034,14 @@ constructor( 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) { FINCH -> Known.FINCH 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 6698afa5..1073bff0 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 @@ -12,6 +12,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -22,16 +24,16 @@ import java.util.Optional /** Create a new Connect session for reauthenticating an existing connection */ class ConnectSessionReauthenticateParams -constructor( +private constructor( private val body: ConnectSessionReauthenticateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** The ID of the existing connection to reauthenticate */ fun connectionId(): String = body.connectionId() - /** The number of minutes until the session expires (defaults to 20,160, which is 14 days) */ + /** The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ fun minutesToExpire(): Optional = body.minutesToExpire() /** The products to request access to (optional for reauthentication) */ @@ -43,7 +45,7 @@ constructor( /** The ID of the existing connection to reauthenticate */ fun _connectionId(): JsonField = body._connectionId() - /** The number of minutes until the session expires (defaults to 20,160, which is 14 days) */ + /** The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ fun _minutesToExpire(): JsonField = body._minutesToExpire() /** The products to request access to (optional for reauthentication) */ @@ -58,11 +60,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): ConnectSessionReauthenticateBody = body + @JvmSynthetic internal fun _body(): ConnectSessionReauthenticateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect class ConnectSessionReauthenticateBody @@ -88,7 +90,7 @@ constructor( fun connectionId(): String = connectionId.getRequired("connection_id") /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + * The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ fun minutesToExpire(): Optional = Optional.ofNullable(minutesToExpire.getNullable("minutes_to_expire")) @@ -107,7 +109,7 @@ constructor( fun _connectionId(): JsonField = connectionId /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + * The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ @JsonProperty("minutes_to_expire") @ExcludeMissing @@ -130,13 +132,15 @@ constructor( private var validated: Boolean = false fun validate(): ConnectSessionReauthenticateBody = apply { - if (!validated) { - connectionId() - minutesToExpire() - products() - redirectUri() - validated = true + if (validated) { + return@apply } + + connectionId() + minutesToExpire() + products() + redirectUri() + validated = true } fun toBuilder() = Builder().from(this) @@ -146,7 +150,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ConnectSessionReauthenticateBody]. */ + class Builder internal constructor() { private var connectionId: JsonField? = null private var minutesToExpire: JsonField = JsonMissing.of() @@ -174,20 +179,20 @@ constructor( } /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 + * The number of minutes until the session expires (defaults to 43,200, which is 30 * days) */ fun minutesToExpire(minutesToExpire: Long?) = minutesToExpire(JsonField.ofNullable(minutesToExpire)) /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 + * The number of minutes until the session expires (defaults to 43,200, which is 30 * days) */ fun minutesToExpire(minutesToExpire: Long) = minutesToExpire(minutesToExpire as Long?) /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 + * The number of minutes until the session expires (defaults to 43,200, which is 30 * days) */ @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 @@ -195,7 +200,7 @@ constructor( minutesToExpire(minutesToExpire.orElse(null) as Long?) /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 + * The number of minutes until the session expires (defaults to 43,200, which is 30 * days) */ fun minutesToExpire(minutesToExpire: JsonField) = apply { @@ -261,7 +266,7 @@ constructor( fun build(): ConnectSessionReauthenticateBody = ConnectSessionReauthenticateBody( - checkNotNull(connectionId) { "`connectionId` is required but was not set" }, + checkRequired("connectionId", connectionId), minutesToExpire, (products ?: JsonMissing.of()).map { it.toImmutable() }, redirectUri, @@ -294,8 +299,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ConnectSessionReauthenticateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: ConnectSessionReauthenticateBody.Builder = ConnectSessionReauthenticateBody.builder() @@ -320,26 +326,26 @@ constructor( } /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + * The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ fun minutesToExpire(minutesToExpire: Long?) = apply { body.minutesToExpire(minutesToExpire) } /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + * The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ fun minutesToExpire(minutesToExpire: Long) = minutesToExpire(minutesToExpire as Long?) /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + * The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun minutesToExpire(minutesToExpire: Optional) = minutesToExpire(minutesToExpire.orElse(null) as Long?) /** - * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + * The number of minutes until the session expires (defaults to 43,200, which is 30 days) */ fun minutesToExpire(minutesToExpire: JsonField) = apply { body.minutesToExpire(minutesToExpire) @@ -491,12 +497,21 @@ constructor( ) } + /** The Finch products that can be requested during the Connect flow. */ class ConnectProducts @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 { @@ -520,6 +535,7 @@ constructor( @JvmStatic fun of(value: String) = ConnectProducts(JsonField.of(value)) } + /** An enum containing [ConnectProducts]'s known values. */ enum class Known { COMPANY, DIRECTORY, @@ -531,6 +547,15 @@ constructor( SSN, } + /** + * An enum containing [ConnectProducts]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ConnectProducts] 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 { COMPANY, DIRECTORY, @@ -540,9 +565,20 @@ constructor( PAY_STATEMENT, BENEFITS, SSN, + /** + * An enum member indicating that [ConnectProducts] 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) { COMPANY -> Value.COMPANY @@ -556,6 +592,14 @@ constructor( 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) { COMPANY -> Known.COMPANY 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 3917b3e3..49be8e42 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -52,13 +53,13 @@ private constructor( fun accessToken(): String = accessToken.getRequired("access_token") /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - fun accountId(): String = accountId.getRequired("account_id") + @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") fun authenticationType(): AuthenticationType = authenticationType.getRequired("authentication_type") /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - fun companyId(): String = companyId.getRequired("company_id") + @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") /** The ID of the new connection */ fun connectionId(): String = connectionId.getRequired("connection_id") @@ -75,14 +76,20 @@ private constructor( fun _accessToken(): JsonField = accessToken /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId @JsonProperty("authentication_type") @ExcludeMissing fun _authenticationType(): JsonField = authenticationType /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId /** The ID of the new connection */ @JsonProperty("connection_id") @@ -103,17 +110,19 @@ private constructor( private var validated: Boolean = false fun validate(): ConnectionCreateResponse = apply { - if (!validated) { - accessToken() - accountId() - authenticationType() - companyId() - connectionId() - products() - providerId() - tokenType() - validated = true + if (validated) { + return@apply } + + accessToken() + accountId() + authenticationType() + companyId() + connectionId() + products() + providerId() + tokenType() + validated = true } fun toBuilder() = Builder().from(this) @@ -123,7 +132,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ConnectionCreateResponse]. */ + class Builder internal constructor() { private var accessToken: JsonField? = null private var accountId: JsonField? = null @@ -153,9 +163,11 @@ private constructor( fun accessToken(accessToken: JsonField) = apply { this.accessToken = accessToken } /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ + @Deprecated("deprecated") fun accountId(accountId: String) = accountId(JsonField.of(accountId)) /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ + @Deprecated("deprecated") fun accountId(accountId: JsonField) = apply { this.accountId = accountId } fun authenticationType(authenticationType: AuthenticationType) = @@ -166,9 +178,11 @@ private constructor( } /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ + @Deprecated("deprecated") fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ + @Deprecated("deprecated") fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** The ID of the new connection */ @@ -229,16 +243,13 @@ private constructor( fun build(): ConnectionCreateResponse = ConnectionCreateResponse( - checkNotNull(accessToken) { "`accessToken` is required but was not set" }, - checkNotNull(accountId) { "`accountId` is required but was not set" }, - checkNotNull(authenticationType) { - "`authenticationType` is required but was not set" - }, - checkNotNull(companyId) { "`companyId` is required but was not set" }, - checkNotNull(connectionId) { "`connectionId` is required but was not set" }, - checkNotNull(products) { "`products` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(providerId) { "`providerId` is required but was not set" }, + checkRequired("accessToken", accessToken), + checkRequired("accountId", accountId), + checkRequired("authenticationType", authenticationType), + checkRequired("companyId", companyId), + checkRequired("connectionId", connectionId), + checkRequired("products", products).map { it.toImmutable() }, + checkRequired("providerId", providerId), tokenType, additionalProperties.toImmutable(), ) @@ -250,6 +261,14 @@ 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 { @@ -265,6 +284,7 @@ private constructor( @JvmStatic fun of(value: String) = AuthenticationType(JsonField.of(value)) } + /** An enum containing [AuthenticationType]'s known values. */ enum class Known { CREDENTIAL, API_TOKEN, @@ -272,14 +292,34 @@ private constructor( ASSISTED, } + /** + * An enum containing [AuthenticationType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AuthenticationType] 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 { CREDENTIAL, API_TOKEN, OAUTH, ASSISTED, + /** + * An enum member indicating that [AuthenticationType] 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) { CREDENTIAL -> Value.CREDENTIAL @@ -289,6 +329,14 @@ private constructor( 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) { CREDENTIAL -> Known.CREDENTIAL diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectionStatusType.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectionStatusType.kt index e926f102..b87840e6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectionStatusType.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectionStatusType.kt @@ -13,6 +13,13 @@ 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 { @@ -32,6 +39,7 @@ private constructor( @JvmStatic fun of(value: String) = ConnectionStatusType(JsonField.of(value)) } + /** An enum containing [ConnectionStatusType]'s known values. */ enum class Known { PENDING, PROCESSING, @@ -41,6 +49,15 @@ private constructor( REAUTH, } + /** + * An enum containing [ConnectionStatusType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ConnectionStatusType] 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 { PENDING, PROCESSING, @@ -48,9 +65,20 @@ private constructor( ERROR_NO_ACCOUNT_SETUP, ERROR_PERMISSIONS, REAUTH, + /** + * An enum member indicating that [ConnectionStatusType] 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) { PENDING -> Value.PENDING @@ -62,6 +90,14 @@ private constructor( 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) { PENDING -> Known.PENDING 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 35b8d58a..312150e0 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -59,13 +60,13 @@ private constructor( fun accessToken(): String = accessToken.getRequired("access_token") /** [DEPRECATED] Use `connection_id` to identify the connection instead of this account ID. */ - fun accountId(): String = accountId.getRequired("account_id") + @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") /** The type of application associated with a token. */ fun clientType(): ClientType = clientType.getRequired("client_type") /** [DEPRECATED] Use `connection_id` to identify the connection instead of this company ID. */ - fun companyId(): String = companyId.getRequired("company_id") + @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") /** The Finch UUID of the connection associated with the `access_token`. */ fun connectionId(): String = connectionId.getRequired("connection_id") @@ -98,7 +99,10 @@ private constructor( fun _accessToken(): JsonField = accessToken /** [DEPRECATED] Use `connection_id` to identify the connection instead of this account ID. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId /** The type of application associated with a token. */ @JsonProperty("client_type") @@ -106,7 +110,10 @@ private constructor( fun _clientType(): JsonField = clientType /** [DEPRECATED] Use `connection_id` to identify the connection instead of this company ID. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId /** The Finch UUID of the connection associated with the `access_token`. */ @JsonProperty("connection_id") @@ -144,19 +151,21 @@ private constructor( private var validated: Boolean = false fun validate(): CreateAccessTokenResponse = apply { - if (!validated) { - accessToken() - accountId() - clientType() - companyId() - connectionId() - connectionType() - products() - providerId() - customerId() - tokenType() - validated = true + if (validated) { + return@apply } + + accessToken() + accountId() + clientType() + companyId() + connectionId() + connectionType() + products() + providerId() + customerId() + tokenType() + validated = true } fun toBuilder() = Builder().from(this) @@ -166,7 +175,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [CreateAccessTokenResponse]. */ + class Builder internal constructor() { private var accessToken: JsonField? = null private var accountId: JsonField? = null @@ -204,11 +214,13 @@ private constructor( /** * [DEPRECATED] Use `connection_id` to identify the connection instead of this account ID. */ + @Deprecated("deprecated") fun accountId(accountId: String) = accountId(JsonField.of(accountId)) /** * [DEPRECATED] Use `connection_id` to identify the connection instead of this account ID. */ + @Deprecated("deprecated") fun accountId(accountId: JsonField) = apply { this.accountId = accountId } /** The type of application associated with a token. */ @@ -220,11 +232,13 @@ private constructor( /** * [DEPRECATED] Use `connection_id` to identify the connection instead of this company ID. */ + @Deprecated("deprecated") fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** * [DEPRECATED] Use `connection_id` to identify the connection instead of this company ID. */ + @Deprecated("deprecated") fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** The Finch UUID of the connection associated with the `access_token`. */ @@ -325,27 +339,35 @@ private constructor( fun build(): CreateAccessTokenResponse = CreateAccessTokenResponse( - checkNotNull(accessToken) { "`accessToken` is required but was not set" }, - checkNotNull(accountId) { "`accountId` is required but was not set" }, - checkNotNull(clientType) { "`clientType` is required but was not set" }, - checkNotNull(companyId) { "`companyId` is required but was not set" }, - checkNotNull(connectionId) { "`connectionId` is required but was not set" }, - checkNotNull(connectionType) { "`connectionType` is required but was not set" }, - checkNotNull(products) { "`products` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(providerId) { "`providerId` is required but was not set" }, + 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), customerId, tokenType, additionalProperties.toImmutable(), ) } + /** The type of application associated with a token. */ class ClientType @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 { @@ -359,19 +381,39 @@ private constructor( @JvmStatic fun of(value: String) = ClientType(JsonField.of(value)) } + /** An enum containing [ClientType]'s known values. */ enum class Known { PRODUCTION, DEVELOPMENT, SANDBOX, } + /** + * An enum containing [ClientType]'s known values, as well as an [_UNKNOWN] member. + * + * 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. + */ enum class Value { PRODUCTION, DEVELOPMENT, SANDBOX, + /** + * An enum member indicating that [ClientType] 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) { PRODUCTION -> Value.PRODUCTION @@ -380,6 +422,14 @@ private constructor( 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) { PRODUCTION -> Known.PRODUCTION @@ -403,12 +453,25 @@ private constructor( override fun toString() = value.toString() } + /** + * 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. + * + * 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 { @@ -420,17 +483,38 @@ private constructor( @JvmStatic fun of(value: String) = ConnectionType(JsonField.of(value)) } + /** An enum containing [ConnectionType]'s known values. */ enum class Known { PROVIDER, FINCH, } + /** + * 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, } + /** + * 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 @@ -438,6 +522,14 @@ private constructor( 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) { PROVIDER -> Known.PROVIDER 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 afd35fe1..182bc3e7 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import java.util.Objects @@ -36,10 +37,12 @@ private constructor( private var validated: Boolean = false fun validate(): CreateCompanyBenefitsResponse = apply { - if (!validated) { - benefitId() - validated = true + if (validated) { + return@apply } + + benefitId() + validated = true } fun toBuilder() = Builder().from(this) @@ -49,7 +52,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [CreateCompanyBenefitsResponse]. */ + class Builder internal constructor() { private var benefitId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -85,7 +89,7 @@ private constructor( fun build(): CreateCompanyBenefitsResponse = CreateCompanyBenefitsResponse( - checkNotNull(benefitId) { "`benefitId` is required but was not set" }, + checkRequired("benefitId", benefitId), additionalProperties.toImmutable() ) } 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 32f700e5..750c01b2 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -42,13 +43,13 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - fun accountId(): String = accountId.getRequired("account_id") + @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - fun companyId(): String = companyId.getRequired("company_id") + @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") /** Unique Finch ID of the connection associated with the webhook event. */ fun connectionId(): Optional = @@ -62,13 +63,19 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ @JsonProperty("connection_id") @@ -93,14 +100,16 @@ private constructor( private var validated: Boolean = false fun validate(): DirectoryEvent = apply { - if (!validated) { - accountId() - companyId() - connectionId() - data().map { it.validate() } - eventType() - validated = true + if (validated) { + return@apply } + + accountId() + companyId() + connectionId() + data().ifPresent { it.validate() } + eventType() + validated = true } fun toBuilder() = Builder().from(this) @@ -110,7 +119,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DirectoryEvent]. */ + class Builder internal constructor() { private var accountId: JsonField? = null private var companyId: JsonField? = null @@ -133,24 +143,28 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: String) = accountId(JsonField.of(accountId)) /** * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: JsonField) = apply { this.accountId = accountId } /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** Unique Finch ID of the connection associated with the webhook event. */ @@ -190,8 +204,8 @@ private constructor( fun build(): DirectoryEvent = DirectoryEvent( - checkNotNull(accountId) { "`accountId` is required but was not set" }, - checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkRequired("accountId", accountId), + checkRequired("companyId", companyId), connectionId, data, eventType, @@ -226,10 +240,12 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - individualId() - validated = true + if (validated) { + return@apply } + + individualId() + validated = true } fun toBuilder() = Builder().from(this) @@ -239,7 +255,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { private var individualId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -304,6 +321,14 @@ 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 { @@ -317,19 +342,39 @@ private constructor( @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) } + /** An enum containing [EventType]'s known values. */ enum class Known { DIRECTORY_CREATED, DIRECTORY_UPDATED, DIRECTORY_DELETED, } + /** + * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventType] 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 { DIRECTORY_CREATED, DIRECTORY_UPDATED, DIRECTORY_DELETED, + /** + * An enum member indicating that [EventType] 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) { DIRECTORY_CREATED -> Value.DIRECTORY_CREATED @@ -338,6 +383,14 @@ private constructor( 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) { DIRECTORY_CREATED -> Known.DIRECTORY_CREATED 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 4759deb3..a2b8ff0a 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import java.util.Objects @@ -38,10 +39,12 @@ private constructor( private var validated: Boolean = false fun validate(): DisconnectResponse = apply { - if (!validated) { - status() - validated = true + if (validated) { + return@apply } + + status() + validated = true } fun toBuilder() = Builder().from(this) @@ -51,7 +54,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DisconnectResponse]. */ + class Builder internal constructor() { private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -88,10 +92,7 @@ private constructor( } fun build(): DisconnectResponse = - DisconnectResponse( - checkNotNull(status) { "`status` is required but was not set" }, - additionalProperties.toImmutable() - ) + DisconnectResponse(checkRequired("status", status), additionalProperties.toImmutable()) } override fun equals(other: Any?): Boolean { 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 3e21e436..ed73b872 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import java.util.Objects @@ -45,11 +46,13 @@ private constructor( private var validated: Boolean = false fun validate(): DocumentListResponse = apply { - if (!validated) { - documents().forEach { it.validate() } - paging().validate() - validated = true + if (validated) { + return@apply } + + documents().forEach { it.validate() } + paging().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -59,7 +62,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DocumentListResponse]. */ + class Builder internal constructor() { private var documents: JsonField>? = null private var paging: JsonField? = null @@ -116,9 +120,8 @@ private constructor( fun build(): DocumentListResponse = DocumentListResponse( - checkNotNull(documents) { "`documents` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(paging) { "`paging` is required but was not set" }, + checkRequired("documents", documents).map { it.toImmutable() }, + checkRequired("paging", paging), additionalProperties.toImmutable(), ) } 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 005d03a8..6d71abd4 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 @@ -84,14 +84,16 @@ private constructor( private var validated: Boolean = false fun validate(): DocumentResponse = apply { - if (!validated) { - id() - individualId() - type() - url() - year() - validated = true + if (validated) { + return@apply } + + id() + individualId() + type() + url() + year() + validated = true } fun toBuilder() = Builder().from(this) @@ -101,7 +103,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DocumentResponse]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var individualId: JsonField = JsonMissing.of() @@ -207,12 +210,21 @@ private constructor( ) } + /** The type of document. */ 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 { @@ -224,17 +236,35 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { W4_2020, W4_2005, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { W4_2020, W4_2005, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { W4_2020 -> Value.W4_2020 @@ -242,6 +272,14 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { W4_2020 -> Known.W4_2020 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentRetreiveResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentRetreiveResponse.kt index f4a7cd62..83153e62 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentRetreiveResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentRetreiveResponse.kt @@ -31,13 +31,12 @@ private constructor( private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - /** * A 2020 version of the W-4 tax form containing information on an individual's filing status, * dependents, and withholding details. */ fun w42020(): Optional = Optional.ofNullable(w42020) + /** * A 2005 version of the W-4 tax form containing information on an individual's filing status, * dependents, and withholding details. @@ -53,6 +52,7 @@ private constructor( * dependents, and withholding details. */ fun asW42020(): W42020 = w42020.getOrThrow("w42020") + /** * A 2005 version of the W-4 tax form containing information on an individual's filing status, * dependents, and withholding details. @@ -69,15 +69,25 @@ private constructor( } } + private var validated: Boolean = false + fun validate(): DocumentRetreiveResponse = apply { - if (!validated) { - if (w42020 == null && w42005 == null) { - throw FinchInvalidDataException("Unknown DocumentRetreiveResponse: $_json") - } - w42020?.validate() - w42005?.validate() - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitW42020(w42020: W42020) { + w42020.validate() + } + + override fun visitW42005(w42005: W42005) { + w42005.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -113,18 +123,40 @@ private constructor( @JvmStatic fun ofW42005(w42005: W42005) = DocumentRetreiveResponse(w42005 = w42005) } + /** + * An interface that defines how to map each variant of [DocumentRetreiveResponse] to a value of + * type [T]. + */ interface Visitor { + /** + * A 2020 version of the W-4 tax form containing information on an individual's filing + * status, dependents, and withholding details. + */ fun visitW42020(w42020: W42020): T + /** + * A 2005 version of the W-4 tax form containing information on an individual's filing + * status, dependents, and withholding details. + */ fun visitW42005(w42005: W42005): T + /** + * Maps an unknown variant of [DocumentRetreiveResponse] to a value of type [T]. + * + * An instance of [DocumentRetreiveResponse] 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 DocumentRetreiveResponse: $json") } } - class Deserializer : + internal class Deserializer : BaseDeserializer(DocumentRetreiveResponse::class) { override fun ObjectCodec.deserialize(node: JsonNode): DocumentRetreiveResponse { @@ -150,7 +182,8 @@ private constructor( } } - class Serializer : BaseSerializer(DocumentRetreiveResponse::class) { + internal class Serializer : + BaseSerializer(DocumentRetreiveResponse::class) { override fun serialize( value: DocumentRetreiveResponse, 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 108cf3c6..d0d6ea8d 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 @@ -151,6 +151,7 @@ private constructor( fun title(): Optional = Optional.ofNullable(title.getNullable("title")) /** This field is deprecated in favour of `source_id` */ + @Deprecated("deprecated") fun workId(): Optional = Optional.ofNullable(workId.getNullable("work_id")) /** string A stable Finch `id` (UUID v4) for an individual in the company. */ @@ -229,7 +230,10 @@ private constructor( @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title /** This field is deprecated in favour of `source_id` */ - @JsonProperty("work_id") @ExcludeMissing fun _workId(): JsonField = workId + @Deprecated("deprecated") + @JsonProperty("work_id") + @ExcludeMissing + fun _workId(): JsonField = workId @JsonAnyGetter @ExcludeMissing @@ -238,29 +242,31 @@ private constructor( private var validated: Boolean = false fun validate(): EmploymentData = apply { - if (!validated) { - id() - classCode() - customFields().map { it.forEach { it.validate() } } - department().map { it.validate() } - employment().map { it.validate() } - employmentStatus() - endDate() - firstName() - income().map { it.validate() } - incomeHistory().map { it.forEach { it?.validate() } } - isActive() - lastName() - latestRehireDate() - location().map { it.validate() } - manager().map { it.validate() } - middleName() - sourceId() - startDate() - title() - workId() - validated = true + if (validated) { + return@apply } + + id() + classCode() + customFields().ifPresent { it.forEach { it.validate() } } + department().ifPresent { it.validate() } + employment().ifPresent { it.validate() } + employmentStatus() + endDate() + firstName() + income().ifPresent { it.validate() } + incomeHistory().ifPresent { it.forEach { it?.validate() } } + isActive() + lastName() + latestRehireDate() + location().ifPresent { it.validate() } + manager().ifPresent { it.validate() } + middleName() + sourceId() + startDate() + title() + workId() + validated = true } fun toBuilder() = Builder().from(this) @@ -270,7 +276,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EmploymentData]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var classCode: JsonField = JsonMissing.of() @@ -557,12 +564,13 @@ private constructor( fun title(title: JsonField) = apply { this.title = title } /** This field is deprecated in favour of `source_id` */ - fun workId(workId: String?) = workId(JsonField.ofNullable(workId)) + @Deprecated("deprecated") fun workId(workId: String?) = workId(JsonField.ofNullable(workId)) /** This field is deprecated in favour of `source_id` */ - fun workId(workId: Optional) = workId(workId.orElse(null)) + @Deprecated("deprecated") fun workId(workId: Optional) = workId(workId.orElse(null)) /** This field is deprecated in favour of `source_id` */ + @Deprecated("deprecated") fun workId(workId: JsonField) = apply { this.workId = workId } fun additionalProperties(additionalProperties: Map) = apply { @@ -635,10 +643,12 @@ private constructor( private var validated: Boolean = false fun validate(): CustomField = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -648,7 +658,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [CustomField]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var value: JsonValue = JsonMissing.of() @@ -737,10 +748,12 @@ private constructor( private var validated: Boolean = false fun validate(): Department = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -750,7 +763,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Department]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -848,11 +862,13 @@ private constructor( private var validated: Boolean = false fun validate(): Employment = apply { - if (!validated) { - subtype() - type() - validated = true + if (validated) { + return@apply } + + subtype() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -862,7 +878,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Employment]. */ + class Builder internal constructor() { private var subtype: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -929,12 +946,24 @@ private constructor( ) } + /** + * The secondary employment type of the individual. Options: `full_time`, `part_time`, + * `intern`, `temp`, `seasonal` and `individual_contractor`. + */ class Subtype @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -954,6 +983,7 @@ private constructor( @JvmStatic fun of(value: String) = Subtype(JsonField.of(value)) } + /** An enum containing [Subtype]'s known values. */ enum class Known { FULL_TIME, INTERN, @@ -963,6 +993,15 @@ private constructor( INDIVIDUAL_CONTRACTOR, } + /** + * An enum containing [Subtype]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Subtype] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { FULL_TIME, INTERN, @@ -970,9 +1009,19 @@ private constructor( TEMP, SEASONAL, INDIVIDUAL_CONTRACTOR, + /** + * An enum member indicating that [Subtype] was instantiated with an unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { FULL_TIME -> Value.FULL_TIME @@ -984,6 +1033,15 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { FULL_TIME -> Known.FULL_TIME @@ -1010,12 +1068,21 @@ private constructor( override fun toString() = value.toString() } + /** The main employment type of the individual. */ class Type @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1027,17 +1094,35 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { EMPLOYEE, CONTRACTOR, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { EMPLOYEE, CONTRACTOR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { EMPLOYEE -> Value.EMPLOYEE @@ -1045,6 +1130,15 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { EMPLOYEE -> Known.EMPLOYEE @@ -1085,12 +1179,24 @@ private constructor( "Employment{subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" } + /** + * The detailed employment status of the individual. Available options: `active`, `deceased`, + * `leave`, `onboarding`, `prehire`, `retired`, `terminated`. + */ class EmploymentStatus @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * 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 { @@ -1112,6 +1218,7 @@ private constructor( @JvmStatic fun of(value: String) = EmploymentStatus(JsonField.of(value)) } + /** An enum containing [EmploymentStatus]'s known values. */ enum class Known { ACTIVE, DECEASED, @@ -1122,6 +1229,15 @@ private constructor( TERMINATED, } + /** + * An enum containing [EmploymentStatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EmploymentStatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { ACTIVE, DECEASED, @@ -1130,9 +1246,20 @@ private constructor( PREHIRE, RETIRED, TERMINATED, + /** + * An enum member indicating that [EmploymentStatus] 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) { ACTIVE -> Value.ACTIVE @@ -1145,6 +1272,14 @@ private constructor( 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) { ACTIVE -> Known.ACTIVE @@ -1195,10 +1330,12 @@ private constructor( private var validated: Boolean = false fun validate(): Manager = apply { - if (!validated) { - id() - validated = true + if (validated) { + return@apply } + + id() + validated = true } fun toBuilder() = Builder().from(this) @@ -1208,7 +1345,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Manager]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() 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 6c9887d2..2b83375e 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 @@ -52,12 +52,14 @@ private constructor( private var validated: Boolean = false fun validate(): EmploymentDataResponse = apply { - if (!validated) { - body().map { it.validate() } - code() - individualId() - validated = true + if (validated) { + return@apply } + + body().ifPresent { it.validate() } + code() + individualId() + validated = true } fun toBuilder() = Builder().from(this) @@ -67,7 +69,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EmploymentDataResponse]. */ + class Builder internal constructor() { private var body: JsonField = JsonMissing.of() private var code: JsonField = JsonMissing.of() 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 9921898c..f9bd150a 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -42,13 +43,13 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - fun accountId(): String = accountId.getRequired("account_id") + @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - fun companyId(): String = companyId.getRequired("company_id") + @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") /** Unique Finch ID of the connection associated with the webhook event. */ fun connectionId(): Optional = @@ -62,13 +63,19 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ @JsonProperty("connection_id") @@ -93,14 +100,16 @@ private constructor( private var validated: Boolean = false fun validate(): EmploymentEvent = apply { - if (!validated) { - accountId() - companyId() - connectionId() - data().map { it.validate() } - eventType() - validated = true + if (validated) { + return@apply } + + accountId() + companyId() + connectionId() + data().ifPresent { it.validate() } + eventType() + validated = true } fun toBuilder() = Builder().from(this) @@ -110,7 +119,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EmploymentEvent]. */ + class Builder internal constructor() { private var accountId: JsonField? = null private var companyId: JsonField? = null @@ -133,24 +143,28 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: String) = accountId(JsonField.of(accountId)) /** * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: JsonField) = apply { this.accountId = accountId } /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** Unique Finch ID of the connection associated with the webhook event. */ @@ -190,8 +204,8 @@ private constructor( fun build(): EmploymentEvent = EmploymentEvent( - checkNotNull(accountId) { "`accountId` is required but was not set" }, - checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkRequired("accountId", accountId), + checkRequired("companyId", companyId), connectionId, data, eventType, @@ -226,10 +240,12 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - individualId() - validated = true + if (validated) { + return@apply } + + individualId() + validated = true } fun toBuilder() = Builder().from(this) @@ -239,7 +255,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { private var individualId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -304,6 +321,14 @@ 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 { @@ -317,19 +342,39 @@ private constructor( @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) } + /** An enum containing [EventType]'s known values. */ enum class Known { EMPLOYMENT_CREATED, EMPLOYMENT_UPDATED, EMPLOYMENT_DELETED, } + /** + * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventType] 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 { EMPLOYMENT_CREATED, EMPLOYMENT_UPDATED, EMPLOYMENT_DELETED, + /** + * An enum member indicating that [EventType] 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) { EMPLOYMENT_CREATED -> Value.EMPLOYMENT_CREATED @@ -338,6 +383,14 @@ private constructor( 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) { EMPLOYMENT_CREATED -> Known.EMPLOYMENT_CREATED 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 e5f2aca3..4ea8b3f5 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 @@ -223,28 +223,30 @@ private constructor( private var validated: Boolean = false fun validate(): EmploymentUpdateResponse = apply { - if (!validated) { - id() - classCode() - customFields().map { it.forEach { it.validate() } } - department().map { it.validate() } - employment().map { it.validate() } - employmentStatus() - endDate() - firstName() - income().map { it.validate() } - incomeHistory().map { it.forEach { it?.validate() } } - isActive() - lastName() - latestRehireDate() - location().map { it.validate() } - manager().map { it.validate() } - middleName() - sourceId() - startDate() - title() - validated = true + if (validated) { + return@apply } + + id() + classCode() + customFields().ifPresent { it.forEach { it.validate() } } + department().ifPresent { it.validate() } + employment().ifPresent { it.validate() } + employmentStatus() + endDate() + firstName() + income().ifPresent { it.validate() } + incomeHistory().ifPresent { it.forEach { it?.validate() } } + isActive() + lastName() + latestRehireDate() + location().ifPresent { it.validate() } + manager().ifPresent { it.validate() } + middleName() + sourceId() + startDate() + title() + validated = true } fun toBuilder() = Builder().from(this) @@ -254,7 +256,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EmploymentUpdateResponse]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var classCode: JsonField = JsonMissing.of() @@ -587,10 +590,12 @@ private constructor( private var validated: Boolean = false fun validate(): CustomField = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -600,7 +605,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [CustomField]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var value: JsonValue = JsonMissing.of() @@ -691,10 +697,12 @@ private constructor( private var validated: Boolean = false fun validate(): Department = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -704,7 +712,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Department]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -802,11 +811,13 @@ private constructor( private var validated: Boolean = false fun validate(): Employment = apply { - if (!validated) { - subtype() - type() - validated = true + if (validated) { + return@apply } + + subtype() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -816,7 +827,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Employment]. */ + class Builder internal constructor() { private var subtype: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -883,12 +895,24 @@ private constructor( ) } + /** + * The secondary employment type of the individual. Options: `full_time`, `part_time`, + * `intern`, `temp`, `seasonal` and `individual_contractor`. + */ class Subtype @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -908,6 +932,7 @@ private constructor( @JvmStatic fun of(value: String) = Subtype(JsonField.of(value)) } + /** An enum containing [Subtype]'s known values. */ enum class Known { FULL_TIME, INTERN, @@ -917,6 +942,15 @@ private constructor( INDIVIDUAL_CONTRACTOR, } + /** + * An enum containing [Subtype]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Subtype] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { FULL_TIME, INTERN, @@ -924,9 +958,19 @@ private constructor( TEMP, SEASONAL, INDIVIDUAL_CONTRACTOR, + /** + * An enum member indicating that [Subtype] was instantiated with an unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { FULL_TIME -> Value.FULL_TIME @@ -938,6 +982,15 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { FULL_TIME -> Known.FULL_TIME @@ -964,12 +1017,21 @@ private constructor( override fun toString() = value.toString() } + /** The main employment type of the individual. */ class Type @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -981,17 +1043,35 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { EMPLOYEE, CONTRACTOR, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { EMPLOYEE, CONTRACTOR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { EMPLOYEE -> Value.EMPLOYEE @@ -999,6 +1079,15 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { EMPLOYEE -> Known.EMPLOYEE @@ -1039,12 +1128,21 @@ private constructor( "Employment{subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" } + /** The detailed employment status of the individual. */ class EmploymentStatus @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 { @@ -1066,6 +1164,7 @@ private constructor( @JvmStatic fun of(value: String) = EmploymentStatus(JsonField.of(value)) } + /** An enum containing [EmploymentStatus]'s known values. */ enum class Known { ACTIVE, DECEASED, @@ -1076,6 +1175,15 @@ private constructor( TERMINATED, } + /** + * An enum containing [EmploymentStatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EmploymentStatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { ACTIVE, DECEASED, @@ -1084,9 +1192,20 @@ private constructor( PREHIRE, RETIRED, TERMINATED, + /** + * An enum member indicating that [EmploymentStatus] 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) { ACTIVE -> Value.ACTIVE @@ -1099,6 +1218,14 @@ private constructor( 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) { ACTIVE -> Known.ACTIVE @@ -1149,10 +1276,12 @@ private constructor( private var validated: Boolean = false fun validate(): Manager = apply { - if (!validated) { - id() - validated = true + if (validated) { + return@apply } + + id() + validated = true } fun toBuilder() = Builder().from(this) @@ -1162,7 +1291,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Manager]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividual.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividual.kt index 6ee1fa49..7ac3fc5c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividual.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividual.kt @@ -54,12 +54,14 @@ private constructor( private var validated: Boolean = false fun validate(): EnrolledIndividual = apply { - if (!validated) { - body().map { it.validate() } - code() - individualId() - validated = true + if (validated) { + return@apply } + + body().ifPresent { it.validate() } + code() + individualId() + validated = true } fun toBuilder() = Builder().from(this) @@ -69,7 +71,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EnrolledIndividual]. */ + class Builder internal constructor() { private var body: JsonField = JsonMissing.of() private var code: JsonField = JsonMissing.of() @@ -170,12 +173,14 @@ private constructor( private var validated: Boolean = false fun validate(): Body = apply { - if (!validated) { - finchCode() - message() - name() - validated = true + if (validated) { + return@apply } + + finchCode() + message() + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -185,7 +190,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Body]. */ + class Builder internal constructor() { private var finchCode: JsonField = JsonMissing.of() private var message: JsonField = JsonMissing.of() @@ -273,12 +279,21 @@ private constructor( "Body{finchCode=$finchCode, message=$message, name=$name, additionalProperties=$additionalProperties}" } + /** HTTP status code. Either 201 or 200 */ class Code @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 { @@ -294,6 +309,7 @@ private constructor( @JvmStatic fun of(value: Long) = Code(JsonField.of(value)) } + /** An enum containing [Code]'s known values. */ enum class Known { OK, CREATED, @@ -301,14 +317,31 @@ private constructor( FORBIDDEN, } + /** + * An enum containing [Code]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Code] 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 { OK, CREATED, NOT_FOUND, FORBIDDEN, + /** An enum member indicating that [Code] 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) { OK -> Value.OK @@ -318,6 +351,14 @@ private constructor( 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) { OK -> Known.OK 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 9ff08b1c..cb2ec7dc 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import com.tryfinch.api.core.immutableEmptyMap @@ -23,11 +24,11 @@ import java.util.Optional * view available types for each provider. */ class HrisBenefitCreateParams -constructor( +private constructor( private val body: HrisBenefitCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** * Name of the benefit as it appears in the provider and pay statements. Recommend limiting this @@ -57,11 +58,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): HrisBenefitCreateBody = body + @JvmSynthetic internal fun _body(): HrisBenefitCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect class HrisBenefitCreateBody @@ -115,12 +116,14 @@ constructor( private var validated: Boolean = false fun validate(): HrisBenefitCreateBody = apply { - if (!validated) { - description() - frequency() - type() - validated = true + if (validated) { + return@apply } + + description() + frequency() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -130,7 +133,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [HrisBenefitCreateBody]. */ + class Builder internal constructor() { private var description: JsonField = JsonMissing.of() private var frequency: JsonField = JsonMissing.of() @@ -231,8 +235,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisBenefitCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: HrisBenefitCreateBody.Builder = HrisBenefitCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualEnrolledIdsParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualEnrolledIdsParams.kt index 1b2fd5e8..4e98d670 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualEnrolledIdsParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualEnrolledIdsParams.kt @@ -3,17 +3,19 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +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 java.util.Objects /** Lists individuals currently enrolled in a given deduction. */ class HrisBenefitIndividualEnrolledIdsParams -constructor( +private constructor( private val benefitId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun benefitId(): String = benefitId @@ -21,9 +23,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +41,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisBenefitIndividualEnrolledIdsParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var benefitId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -158,7 +161,7 @@ constructor( fun build(): HrisBenefitIndividualEnrolledIdsParams = HrisBenefitIndividualEnrolledIdsParams( - checkNotNull(benefitId) { "`benefitId` is required but was not set" }, + checkRequired("benefitId", benefitId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPage.kt index f5f1d11d..8af049c0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPage.kt @@ -19,6 +19,7 @@ import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** Get enrollment information for the given individuals. */ class HrisBenefitIndividualRetrieveManyBenefitsPage private constructor( private val individualsService: IndividualService, @@ -82,8 +83,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun items(): List = items.getNullable("items") ?: listOf() @JsonProperty("items") @@ -93,11 +92,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - items().map { it.validate() } - validated = true + if (validated) { + return@apply } + + items().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -143,8 +146,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisBenefitIndividualRetrieveManyBenefitsPage, ) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPageAsync.kt index b9f4793c..3b65576e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPageAsync.kt @@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** Get enrollment information for the given individuals. */ class HrisBenefitIndividualRetrieveManyBenefitsPageAsync private constructor( private val individualsService: IndividualServiceAsync, @@ -86,8 +87,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun items(): List = items.getNullable("items") ?: listOf() @JsonProperty("items") @@ -97,11 +96,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - items().map { it.validate() } - validated = true + if (validated) { + return@apply } + + items().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -147,8 +150,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisBenefitIndividualRetrieveManyBenefitsPageAsync, ) { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsParams.kt index c49601d4..bb05a6ef 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsParams.kt @@ -3,6 +3,8 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +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 java.util.Objects @@ -10,12 +12,12 @@ import java.util.Optional /** Get enrollment information for the given individuals. */ class HrisBenefitIndividualRetrieveManyBenefitsParams -constructor( +private constructor( private val benefitId: String, private val individualIds: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun benefitId(): String = benefitId @@ -29,10 +31,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.individualIds?.let { queryParams.put("individual_ids", listOf(it.toString())) } queryParams.putAll(additionalQueryParams) @@ -53,8 +54,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisBenefitIndividualRetrieveManyBenefitsParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var benefitId: String? = null private var individualIds: String? = null @@ -189,7 +191,7 @@ constructor( fun build(): HrisBenefitIndividualRetrieveManyBenefitsParams = HrisBenefitIndividualRetrieveManyBenefitsParams( - checkNotNull(benefitId) { "`benefitId` is required but was not set" }, + checkRequired("benefitId", benefitId), individualIds, additionalHeaders.build(), additionalQueryParams.build(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt index 6fe68d85..cdb9f7ac 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt @@ -19,6 +19,7 @@ import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** Unenroll individuals from a deduction or contribution */ class HrisBenefitIndividualUnenrollManyPage private constructor( private val individualsService: IndividualService, @@ -82,8 +83,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun items(): List = items.getNullable("items") ?: listOf() @JsonProperty("items") @@ -93,11 +92,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - items().map { it.validate() } - validated = true + if (validated) { + return@apply } + + items().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -143,8 +146,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisBenefitIndividualUnenrollManyPage, ) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt index b4fdd6c4..fafba6a4 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt @@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** Unenroll individuals from a deduction or contribution */ class HrisBenefitIndividualUnenrollManyPageAsync private constructor( private val individualsService: IndividualServiceAsync, @@ -85,8 +86,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun items(): List = items.getNullable("items") ?: listOf() @JsonProperty("items") @@ -96,11 +95,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - items().map { it.validate() } - validated = true + if (validated) { + return@apply } + + items().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -146,8 +149,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisBenefitIndividualUnenrollManyPageAsync, ) { 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 f1b1b5ac..30914a92 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 @@ -11,6 +11,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -20,12 +22,12 @@ import java.util.Optional /** Unenroll individuals from a deduction or contribution */ class HrisBenefitIndividualUnenrollManyParams -constructor( +private constructor( private val benefitId: String, private val body: HrisBenefitIndividualUnenrollManyBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun benefitId(): String = benefitId @@ -41,11 +43,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): HrisBenefitIndividualUnenrollManyBody = body + @JvmSynthetic internal fun _body(): HrisBenefitIndividualUnenrollManyBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -81,10 +83,12 @@ constructor( private var validated: Boolean = false fun validate(): HrisBenefitIndividualUnenrollManyBody = apply { - if (!validated) { - individualIds() - validated = true + if (validated) { + return@apply } + + individualIds() + validated = true } fun toBuilder() = Builder().from(this) @@ -94,7 +98,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [HrisBenefitIndividualUnenrollManyBody]. */ + class Builder internal constructor() { private var individualIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -183,8 +188,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisBenefitIndividualUnenrollManyParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var benefitId: String? = null private var body: HrisBenefitIndividualUnenrollManyBody.Builder = @@ -336,7 +342,7 @@ constructor( fun build(): HrisBenefitIndividualUnenrollManyParams = HrisBenefitIndividualUnenrollManyParams( - checkNotNull(benefitId) { "`benefitId` is required but was not set" }, + checkRequired("benefitId", benefitId), body.build(), additionalHeaders.build(), additionalQueryParams.build(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPage.kt index 5c9d3159..dcfd510d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPage.kt @@ -19,6 +19,7 @@ import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** List all company-wide deductions and contributions. */ class HrisBenefitListPage private constructor( private val benefitsService: BenefitService, @@ -78,8 +79,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun items(): List = items.getNullable("items") ?: listOf() @JsonProperty("items") @@ -89,11 +88,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - items().map { it.validate() } - validated = true + if (validated) { + return@apply } + + items().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -139,8 +142,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisBenefitListPage, ) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPageAsync.kt index ad78a2d4..600505e0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPageAsync.kt @@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** List all company-wide deductions and contributions. */ class HrisBenefitListPageAsync private constructor( private val benefitsService: BenefitServiceAsync, @@ -85,8 +86,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun items(): List = items.getNullable("items") ?: listOf() @JsonProperty("items") @@ -96,11 +95,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - items().map { it.validate() } - validated = true + if (validated) { + return@apply } + + items().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -146,8 +149,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisBenefitListPageAsync, ) { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListParams.kt index 00c1a49a..74a5d5b8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListParams.kt @@ -3,24 +3,25 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import java.util.Objects /** List all company-wide deductions and contributions. */ class HrisBenefitListParams -constructor( +private constructor( private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -29,8 +30,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisBenefitListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPage.kt index 95cd2dbe..25e77547 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPage.kt @@ -19,6 +19,7 @@ import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** Get deductions metadata */ class HrisBenefitListSupportedBenefitsPage private constructor( private val benefitsService: BenefitService, @@ -82,8 +83,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun items(): List = items.getNullable("items") ?: listOf() @JsonProperty("items") @@ -93,11 +92,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - items().map { it.validate() } - validated = true + if (validated) { + return@apply } + + items().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -143,8 +146,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisBenefitListSupportedBenefitsPage, ) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPageAsync.kt index e00f8e52..add12868 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPageAsync.kt @@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** Get deductions metadata */ class HrisBenefitListSupportedBenefitsPageAsync private constructor( private val benefitsService: BenefitServiceAsync, @@ -85,8 +86,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun items(): List = items.getNullable("items") ?: listOf() @JsonProperty("items") @@ -96,11 +95,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - items().map { it.validate() } - validated = true + if (validated) { + return@apply } + + items().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -146,8 +149,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisBenefitListSupportedBenefitsPageAsync, ) { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsParams.kt index ef04edfb..a5393797 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsParams.kt @@ -3,24 +3,25 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import java.util.Objects /** Get deductions metadata */ class HrisBenefitListSupportedBenefitsParams -constructor( +private constructor( private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -29,8 +30,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisBenefitListSupportedBenefitsParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitRetrieveParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitRetrieveParams.kt index d9f46dfa..05594957 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitRetrieveParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitRetrieveParams.kt @@ -3,17 +3,19 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +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 java.util.Objects /** Lists deductions and contributions information for a given item */ class HrisBenefitRetrieveParams -constructor( +private constructor( private val benefitId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun benefitId(): String = benefitId @@ -21,9 +23,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +41,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisBenefitRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var benefitId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -155,7 +158,7 @@ constructor( fun build(): HrisBenefitRetrieveParams = HrisBenefitRetrieveParams( - checkNotNull(benefitId) { "`benefitId` is required but was not set" }, + checkRequired("benefitId", benefitId), additionalHeaders.build(), additionalQueryParams.build(), ) 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 e42c44da..208bf30c 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 @@ -11,6 +11,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -20,12 +22,12 @@ import java.util.Optional /** Updates an existing company-wide deduction or contribution */ class HrisBenefitUpdateParams -constructor( +private constructor( private val benefitId: String, private val body: HrisBenefitUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun benefitId(): String = benefitId @@ -41,11 +43,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): HrisBenefitUpdateBody = body + @JvmSynthetic internal fun _body(): HrisBenefitUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -81,10 +83,12 @@ constructor( private var validated: Boolean = false fun validate(): HrisBenefitUpdateBody = apply { - if (!validated) { - description() - validated = true + if (validated) { + return@apply } + + description() + validated = true } fun toBuilder() = Builder().from(this) @@ -94,7 +98,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [HrisBenefitUpdateBody]. */ + class Builder internal constructor() { private var description: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -161,8 +166,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisBenefitUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var benefitId: String? = null private var body: HrisBenefitUpdateBody.Builder = HrisBenefitUpdateBody.builder() @@ -304,7 +310,7 @@ constructor( fun build(): HrisBenefitUpdateParams = HrisBenefitUpdateParams( - checkNotNull(benefitId) { "`benefitId` is required but was not set" }, + checkRequired("benefitId", benefitId), body.build(), additionalHeaders.build(), additionalQueryParams.build(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyRetrieveParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyRetrieveParams.kt index b33fe36f..f1eca56d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyRetrieveParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyRetrieveParams.kt @@ -3,24 +3,25 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import java.util.Objects /** Read basic company data */ class HrisCompanyRetrieveParams -constructor( +private constructor( private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -29,8 +30,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisCompanyRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPage.kt index b24aa8e9..41116b2f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPage.kt @@ -19,6 +19,8 @@ import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** Read company directory and organization structure */ +@Deprecated("use `list` instead") class HrisDirectoryListIndividualsPage private constructor( private val directoryService: DirectoryService, @@ -46,7 +48,12 @@ private constructor( "HrisDirectoryListIndividualsPage{directoryService=$directoryService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !individuals().isEmpty() + if (individuals().isEmpty()) { + return false + } + + return paging().offset().orElse(0) + individuals().count() < + paging().count().orElse(Long.MAX_VALUE) } fun getNextPageParams(): Optional { @@ -63,7 +70,6 @@ private constructor( } fun getNextPage(): Optional { - @Suppress("DEPRECATION") return getNextPageParams().map { directoryService.listIndividuals(it) } } @@ -95,8 +101,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun individuals(): List = individuals.getNullable("individuals") ?: listOf() @@ -113,12 +117,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - individuals().map { it.validate() } - paging().validate() - validated = true + if (validated) { + return@apply } + + individuals().map { it.validate() } + paging().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -178,8 +186,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisDirectoryListIndividualsPage, ) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageAsync.kt index b0d74067..0f336524 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageAsync.kt @@ -20,6 +20,8 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** Read company directory and organization structure */ +@Deprecated("use `list` instead") class HrisDirectoryListIndividualsPageAsync private constructor( private val directoryService: DirectoryServiceAsync, @@ -47,7 +49,12 @@ private constructor( "HrisDirectoryListIndividualsPageAsync{directoryService=$directoryService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !individuals().isEmpty() + if (individuals().isEmpty()) { + return false + } + + return paging().offset().orElse(0) + individuals().count() < + paging().count().orElse(Long.MAX_VALUE) } fun getNextPageParams(): Optional { @@ -64,7 +71,6 @@ private constructor( } fun getNextPage(): CompletableFuture> { - @Suppress("DEPRECATION") return getNextPageParams() .map { directoryService.listIndividuals(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } @@ -98,8 +104,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun individuals(): List = individuals.getNullable("individuals") ?: listOf() @@ -116,12 +120,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - individuals().map { it.validate() } - paging().validate() - validated = true + if (validated) { + return@apply } + + individuals().map { it.validate() } + paging().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -181,8 +189,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisDirectoryListIndividualsPageAsync, ) { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsParams.kt index 25dd34df..5eafd559 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsParams.kt @@ -3,19 +3,21 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import java.util.Objects import java.util.Optional /** Read company directory and organization structure */ +@Deprecated("use `list` instead") class HrisDirectoryListIndividualsParams -constructor( +private constructor( private val limit: Long?, private val offset: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** Number of employees to return (defaults to all) */ fun limit(): Optional = Optional.ofNullable(limit) @@ -27,10 +29,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.limit?.let { queryParams.put("limit", listOf(it.toString())) } this.offset?.let { queryParams.put("offset", listOf(it.toString())) } @@ -45,8 +46,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisDirectoryListIndividualsParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var limit: Long? = null private var offset: Long? = null diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPage.kt index fc5cb237..68aa5fb1 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPage.kt @@ -19,6 +19,7 @@ import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** Read company directory and organization structure */ class HrisDirectoryListPage private constructor( private val directoryService: DirectoryService, @@ -46,7 +47,12 @@ private constructor( "HrisDirectoryListPage{directoryService=$directoryService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !individuals().isEmpty() + if (individuals().isEmpty()) { + return false + } + + return paging().offset().orElse(0) + individuals().count() < + paging().count().orElse(Long.MAX_VALUE) } fun getNextPageParams(): Optional { @@ -94,8 +100,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun individuals(): List = individuals.getNullable("individuals") ?: listOf() @@ -112,12 +116,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - individuals().map { it.validate() } - paging().validate() - validated = true + if (validated) { + return@apply } + + individuals().map { it.validate() } + paging().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -177,8 +185,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisDirectoryListPage, ) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageAsync.kt index 75f3a775..e7587ae6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageAsync.kt @@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** Read company directory and organization structure */ class HrisDirectoryListPageAsync private constructor( private val directoryService: DirectoryServiceAsync, @@ -47,7 +48,12 @@ private constructor( "HrisDirectoryListPageAsync{directoryService=$directoryService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !individuals().isEmpty() + if (individuals().isEmpty()) { + return false + } + + return paging().offset().orElse(0) + individuals().count() < + paging().count().orElse(Long.MAX_VALUE) } fun getNextPageParams(): Optional { @@ -97,8 +103,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun individuals(): List = individuals.getNullable("individuals") ?: listOf() @@ -115,12 +119,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - individuals().map { it.validate() } - paging().validate() - validated = true + if (validated) { + return@apply } + + individuals().map { it.validate() } + paging().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -180,8 +188,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisDirectoryListPageAsync, ) { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListParams.kt index f68fca4d..000f255d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListParams.kt @@ -3,6 +3,7 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import java.util.Objects @@ -10,12 +11,12 @@ import java.util.Optional /** Read company directory and organization structure */ class HrisDirectoryListParams -constructor( +private constructor( private val limit: Long?, private val offset: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** Number of employees to return (defaults to all) */ fun limit(): Optional = Optional.ofNullable(limit) @@ -27,10 +28,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.limit?.let { queryParams.put("limit", listOf(it.toString())) } this.offset?.let { queryParams.put("offset", listOf(it.toString())) } @@ -45,8 +45,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisDirectoryListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var limit: Long? = null private var offset: Long? = null diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDocumentListParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDocumentListParams.kt index 410ee226..6d13fc3b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDocumentListParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDocumentListParams.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.tryfinch.api.core.Enum import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import com.tryfinch.api.core.toImmutable @@ -15,14 +16,14 @@ import java.util.Optional /** **Beta:** This endpoint is in beta and may change. Retrieve a list of company-wide documents. */ class HrisDocumentListParams -constructor( +private constructor( private val individualIds: List?, private val limit: Long?, private val offset: Long?, private val types: List?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** * Comma-delimited list of stable Finch uuids for each individual. If empty, defaults to all @@ -43,10 +44,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.individualIds?.let { queryParams.put("individual_ids[]", it.map(Any::toString)) } this.limit?.let { queryParams.put("limit", listOf(it.toString())) } @@ -63,8 +63,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisDocumentListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var individualIds: MutableList? = null private var limit: Long? = null @@ -250,6 +251,14 @@ 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 { @@ -261,17 +270,35 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { W4_2020, W4_2005, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { W4_2020, W4_2005, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { W4_2020 -> Value.W4_2020 @@ -279,6 +306,14 @@ constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { W4_2020 -> Known.W4_2020 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDocumentRetreiveParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDocumentRetreiveParams.kt index 8b4bdc2d..5fbb6079 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDocumentRetreiveParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDocumentRetreiveParams.kt @@ -3,6 +3,8 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +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 java.util.Objects @@ -12,11 +14,11 @@ import java.util.Objects * ID. */ class HrisDocumentRetreiveParams -constructor( +private constructor( private val documentId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun documentId(): String = documentId @@ -24,9 +26,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -42,8 +44,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisDocumentRetreiveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var documentId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -158,7 +161,7 @@ constructor( fun build(): HrisDocumentRetreiveParams = HrisDocumentRetreiveParams( - checkNotNull(documentId) { "`documentId` is required but was not set" }, + checkRequired("documentId", documentId), additionalHeaders.build(), additionalQueryParams.build(), ) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPage.kt index 71ea48eb..1ef955e2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPage.kt @@ -19,6 +19,7 @@ import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** Read individual employment and income data */ class HrisEmploymentRetrieveManyPage private constructor( private val employmentsService: EmploymentService, @@ -82,8 +83,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun responses(): List = responses.getNullable("responses") ?: listOf() @@ -95,11 +94,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - responses().map { it.validate() } - validated = true + if (validated) { + return@apply } + + responses().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -148,8 +151,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisEmploymentRetrieveManyPage, ) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageAsync.kt index 9c7d988d..f3dc9330 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageAsync.kt @@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** Read individual employment and income data */ class HrisEmploymentRetrieveManyPageAsync private constructor( private val employmentsService: EmploymentServiceAsync, @@ -85,8 +86,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun responses(): List = responses.getNullable("responses") ?: listOf() @@ -98,11 +97,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - responses().map { it.validate() } - validated = true + if (validated) { + return@apply } + + responses().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -151,8 +154,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisEmploymentRetrieveManyPageAsync, ) { 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 2e9a4b87..47a1156c 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 @@ -11,6 +11,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -19,11 +21,11 @@ import java.util.Objects /** Read individual employment and income data */ class HrisEmploymentRetrieveManyParams -constructor( +private constructor( private val body: HrisEmploymentRetrieveManyBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** The array of batch requests. */ fun requests(): List = body.requests() @@ -37,11 +39,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): HrisEmploymentRetrieveManyBody = body + @JvmSynthetic internal fun _body(): HrisEmploymentRetrieveManyBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams /** Individual Ids Request Body */ @NoAutoDetect @@ -70,10 +72,12 @@ constructor( private var validated: Boolean = false fun validate(): HrisEmploymentRetrieveManyBody = apply { - if (!validated) { - requests().forEach { it.validate() } - validated = true + if (validated) { + return@apply } + + requests().forEach { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -83,7 +87,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [HrisEmploymentRetrieveManyBody]. */ + class Builder internal constructor() { private var requests: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -139,8 +144,7 @@ constructor( fun build(): HrisEmploymentRetrieveManyBody = HrisEmploymentRetrieveManyBody( - checkNotNull(requests) { "`requests` is required but was not set" } - .map { it.toImmutable() }, + checkRequired("requests", requests).map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -170,8 +174,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisEmploymentRetrieveManyParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: HrisEmploymentRetrieveManyBody.Builder = HrisEmploymentRetrieveManyBody.builder() @@ -355,10 +360,12 @@ constructor( private var validated: Boolean = false fun validate(): Request = apply { - if (!validated) { - individualId() - validated = true + if (validated) { + return@apply } + + individualId() + validated = true } fun toBuilder() = Builder().from(this) @@ -368,7 +375,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Request]. */ + class Builder internal constructor() { private var individualId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -416,7 +424,7 @@ constructor( fun build(): Request = Request( - checkNotNull(individualId) { "`individualId` is required but was not set" }, + checkRequired("individualId", individualId), additionalProperties.toImmutable() ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPage.kt index 72a1d20e..30c5ab22 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPage.kt @@ -19,6 +19,7 @@ import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** Read individual data, excluding income and employment data */ class HrisIndividualRetrieveManyPage private constructor( private val individualsService: IndividualService, @@ -82,8 +83,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun responses(): List = responses.getNullable("responses") ?: listOf() @JsonProperty("responses") @@ -94,11 +93,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - responses().map { it.validate() } - validated = true + if (validated) { + return@apply } + + responses().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -146,8 +149,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisIndividualRetrieveManyPage, ) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageAsync.kt index efdfe58a..62e2a9c6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageAsync.kt @@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** Read individual data, excluding income and employment data */ class HrisIndividualRetrieveManyPageAsync private constructor( private val individualsService: IndividualServiceAsync, @@ -85,8 +86,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun responses(): List = responses.getNullable("responses") ?: listOf() @JsonProperty("responses") @@ -97,11 +96,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - responses().map { it.validate() } - validated = true + if (validated) { + return@apply } + + responses().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -149,8 +152,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisIndividualRetrieveManyPageAsync, ) { 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 2aca8f6e..c63cd80a 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import com.tryfinch.api.core.immutableEmptyMap @@ -20,11 +21,11 @@ import java.util.Optional /** Read individual data, excluding income and employment data */ class HrisIndividualRetrieveManyParams -constructor( +private constructor( private val body: HrisIndividualRetrieveManyBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun options(): Optional = body.options() @@ -40,11 +41,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): HrisIndividualRetrieveManyBody = body + @JvmSynthetic internal fun _body(): HrisIndividualRetrieveManyBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect class HrisIndividualRetrieveManyBody @@ -78,11 +79,13 @@ constructor( private var validated: Boolean = false fun validate(): HrisIndividualRetrieveManyBody = apply { - if (!validated) { - options().map { it.validate() } - requests().map { it.forEach { it.validate() } } - validated = true + if (validated) { + return@apply } + + options().ifPresent { it.validate() } + requests().ifPresent { it.forEach { it.validate() } } + validated = true } fun toBuilder() = Builder().from(this) @@ -92,7 +95,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [HrisIndividualRetrieveManyBody]. */ + class Builder internal constructor() { private var options: JsonField = JsonMissing.of() private var requests: JsonField>? = null @@ -184,8 +188,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisIndividualRetrieveManyParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: HrisIndividualRetrieveManyBody.Builder = HrisIndividualRetrieveManyBody.builder() @@ -360,10 +365,12 @@ constructor( private var validated: Boolean = false fun validate(): Options = apply { - if (!validated) { - include() - validated = true + if (validated) { + return@apply } + + include() + validated = true } fun toBuilder() = Builder().from(this) @@ -373,7 +380,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Options]. */ + class Builder internal constructor() { private var include: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -472,10 +480,12 @@ constructor( private var validated: Boolean = false fun validate(): Request = apply { - if (!validated) { - individualId() - validated = true + if (validated) { + return@apply } + + individualId() + validated = true } fun toBuilder() = Builder().from(this) @@ -485,7 +495,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Request]. */ + class Builder internal constructor() { private var individualId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPage.kt index 0c3034b0..3343773b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPage.kt @@ -19,6 +19,11 @@ import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * Read detailed pay statements for each individual. + * + * Deduction and contribution types are supported by the payroll systems that supports Benefits. + */ class HrisPayStatementRetrieveManyPage private constructor( private val payStatementsService: PayStatementService, @@ -82,8 +87,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun responses(): List = responses.getNullable("responses") ?: listOf() @JsonProperty("responses") @@ -94,11 +97,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - responses().map { it.validate() } - validated = true + if (validated) { + return@apply } + + responses().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -147,8 +154,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisPayStatementRetrieveManyPage, ) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageAsync.kt index 84291ccb..8402cb89 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageAsync.kt @@ -20,6 +20,11 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * Read detailed pay statements for each individual. + * + * Deduction and contribution types are supported by the payroll systems that supports Benefits. + */ class HrisPayStatementRetrieveManyPageAsync private constructor( private val payStatementsService: PayStatementServiceAsync, @@ -85,8 +90,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun responses(): List = responses.getNullable("responses") ?: listOf() @JsonProperty("responses") @@ -97,11 +100,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - responses().map { it.validate() } - validated = true + if (validated) { + return@apply } + + responses().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -150,8 +157,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisPayStatementRetrieveManyPageAsync, ) { 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 a3e8ac70..2bd05098 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 @@ -11,6 +11,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -24,11 +26,11 @@ import java.util.Optional * Deduction and contribution types are supported by the payroll systems that supports Benefits. */ class HrisPayStatementRetrieveManyParams -constructor( +private constructor( private val body: HrisPayStatementRetrieveManyBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** The array of batch requests. */ fun requests(): List = body.requests() @@ -42,11 +44,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): HrisPayStatementRetrieveManyBody = body + @JvmSynthetic internal fun _body(): HrisPayStatementRetrieveManyBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect class HrisPayStatementRetrieveManyBody @@ -74,10 +76,12 @@ constructor( private var validated: Boolean = false fun validate(): HrisPayStatementRetrieveManyBody = apply { - if (!validated) { - requests().forEach { it.validate() } - validated = true + if (validated) { + return@apply } + + requests().forEach { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -87,7 +91,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [HrisPayStatementRetrieveManyBody]. */ + class Builder internal constructor() { private var requests: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -143,8 +148,7 @@ constructor( fun build(): HrisPayStatementRetrieveManyBody = HrisPayStatementRetrieveManyBody( - checkNotNull(requests) { "`requests` is required but was not set" } - .map { it.toImmutable() }, + checkRequired("requests", requests).map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -174,8 +178,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisPayStatementRetrieveManyParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: HrisPayStatementRetrieveManyBody.Builder = HrisPayStatementRetrieveManyBody.builder() @@ -367,12 +372,14 @@ constructor( private var validated: Boolean = false fun validate(): Request = apply { - if (!validated) { - paymentId() - limit() - offset() - validated = true + if (validated) { + return@apply } + + paymentId() + limit() + offset() + validated = true } fun toBuilder() = Builder().from(this) @@ -382,7 +389,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Request]. */ + class Builder internal constructor() { private var paymentId: JsonField? = null private var limit: JsonField = JsonMissing.of() @@ -436,7 +444,7 @@ constructor( fun build(): Request = Request( - checkNotNull(paymentId) { "`paymentId` is required but was not set" }, + checkRequired("paymentId", paymentId), limit, offset, additionalProperties.toImmutable(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPage.kt index 8b7c0854..21e1d194 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPage.kt @@ -19,6 +19,7 @@ import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** Read payroll and contractor related payments by the company. */ class HrisPaymentListPage private constructor( private val paymentsService: PaymentService, @@ -77,8 +78,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun items(): List = items.getNullable("items") ?: listOf() @JsonProperty("items") @@ -88,11 +87,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - items().map { it.validate() } - validated = true + if (validated) { + return@apply } + + items().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -138,8 +141,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisPaymentListPage, ) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPageAsync.kt index f84e657c..90b5f23f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPageAsync.kt @@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** Read payroll and contractor related payments by the company. */ class HrisPaymentListPageAsync private constructor( private val paymentsService: PaymentServiceAsync, @@ -84,8 +85,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun items(): List = items.getNullable("items") ?: listOf() @JsonProperty("items") @@ -95,11 +94,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - items().map { it.validate() } - validated = true + if (validated) { + return@apply } + + items().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -145,8 +148,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: HrisPaymentListPageAsync, ) { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListParams.kt index 2d372bb9..f0dc741f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListParams.kt @@ -3,6 +3,8 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +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 java.time.LocalDate @@ -10,12 +12,12 @@ import java.util.Objects /** Read payroll and contractor related payments by the company. */ class HrisPaymentListParams -constructor( +private constructor( private val endDate: LocalDate, private val startDate: LocalDate, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** The end date to retrieve payments by a company (inclusive) in `YYYY-MM-DD` format. */ fun endDate(): LocalDate = endDate @@ -27,10 +29,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.endDate.let { queryParams.put("end_date", listOf(it.toString())) } this.startDate.let { queryParams.put("start_date", listOf(it.toString())) } @@ -45,8 +46,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [HrisPaymentListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var endDate: LocalDate? = null private var startDate: LocalDate? = null @@ -167,8 +169,8 @@ constructor( fun build(): HrisPaymentListParams = HrisPaymentListParams( - checkNotNull(endDate) { "`endDate` is required but was not set" }, - checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), additionalHeaders.build(), additionalQueryParams.build(), ) 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 302b43e2..28c6cfb7 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 @@ -78,13 +78,15 @@ private constructor( private var validated: Boolean = false fun validate(): Income = apply { - if (!validated) { - amount() - currency() - effectiveDate() - unit() - validated = true + if (validated) { + return@apply } + + amount() + currency() + effectiveDate() + unit() + validated = true } fun toBuilder() = Builder().from(this) @@ -94,7 +96,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Income]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -193,12 +196,24 @@ private constructor( ) } + /** + * The income unit of payment. Options: `yearly`, `quarterly`, `monthly`, `semi_monthly`, + * `bi_weekly`, `weekly`, `daily`, `hourly`, and `fixed`. + */ class Unit @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 { @@ -224,6 +239,7 @@ private constructor( @JvmStatic fun of(value: String) = Unit(JsonField.of(value)) } + /** An enum containing [Unit]'s known values. */ enum class Known { YEARLY, QUARTERLY, @@ -236,6 +252,15 @@ private constructor( FIXED, } + /** + * An enum containing [Unit]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Unit] 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 { YEARLY, QUARTERLY, @@ -246,9 +271,17 @@ private constructor( DAILY, HOURLY, FIXED, + /** An enum member indicating that [Unit] 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) { YEARLY -> Value.YEARLY @@ -263,6 +296,14 @@ private constructor( 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) { YEARLY -> Known.YEARLY 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 12cf5231..b26b4aba 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 @@ -160,22 +160,24 @@ private constructor( private var validated: Boolean = false fun validate(): Individual = apply { - if (!validated) { - id() - dob() - emails().map { it.forEach { it.validate() } } - encryptedSsn() - ethnicity() - firstName() - gender() - lastName() - middleName() - phoneNumbers().map { it.forEach { it?.validate() } } - preferredName() - residence().map { it.validate() } - ssn() - validated = true + if (validated) { + return@apply } + + id() + dob() + emails().ifPresent { it.forEach { it.validate() } } + encryptedSsn() + ethnicity() + firstName() + gender() + lastName() + middleName() + phoneNumbers().ifPresent { it.forEach { it?.validate() } } + preferredName() + residence().ifPresent { it.validate() } + ssn() + validated = true } fun toBuilder() = Builder().from(this) @@ -185,7 +187,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Individual]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var dob: JsonField = JsonMissing.of() @@ -449,11 +452,13 @@ private constructor( private var validated: Boolean = false fun validate(): Email = apply { - if (!validated) { - data() - type() - validated = true + if (validated) { + return@apply } + + data() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -463,7 +468,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Email]. */ + class Builder internal constructor() { private var data: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -519,6 +525,14 @@ 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 { @@ -530,17 +544,35 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { WORK, PERSONAL, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { WORK, PERSONAL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { WORK -> Value.WORK @@ -548,6 +580,15 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { WORK -> Known.WORK @@ -588,12 +629,21 @@ private constructor( "Email{data=$data, type=$type, additionalProperties=$additionalProperties}" } + /** The EEOC-defined ethnicity of the individual. */ class Ethnicity @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -618,6 +668,7 @@ private constructor( @JvmStatic fun of(value: String) = Ethnicity(JsonField.of(value)) } + /** An enum containing [Ethnicity]'s known values. */ enum class Known { ASIAN, WHITE, @@ -629,6 +680,15 @@ private constructor( DECLINE_TO_SPECIFY, } + /** + * An enum containing [Ethnicity]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Ethnicity] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { ASIAN, WHITE, @@ -638,9 +698,19 @@ private constructor( HISPANIC_OR_LATINO, TWO_OR_MORE_RACES, DECLINE_TO_SPECIFY, + /** + * An enum member indicating that [Ethnicity] 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) { ASIAN -> Value.ASIAN @@ -654,6 +724,14 @@ private constructor( 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) { ASIAN -> Known.ASIAN @@ -682,12 +760,21 @@ private constructor( override fun toString() = value.toString() } + /** The gender of the individual. */ class Gender @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 { @@ -703,6 +790,7 @@ private constructor( @JvmStatic fun of(value: String) = Gender(JsonField.of(value)) } + /** An enum containing [Gender]'s known values. */ enum class Known { FEMALE, MALE, @@ -710,14 +798,31 @@ private constructor( DECLINE_TO_SPECIFY, } + /** + * An enum containing [Gender]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Gender] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { FEMALE, MALE, OTHER, DECLINE_TO_SPECIFY, + /** An enum member indicating that [Gender] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { FEMALE -> Value.FEMALE @@ -727,6 +832,14 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { FEMALE -> Known.FEMALE @@ -778,11 +891,13 @@ private constructor( private var validated: Boolean = false fun validate(): PhoneNumber = apply { - if (!validated) { - data() - type() - validated = true + if (validated) { + return@apply } + + data() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -792,7 +907,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PhoneNumber]. */ + class Builder internal constructor() { private var data: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -850,6 +966,14 @@ 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 { @@ -861,17 +985,35 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { WORK, PERSONAL, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { WORK, PERSONAL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { WORK -> Value.WORK @@ -879,6 +1021,15 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { WORK -> Known.WORK 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 5d784e1a..f0d60f8a 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 @@ -52,12 +52,14 @@ private constructor( private var validated: Boolean = false fun validate(): IndividualBenefit = apply { - if (!validated) { - body().map { it.validate() } - code() - individualId() - validated = true + if (validated) { + return@apply } + + body().ifPresent { it.validate() } + code() + individualId() + validated = true } fun toBuilder() = Builder().from(this) @@ -67,7 +69,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [IndividualBenefit]. */ + class Builder internal constructor() { private var body: JsonField = JsonMissing.of() private var code: JsonField = JsonMissing.of() @@ -198,14 +201,16 @@ private constructor( private var validated: Boolean = false fun validate(): Body = apply { - if (!validated) { - annualMaximum() - catchUp() - companyContribution().map { it.validate() } - employeeDeduction().map { it.validate() } - hsaContributionLimit() - validated = true + if (validated) { + return@apply } + + annualMaximum() + catchUp() + companyContribution().ifPresent { it.validate() } + employeeDeduction().ifPresent { it.validate() } + hsaContributionLimit() + validated = true } fun toBuilder() = Builder().from(this) @@ -215,7 +220,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Body]. */ + class Builder internal constructor() { private var annualMaximum: JsonField = JsonMissing.of() private var catchUp: JsonField = JsonMissing.of() @@ -340,12 +346,21 @@ private constructor( ) } + /** Type for HSA contribution limit if the benefit is a HSA. */ class HsaContributionLimit @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 { @@ -357,17 +372,40 @@ private constructor( @JvmStatic fun of(value: String) = HsaContributionLimit(JsonField.of(value)) } + /** An enum containing [HsaContributionLimit]'s known values. */ enum class Known { INDIVIDUAL, FAMILY, } + /** + * An enum containing [HsaContributionLimit]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [HsaContributionLimit] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { INDIVIDUAL, FAMILY, + /** + * An enum member indicating that [HsaContributionLimit] was instantiated with an + * unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { INDIVIDUAL -> Value.INDIVIDUAL @@ -375,6 +413,15 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { INDIVIDUAL -> Known.INDIVIDUAL 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 f357d9ca..4d93c7c2 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import java.util.Objects @@ -45,11 +46,13 @@ private constructor( private var validated: Boolean = false fun validate(): IndividualEnrolledIdsResponse = apply { - if (!validated) { - benefitId() - individualIds() - validated = true + if (validated) { + return@apply } + + benefitId() + individualIds() + validated = true } fun toBuilder() = Builder().from(this) @@ -59,7 +62,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [IndividualEnrolledIdsResponse]. */ + class Builder internal constructor() { private var benefitId: JsonField? = null private var individualIds: JsonField>? = null @@ -116,9 +120,8 @@ private constructor( fun build(): IndividualEnrolledIdsResponse = IndividualEnrolledIdsResponse( - checkNotNull(benefitId) { "`benefitId` is required but was not set" }, - checkNotNull(individualIds) { "`individualIds` is required but was not set" } - .map { it.toImmutable() }, + checkRequired("benefitId", benefitId), + checkRequired("individualIds", individualIds).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } 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 2ddad75f..c380b159 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -42,13 +43,13 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - fun accountId(): String = accountId.getRequired("account_id") + @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - fun companyId(): String = companyId.getRequired("company_id") + @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") /** Unique Finch ID of the connection associated with the webhook event. */ fun connectionId(): Optional = @@ -62,13 +63,19 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ @JsonProperty("connection_id") @@ -93,14 +100,16 @@ private constructor( private var validated: Boolean = false fun validate(): IndividualEvent = apply { - if (!validated) { - accountId() - companyId() - connectionId() - data().map { it.validate() } - eventType() - validated = true + if (validated) { + return@apply } + + accountId() + companyId() + connectionId() + data().ifPresent { it.validate() } + eventType() + validated = true } fun toBuilder() = Builder().from(this) @@ -110,7 +119,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [IndividualEvent]. */ + class Builder internal constructor() { private var accountId: JsonField? = null private var companyId: JsonField? = null @@ -133,24 +143,28 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: String) = accountId(JsonField.of(accountId)) /** * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: JsonField) = apply { this.accountId = accountId } /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** Unique Finch ID of the connection associated with the webhook event. */ @@ -190,8 +204,8 @@ private constructor( fun build(): IndividualEvent = IndividualEvent( - checkNotNull(accountId) { "`accountId` is required but was not set" }, - checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkRequired("accountId", accountId), + checkRequired("companyId", companyId), connectionId, data, eventType, @@ -226,10 +240,12 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - individualId() - validated = true + if (validated) { + return@apply } + + individualId() + validated = true } fun toBuilder() = Builder().from(this) @@ -239,7 +255,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { private var individualId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -304,6 +321,14 @@ 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 { @@ -317,19 +342,39 @@ private constructor( @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) } + /** An enum containing [EventType]'s known values. */ enum class Known { INDIVIDUAL_CREATED, INDIVIDUAL_UPDATED, INDIVIDUAL_DELETED, } + /** + * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { INDIVIDUAL_CREATED, INDIVIDUAL_UPDATED, INDIVIDUAL_DELETED, + /** + * An enum member indicating that [EventType] was instantiated with an unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { INDIVIDUAL_CREATED -> Value.INDIVIDUAL_CREATED @@ -338,6 +383,14 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { INDIVIDUAL_CREATED -> Known.INDIVIDUAL_CREATED 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 1bf98637..fe785bc0 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 @@ -94,16 +94,18 @@ private constructor( private var validated: Boolean = false fun validate(): IndividualInDirectory = apply { - if (!validated) { - id() - department().map { it.validate() } - firstName() - isActive() - lastName() - manager().map { it.validate() } - middleName() - validated = true + if (validated) { + return@apply } + + id() + department().ifPresent { it.validate() } + firstName() + isActive() + lastName() + manager().ifPresent { it.validate() } + middleName() + validated = true } fun toBuilder() = Builder().from(this) @@ -113,7 +115,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [IndividualInDirectory]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var department: JsonField = JsonMissing.of() @@ -257,10 +260,12 @@ private constructor( private var validated: Boolean = false fun validate(): Department = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -270,7 +275,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Department]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -353,10 +359,12 @@ private constructor( private var validated: Boolean = false fun validate(): Manager = apply { - if (!validated) { - id() - validated = true + if (validated) { + return@apply } + + id() + validated = true } fun toBuilder() = Builder().from(this) @@ -366,7 +374,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Manager]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() 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 7bf461f2..d4fb4462 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 @@ -52,12 +52,14 @@ private constructor( private var validated: Boolean = false fun validate(): IndividualResponse = apply { - if (!validated) { - body().map { it.validate() } - code() - individualId() - validated = true + if (validated) { + return@apply } + + body().ifPresent { it.validate() } + code() + individualId() + validated = true } fun toBuilder() = Builder().from(this) @@ -67,7 +69,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [IndividualResponse]. */ + class Builder internal constructor() { private var body: JsonField = JsonMissing.of() private var code: JsonField = JsonMissing.of() 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 b70a9897..d1864f48 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 @@ -160,22 +160,24 @@ private constructor( private var validated: Boolean = false fun validate(): IndividualUpdateResponse = apply { - if (!validated) { - id() - dob() - emails().map { it.forEach { it.validate() } } - encryptedSsn() - ethnicity() - firstName() - gender() - lastName() - middleName() - phoneNumbers().map { it.forEach { it?.validate() } } - preferredName() - residence().map { it.validate() } - ssn() - validated = true + if (validated) { + return@apply } + + id() + dob() + emails().ifPresent { it.forEach { it.validate() } } + encryptedSsn() + ethnicity() + firstName() + gender() + lastName() + middleName() + phoneNumbers().ifPresent { it.forEach { it?.validate() } } + preferredName() + residence().ifPresent { it.validate() } + ssn() + validated = true } fun toBuilder() = Builder().from(this) @@ -185,7 +187,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [IndividualUpdateResponse]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var dob: JsonField = JsonMissing.of() @@ -449,11 +452,13 @@ private constructor( private var validated: Boolean = false fun validate(): Email = apply { - if (!validated) { - data() - type() - validated = true + if (validated) { + return@apply } + + data() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -463,7 +468,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Email]. */ + class Builder internal constructor() { private var data: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -519,6 +525,14 @@ 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 { @@ -530,17 +544,35 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { WORK, PERSONAL, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { WORK, PERSONAL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { WORK -> Value.WORK @@ -548,6 +580,15 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { WORK -> Known.WORK @@ -588,12 +629,21 @@ private constructor( "Email{data=$data, type=$type, additionalProperties=$additionalProperties}" } + /** The EEOC-defined ethnicity of the individual. */ class Ethnicity @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -618,6 +668,7 @@ private constructor( @JvmStatic fun of(value: String) = Ethnicity(JsonField.of(value)) } + /** An enum containing [Ethnicity]'s known values. */ enum class Known { ASIAN, WHITE, @@ -629,6 +680,15 @@ private constructor( DECLINE_TO_SPECIFY, } + /** + * An enum containing [Ethnicity]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Ethnicity] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { ASIAN, WHITE, @@ -638,9 +698,19 @@ private constructor( HISPANIC_OR_LATINO, TWO_OR_MORE_RACES, DECLINE_TO_SPECIFY, + /** + * An enum member indicating that [Ethnicity] 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) { ASIAN -> Value.ASIAN @@ -654,6 +724,14 @@ private constructor( 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) { ASIAN -> Known.ASIAN @@ -682,12 +760,21 @@ private constructor( override fun toString() = value.toString() } + /** The gender of the individual. */ class Gender @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 { @@ -703,6 +790,7 @@ private constructor( @JvmStatic fun of(value: String) = Gender(JsonField.of(value)) } + /** An enum containing [Gender]'s known values. */ enum class Known { FEMALE, MALE, @@ -710,14 +798,31 @@ private constructor( DECLINE_TO_SPECIFY, } + /** + * An enum containing [Gender]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Gender] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { FEMALE, MALE, OTHER, DECLINE_TO_SPECIFY, + /** An enum member indicating that [Gender] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { FEMALE -> Value.FEMALE @@ -727,6 +832,14 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { FEMALE -> Known.FEMALE @@ -778,11 +891,13 @@ private constructor( private var validated: Boolean = false fun validate(): PhoneNumber = apply { - if (!validated) { - data() - type() - validated = true + if (validated) { + return@apply } + + data() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -792,7 +907,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PhoneNumber]. */ + class Builder internal constructor() { private var data: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -848,6 +964,14 @@ 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 { @@ -859,17 +983,35 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { WORK, PERSONAL, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { WORK, PERSONAL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { WORK -> Value.WORK @@ -877,6 +1019,15 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { WORK -> Known.WORK 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 2bc6b92f..16b78e12 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -77,7 +78,7 @@ private constructor( * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of this * account ID. */ - fun accountId(): String = accountId.getRequired("account_id") + @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") fun authenticationMethods(): List = authenticationMethods.getRequired("authentication_methods") @@ -92,7 +93,7 @@ private constructor( * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of this * company ID. */ - fun companyId(): String = companyId.getRequired("company_id") + @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") /** The Finch UUID of the connection associated with the `access_token`. */ fun connectionId(): String = connectionId.getRequired("connection_id") @@ -135,6 +136,7 @@ private constructor( /** * [DEPRECATED] Use `provider_id` to identify the provider instead of this payroll provider ID. */ + @Deprecated("deprecated") fun payrollProviderId(): String = payrollProviderId.getRequired("payroll_provider_id") /** An array of the authorized products associated with the `access_token`. */ @@ -150,7 +152,10 @@ private constructor( * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of this * account ID. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId @JsonProperty("authentication_methods") @ExcludeMissing @@ -168,7 +173,10 @@ private constructor( * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of this * company ID. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId /** The Finch UUID of the connection associated with the `access_token`. */ @JsonProperty("connection_id") @@ -219,6 +227,7 @@ private constructor( /** * [DEPRECATED] Use `provider_id` to identify the provider instead of this payroll provider ID. */ + @Deprecated("deprecated") @JsonProperty("payroll_provider_id") @ExcludeMissing fun _payrollProviderId(): JsonField = payrollProviderId @@ -239,25 +248,27 @@ private constructor( private var validated: Boolean = false fun validate(): Introspection = apply { - if (!validated) { - accountId() - authenticationMethods().forEach { it.validate() } - clientId() - clientType() - companyId() - connectionId() - connectionStatus().validate() - connectionType() - customerEmail() - customerId() - customerName() - manual() - payrollProviderId() - products() - providerId() - username() - validated = true + if (validated) { + return@apply } + + accountId() + authenticationMethods().forEach { it.validate() } + clientId() + clientType() + companyId() + connectionId() + connectionStatus().validate() + connectionType() + customerEmail() + customerId() + customerName() + manual() + payrollProviderId() + products() + providerId() + username() + validated = true } fun toBuilder() = Builder().from(this) @@ -267,7 +278,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Introspection]. */ + class Builder internal constructor() { private var accountId: JsonField? = null private var authenticationMethods: JsonField>? = null @@ -312,12 +324,14 @@ private constructor( * [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)) /** * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of * this account ID. */ + @Deprecated("deprecated") fun accountId(accountId: JsonField) = apply { this.accountId = accountId } fun authenticationMethods(authenticationMethods: List) = @@ -357,12 +371,14 @@ private constructor( * [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)) /** * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of * this company ID. */ + @Deprecated("deprecated") fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** The Finch UUID of the connection associated with the `access_token`. */ @@ -473,6 +489,7 @@ private constructor( * [DEPRECATED] Use `provider_id` to identify the provider instead of this payroll provider * ID. */ + @Deprecated("deprecated") fun payrollProviderId(payrollProviderId: String) = payrollProviderId(JsonField.of(payrollProviderId)) @@ -480,6 +497,7 @@ private constructor( * [DEPRECATED] Use `provider_id` to identify the provider instead of this payroll provider * ID. */ + @Deprecated("deprecated") fun payrollProviderId(payrollProviderId: JsonField) = apply { this.payrollProviderId = payrollProviderId } @@ -539,28 +557,24 @@ private constructor( fun build(): Introspection = Introspection( - checkNotNull(accountId) { "`accountId` is required but was not set" }, - checkNotNull(authenticationMethods) { - "`authenticationMethods` is required but was not set" - } - .map { it.toImmutable() }, - checkNotNull(clientId) { "`clientId` is required but was not set" }, - checkNotNull(clientType) { "`clientType` is required but was not set" }, - checkNotNull(companyId) { "`companyId` is required but was not set" }, - checkNotNull(connectionId) { "`connectionId` is required but was not set" }, - checkNotNull(connectionStatus) { "`connectionStatus` is required but was not set" }, - checkNotNull(connectionType) { "`connectionType` is required but was not set" }, - checkNotNull(customerEmail) { "`customerEmail` is required but was not set" }, - checkNotNull(customerId) { "`customerId` is required but was not set" }, - checkNotNull(customerName) { "`customerName` is required but was not set" }, - checkNotNull(manual) { "`manual` is required but was not set" }, - checkNotNull(payrollProviderId) { - "`payrollProviderId` is required but was not set" + checkRequired("accountId", accountId), + checkRequired("authenticationMethods", authenticationMethods).map { + it.toImmutable() }, - checkNotNull(products) { "`products` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(providerId) { "`providerId` is required but was not set" }, - checkNotNull(username) { "`username` is required but was not set" }, + 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), additionalProperties.toImmutable(), ) } @@ -609,12 +623,14 @@ private constructor( private var validated: Boolean = false fun validate(): AuthenticationMethod = apply { - if (!validated) { - connectionStatus().map { it.validate() } - products() - type() - validated = true + if (validated) { + return@apply } + + connectionStatus().ifPresent { it.validate() } + products() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -624,7 +640,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AuthenticationMethod]. */ + class Builder internal constructor() { private var connectionStatus: JsonField = JsonMissing.of() private var products: JsonField>? = null @@ -734,11 +751,13 @@ private constructor( private var validated: Boolean = false fun validate(): ConnectionStatus = apply { - if (!validated) { - message() - status() - validated = true + if (validated) { + return@apply } + + message() + status() + validated = true } fun toBuilder() = Builder().from(this) @@ -748,7 +767,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ConnectionStatus]. */ + class Builder internal constructor() { private var message: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() @@ -817,12 +837,21 @@ private constructor( "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 { @@ -840,6 +869,7 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { ASSISTED, CREDENTIAL, @@ -848,15 +878,32 @@ private constructor( 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 @@ -867,6 +914,15 @@ private constructor( 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 @@ -910,12 +966,21 @@ private constructor( "AuthenticationMethod{connectionStatus=$connectionStatus, products=$products, type=$type, additionalProperties=$additionalProperties}" } + /** The type of application associated with a token. */ class ClientType @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 { @@ -929,19 +994,39 @@ private constructor( @JvmStatic fun of(value: String) = ClientType(JsonField.of(value)) } + /** An enum containing [ClientType]'s known values. */ enum class Known { PRODUCTION, DEVELOPMENT, SANDBOX, } + /** + * An enum containing [ClientType]'s known values, as well as an [_UNKNOWN] member. + * + * 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. + */ enum class Value { PRODUCTION, DEVELOPMENT, SANDBOX, + /** + * An enum member indicating that [ClientType] 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) { PRODUCTION -> Value.PRODUCTION @@ -950,6 +1035,14 @@ private constructor( 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) { PRODUCTION -> Known.PRODUCTION @@ -1005,11 +1098,13 @@ private constructor( private var validated: Boolean = false fun validate(): ConnectionStatus = apply { - if (!validated) { - message() - status() - validated = true + if (validated) { + return@apply } + + message() + status() + validated = true } fun toBuilder() = Builder().from(this) @@ -1019,7 +1114,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ConnectionStatus]. */ + class Builder internal constructor() { private var message: JsonField = JsonMissing.of() private var status: JsonField = JsonMissing.of() @@ -1085,12 +1181,25 @@ private constructor( "ConnectionStatus{message=$message, status=$status, additionalProperties=$additionalProperties}" } + /** + * 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. + * + * 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 { @@ -1102,17 +1211,38 @@ private constructor( @JvmStatic fun of(value: String) = ConnectionType(JsonField.of(value)) } + /** An enum containing [ConnectionType]'s known values. */ enum class Known { PROVIDER, FINCH, } + /** + * 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, } + /** + * 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 @@ -1120,6 +1250,14 @@ private constructor( 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) { PROVIDER -> Known.PROVIDER 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 b977af66..9e723312 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 @@ -21,6 +21,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.getOrThrow import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams @@ -47,11 +49,11 @@ import kotlin.jvm.optionals.getOrNull * endpoint, please contact your Finch account manager. */ class JobAutomatedCreateParams -constructor( +private constructor( private val body: JobAutomatedCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun dataSyncAll(): Optional = body.dataSyncAll() @@ -61,11 +63,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): JobAutomatedCreateBody = body + @JvmSynthetic internal fun _body(): JobAutomatedCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams @JsonDeserialize(using = JobAutomatedCreateBody.Deserializer::class) @JsonSerialize(using = JobAutomatedCreateBody.Serializer::class) @@ -130,18 +132,32 @@ constructor( JobAutomatedCreateBody(w4FormEmployeeSync = w4FormEmployeeSync) } + /** + * An interface that defines how to map each variant of [JobAutomatedCreateBody] to a value + * of type [T]. + */ interface Visitor { fun visitDataSyncAll(dataSyncAll: DataSyncAll): T fun visitW4FormEmployeeSync(w4FormEmployeeSync: W4FormEmployeeSync): T + /** + * Maps an unknown variant of [JobAutomatedCreateBody] to a value of type [T]. + * + * An instance of [JobAutomatedCreateBody] 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 JobAutomatedCreateBody: $json") } } - class Deserializer : + internal class Deserializer : BaseDeserializer(JobAutomatedCreateBody::class) { override fun ObjectCodec.deserialize(node: JsonNode): JobAutomatedCreateBody { @@ -165,7 +181,8 @@ constructor( } } - class Serializer : BaseSerializer(JobAutomatedCreateBody::class) { + internal class Serializer : + BaseSerializer(JobAutomatedCreateBody::class) { override fun serialize( value: JobAutomatedCreateBody, @@ -190,8 +207,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [JobAutomatedCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: JobAutomatedCreateBody? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -340,10 +358,12 @@ constructor( private var validated: Boolean = false fun validate(): DataSyncAll = apply { - if (!validated) { - type() - validated = true + if (validated) { + return@apply } + + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -353,7 +373,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [DataSyncAll]. */ + class Builder internal constructor() { private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -390,18 +411,24 @@ constructor( } fun build(): DataSyncAll = - DataSyncAll( - checkNotNull(type) { "`type` is required but was not set" }, - additionalProperties.toImmutable() - ) + DataSyncAll(checkRequired("type", type), additionalProperties.toImmutable()) } + /** The type of job to start. */ class Type @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -411,21 +438,48 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { DATA_SYNC_ALL, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { DATA_SYNC_ALL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { DATA_SYNC_ALL -> Value.DATA_SYNC_ALL else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { DATA_SYNC_ALL -> Known.DATA_SYNC_ALL @@ -469,24 +523,20 @@ constructor( class W4FormEmployeeSync @JsonCreator private constructor( - @JsonProperty("individual_id") + @JsonProperty("params") @ExcludeMissing - private val individualId: JsonField = JsonMissing.of(), + private val params: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - /** The unique ID of the individual for W-4 data sync. */ - fun individualId(): String = individualId.getRequired("individual_id") + fun params(): Params = params.getRequired("params") /** The type of job to start. */ fun type(): Type = type.getRequired("type") - /** The unique ID of the individual for W-4 data sync. */ - @JsonProperty("individual_id") - @ExcludeMissing - fun _individualId(): JsonField = individualId + @JsonProperty("params") @ExcludeMissing fun _params(): JsonField = params /** The type of job to start. */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @@ -498,11 +548,13 @@ constructor( private var validated: Boolean = false fun validate(): W4FormEmployeeSync = apply { - if (!validated) { - individualId() - type() - validated = true + if (validated) { + return@apply } + + params().validate() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -512,26 +564,23 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [W4FormEmployeeSync]. */ + class Builder internal constructor() { - private var individualId: JsonField? = null + private var params: JsonField? = null private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(w4FormEmployeeSync: W4FormEmployeeSync) = apply { - individualId = w4FormEmployeeSync.individualId + params = w4FormEmployeeSync.params type = w4FormEmployeeSync.type additionalProperties = w4FormEmployeeSync.additionalProperties.toMutableMap() } - /** The unique ID of the individual for W-4 data sync. */ - fun individualId(individualId: String) = individualId(JsonField.of(individualId)) + fun params(params: Params) = params(JsonField.of(params)) - /** The unique ID of the individual for W-4 data sync. */ - fun individualId(individualId: JsonField) = apply { - this.individualId = individualId - } + fun params(params: JsonField) = apply { this.params = params } /** The type of job to start. */ fun type(type: Type) = type(JsonField.of(type)) @@ -560,18 +609,135 @@ constructor( fun build(): W4FormEmployeeSync = W4FormEmployeeSync( - checkNotNull(individualId) { "`individualId` is required but was not set" }, - checkNotNull(type) { "`type` is required but was not set" }, + checkRequired("params", params), + checkRequired("type", type), additionalProperties.toImmutable(), ) } + @NoAutoDetect + class Params + @JsonCreator + private constructor( + @JsonProperty("individual_id") + @ExcludeMissing + private val individualId: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The unique ID of the individual for W-4 data sync. */ + fun individualId(): String = individualId.getRequired("individual_id") + + /** The unique ID of the individual for W-4 data sync. */ + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): Params = apply { + if (validated) { + return@apply + } + + individualId() + validated = true + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Params]. */ + class Builder internal constructor() { + + private var individualId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(params: Params) = apply { + individualId = params.individualId + additionalProperties = params.additionalProperties.toMutableMap() + } + + /** The unique ID of the individual for W-4 data sync. */ + fun individualId(individualId: String) = individualId(JsonField.of(individualId)) + + /** The unique ID of the individual for W-4 data sync. */ + fun individualId(individualId: JsonField) = apply { + this.individualId = individualId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + fun build(): Params = + Params( + checkRequired("individualId", individualId), + additionalProperties.toImmutable() + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Params && individualId == other.individualId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(individualId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Params{individualId=$individualId, additionalProperties=$additionalProperties}" + } + + /** The type of job to start. */ class Type @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -581,21 +747,48 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { W4_FORM_EMPLOYEE_SYNC, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { W4_FORM_EMPLOYEE_SYNC, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { W4_FORM_EMPLOYEE_SYNC -> Value.W4_FORM_EMPLOYEE_SYNC else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { W4_FORM_EMPLOYEE_SYNC -> Known.W4_FORM_EMPLOYEE_SYNC @@ -622,17 +815,17 @@ constructor( return true } - return /* spotless:off */ other is W4FormEmployeeSync && individualId == other.individualId && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is W4FormEmployeeSync && params == other.params && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(individualId, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(params, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "W4FormEmployeeSync{individualId=$individualId, type=$type, additionalProperties=$additionalProperties}" + "W4FormEmployeeSync{params=$params, type=$type, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedListPage.kt index d6048527..8747fddf 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedListPage.kt @@ -19,6 +19,11 @@ import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** + * Get all automated jobs. Automated jobs are completed by a machine. By default, jobs are sorted in + * descending order by submission time. For scheduled jobs such as data syncs, only the next + * scheduled job is shown. + */ class JobAutomatedListPage private constructor( private val automatedService: AutomatedService, @@ -46,7 +51,12 @@ private constructor( "JobAutomatedListPage{automatedService=$automatedService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !data().isEmpty() + if (data().isEmpty()) { + return false + } + + return paging().offset().orElse(0) + data().count() < + paging().count().orElse(Long.MAX_VALUE) } fun getNextPageParams(): Optional { @@ -94,8 +104,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun data(): List = data.getNullable("data") ?: listOf() fun paging(): Paging = paging.getRequired("paging") @@ -110,12 +118,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - data().map { it.validate() } - paging().validate() - validated = true + if (validated) { + return@apply } + + data().map { it.validate() } + paging().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -172,8 +184,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: JobAutomatedListPage, ) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedListPageAsync.kt index a580d6b8..d93302c0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedListPageAsync.kt @@ -20,6 +20,11 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** + * Get all automated jobs. Automated jobs are completed by a machine. By default, jobs are sorted in + * descending order by submission time. For scheduled jobs such as data syncs, only the next + * scheduled job is shown. + */ class JobAutomatedListPageAsync private constructor( private val automatedService: AutomatedServiceAsync, @@ -47,7 +52,12 @@ private constructor( "JobAutomatedListPageAsync{automatedService=$automatedService, params=$params, response=$response}" fun hasNextPage(): Boolean { - return !data().isEmpty() + if (data().isEmpty()) { + return false + } + + return paging().offset().orElse(0) + data().count() < + paging().count().orElse(Long.MAX_VALUE) } fun getNextPageParams(): Optional { @@ -97,8 +107,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun data(): List = data.getNullable("data") ?: listOf() fun paging(): Paging = paging.getRequired("paging") @@ -113,12 +121,16 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - data().map { it.validate() } - paging().validate() - validated = true + if (validated) { + return@apply } + + data().map { it.validate() } + paging().validate() + validated = true } fun toBuilder() = Builder().from(this) @@ -175,8 +187,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: JobAutomatedListPageAsync, ) { 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 0e94df49..9a6b4b60 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 @@ -3,6 +3,7 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import java.util.Objects @@ -14,12 +15,12 @@ import java.util.Optional * scheduled job is shown. */ class JobAutomatedListParams -constructor( +private constructor( private val limit: Long?, private val offset: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** Number of items to return */ fun limit(): Optional = Optional.ofNullable(limit) @@ -31,10 +32,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.limit?.let { queryParams.put("limit", listOf(it.toString())) } this.offset?.let { queryParams.put("offset", listOf(it.toString())) } @@ -49,8 +49,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [JobAutomatedListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var limit: Long? = null private var offset: Long? = null 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 1291d0a0..8f9419ca 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 @@ -3,17 +3,19 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +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 java.util.Objects /** Get an automated job by `job_id`. */ class JobAutomatedRetrieveParams -constructor( +private constructor( private val jobId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun jobId(): String = jobId @@ -21,9 +23,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +41,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [JobAutomatedRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var jobId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -155,7 +158,7 @@ constructor( fun build(): JobAutomatedRetrieveParams = JobAutomatedRetrieveParams( - checkNotNull(jobId) { "`jobId` is required but was not set" }, + checkRequired("jobId", jobId), additionalHeaders.build(), additionalQueryParams.build(), ) 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 5edc106c..0e35e6bf 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -42,13 +43,13 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - fun accountId(): String = accountId.getRequired("account_id") + @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - fun companyId(): String = companyId.getRequired("company_id") + @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") /** Unique Finch ID of the connection associated with the webhook event. */ fun connectionId(): Optional = @@ -62,13 +63,19 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ @JsonProperty("connection_id") @@ -93,14 +100,16 @@ private constructor( private var validated: Boolean = false fun validate(): JobCompletionEvent = apply { - if (!validated) { - accountId() - companyId() - connectionId() - data().map { it.validate() } - eventType() - validated = true + if (validated) { + return@apply } + + accountId() + companyId() + connectionId() + data().ifPresent { it.validate() } + eventType() + validated = true } fun toBuilder() = Builder().from(this) @@ -110,7 +119,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [JobCompletionEvent]. */ + class Builder internal constructor() { private var accountId: JsonField? = null private var companyId: JsonField? = null @@ -133,24 +143,28 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: String) = accountId(JsonField.of(accountId)) /** * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: JsonField) = apply { this.accountId = accountId } /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** Unique Finch ID of the connection associated with the webhook event. */ @@ -190,8 +204,8 @@ private constructor( fun build(): JobCompletionEvent = JobCompletionEvent( - checkNotNull(accountId) { "`accountId` is required but was not set" }, - checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkRequired("accountId", accountId), + checkRequired("companyId", companyId), connectionId, data, eventType, @@ -232,11 +246,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - jobId() - jobUrl() - validated = true + if (validated) { + return@apply } + + jobId() + jobUrl() + validated = true } fun toBuilder() = Builder().from(this) @@ -246,7 +262,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { private var jobId: JsonField? = null private var jobUrl: JsonField? = null @@ -292,8 +309,8 @@ private constructor( fun build(): Data = Data( - checkNotNull(jobId) { "`jobId` is required but was not set" }, - checkNotNull(jobUrl) { "`jobUrl` is required but was not set" }, + checkRequired("jobId", jobId), + checkRequired("jobUrl", jobUrl), additionalProperties.toImmutable(), ) } @@ -322,6 +339,14 @@ 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 { @@ -341,6 +366,7 @@ private constructor( @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) } + /** An enum containing [EventType]'s known values. */ enum class Known { JOB_BENEFIT_CREATE_COMPLETED, JOB_BENEFIT_ENROLL_COMPLETED, @@ -350,6 +376,15 @@ private constructor( JOB_DATA_SYNC_ALL_COMPLETED, } + /** + * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventType] 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 { JOB_BENEFIT_CREATE_COMPLETED, JOB_BENEFIT_ENROLL_COMPLETED, @@ -357,9 +392,19 @@ private constructor( JOB_BENEFIT_UNENROLL_COMPLETED, JOB_BENEFIT_UPDATE_COMPLETED, JOB_DATA_SYNC_ALL_COMPLETED, + /** + * An enum member indicating that [EventType] 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) { JOB_BENEFIT_CREATE_COMPLETED -> Value.JOB_BENEFIT_CREATE_COMPLETED @@ -371,6 +416,14 @@ private constructor( 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) { JOB_BENEFIT_CREATE_COMPLETED -> Known.JOB_BENEFIT_CREATE_COMPLETED 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 9efdd745..b5f0299c 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import java.util.Objects @@ -67,13 +68,15 @@ private constructor( private var validated: Boolean = false fun validate(): JobCreateResponse = apply { - if (!validated) { - allowedRefreshes() - jobId() - jobUrl() - remainingRefreshes() - validated = true + if (validated) { + return@apply } + + allowedRefreshes() + jobId() + jobUrl() + remainingRefreshes() + validated = true } fun toBuilder() = Builder().from(this) @@ -83,7 +86,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [JobCreateResponse]. */ + class Builder internal constructor() { private var allowedRefreshes: JsonField? = null private var jobId: JsonField? = null @@ -151,12 +155,10 @@ private constructor( fun build(): JobCreateResponse = JobCreateResponse( - checkNotNull(allowedRefreshes) { "`allowedRefreshes` is required but was not set" }, - checkNotNull(jobId) { "`jobId` is required but was not set" }, - checkNotNull(jobUrl) { "`jobUrl` is required but was not set" }, - checkNotNull(remainingRefreshes) { - "`remainingRefreshes` is required but was not set" - }, + checkRequired("allowedRefreshes", allowedRefreshes), + checkRequired("jobId", jobId), + checkRequired("jobUrl", jobUrl), + checkRequired("remainingRefreshes", remainingRefreshes), additionalProperties.toImmutable(), ) } 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 fdab14f7..32fc6bca 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 @@ -3,6 +3,8 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +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 java.util.Objects @@ -12,11 +14,11 @@ import java.util.Objects * jobs. */ class JobManualRetrieveParams -constructor( +private constructor( private val jobId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun jobId(): String = jobId @@ -24,9 +26,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -42,8 +44,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [JobManualRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var jobId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -158,7 +161,7 @@ constructor( fun build(): JobManualRetrieveParams = JobManualRetrieveParams( - checkNotNull(jobId) { "`jobId` is required but was not set" }, + checkRequired("jobId", jobId), additionalHeaders.build(), additionalQueryParams.build(), ) 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 74b7ece0..20ce723d 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 @@ -88,17 +88,19 @@ private constructor( private var validated: Boolean = false fun validate(): Location = apply { - if (!validated) { - city() - country() - line1() - line2() - name() - postalCode() - sourceId() - state() - validated = true + if (validated) { + return@apply } + + city() + country() + line1() + line2() + name() + postalCode() + sourceId() + state() + validated = true } fun toBuilder() = Builder().from(this) @@ -108,7 +110,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Location]. */ + class Builder internal constructor() { private var city: JsonField = JsonMissing.of() private var country: JsonField = JsonMissing.of() 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 0d24f99c..42a27152 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -53,12 +54,14 @@ private constructor( private var validated: Boolean = false fun validate(): ManualAsyncJob = apply { - if (!validated) { - body() - jobId() - status() - validated = true + if (validated) { + return@apply } + + body() + jobId() + status() + validated = true } fun toBuilder() = Builder().from(this) @@ -68,7 +71,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [ManualAsyncJob]. */ + class Builder internal constructor() { private var body: JsonField>? = null private var jobId: JsonField? = null @@ -137,10 +141,9 @@ private constructor( fun build(): ManualAsyncJob = ManualAsyncJob( - checkNotNull(body) { "`body` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(jobId) { "`jobId` is required but was not set" }, - checkNotNull(status) { "`status` is required but was not set" }, + checkRequired("body", body).map { it.toImmutable() }, + checkRequired("jobId", jobId), + checkRequired("status", status), additionalProperties.toImmutable(), ) } @@ -151,6 +154,14 @@ 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 { @@ -166,6 +177,7 @@ private constructor( @JvmStatic fun of(value: String) = Status(JsonField.of(value)) } + /** An enum containing [Status]'s known values. */ enum class Known { PENDING, IN_PROGRESS, @@ -173,14 +185,31 @@ private constructor( COMPLETE, } + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { PENDING, IN_PROGRESS, ERROR, COMPLETE, + /** An enum member indicating that [Status] 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) { PENDING -> Value.PENDING @@ -190,6 +219,14 @@ private constructor( 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) { PENDING -> Known.PENDING 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 59202734..2aeaa697 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 @@ -44,11 +44,13 @@ private constructor( private var validated: Boolean = false fun validate(): Money = apply { - if (!validated) { - amount() - currency() - validated = true + if (validated) { + return@apply } + + amount() + currency() + validated = true } fun toBuilder() = Builder().from(this) @@ -58,7 +60,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Money]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/OperationSupport.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/OperationSupport.kt index 784345dc..7ff857eb 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/OperationSupport.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/OperationSupport.kt @@ -7,12 +7,28 @@ import com.tryfinch.api.core.Enum import com.tryfinch.api.core.JsonField import com.tryfinch.api.errors.FinchInvalidDataException +/** + * - `supported`: This operation is supported by both the provider and Finch + * - `not_supported_by_finch`: This operation is not supported by Finch but supported by the + * provider + * - `not_supported_by_provider`: This operation is not supported by the provider, so Finch cannot + * support + * - `client_access_only`: This behavior is supported by the provider, but only available to the + * client and not to Finch + */ class OperationSupport @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 { @@ -28,6 +44,7 @@ private constructor( @JvmStatic fun of(value: String) = OperationSupport(JsonField.of(value)) } + /** An enum containing [OperationSupport]'s known values. */ enum class Known { SUPPORTED, NOT_SUPPORTED_BY_FINCH, @@ -35,14 +52,33 @@ private constructor( CLIENT_ACCESS_ONLY, } + /** + * An enum containing [OperationSupport]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [OperationSupport] 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 { SUPPORTED, NOT_SUPPORTED_BY_FINCH, NOT_SUPPORTED_BY_PROVIDER, CLIENT_ACCESS_ONLY, + /** + * An enum member indicating that [OperationSupport] 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) { SUPPORTED -> Value.SUPPORTED @@ -52,6 +88,14 @@ private constructor( 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) { SUPPORTED -> Known.SUPPORTED 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 42e31488..28f0e217 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 @@ -130,13 +130,15 @@ private constructor( private var validated: Boolean = false fun validate(): OperationSupportMatrix = apply { - if (!validated) { - create() - delete() - read() - update() - validated = true + if (validated) { + return@apply } + + create() + delete() + read() + update() + validated = true } fun toBuilder() = Builder().from(this) @@ -146,7 +148,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [OperationSupportMatrix]. */ + class Builder internal constructor() { private var create: JsonField = JsonMissing.of() private var delete: JsonField = JsonMissing.of() 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 4ce7f300..7775b803 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 @@ -44,11 +44,13 @@ private constructor( private var validated: Boolean = false fun validate(): Paging = apply { - if (!validated) { - count() - offset() - validated = true + if (validated) { + return@apply } + + count() + offset() + validated = true } fun toBuilder() = Builder().from(this) @@ -58,7 +60,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Paging]. */ + class Builder internal constructor() { private var count: JsonField = JsonMissing.of() private var offset: JsonField = JsonMissing.of() 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 e83fa445..157209b2 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 @@ -58,12 +58,14 @@ private constructor( private var validated: Boolean = false fun validate(): PayGroupListResponse = apply { - if (!validated) { - id() - name() - payFrequencies() - validated = true + if (validated) { + return@apply } + + id() + name() + payFrequencies() + validated = true } fun toBuilder() = Builder().from(this) @@ -73,7 +75,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PayGroupListResponse]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() @@ -157,6 +160,14 @@ 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 { @@ -182,6 +193,7 @@ private constructor( @JvmStatic fun of(value: String) = PayFrequency(JsonField.of(value)) } + /** An enum containing [PayFrequency]'s known values. */ enum class Known { ANNUALLY, SEMI_ANNUALLY, @@ -194,6 +206,15 @@ private constructor( OTHER, } + /** + * An enum containing [PayFrequency]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PayFrequency] 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 { ANNUALLY, SEMI_ANNUALLY, @@ -204,9 +225,19 @@ private constructor( WEEKLY, DAILY, OTHER, + /** + * An enum member indicating that [PayFrequency] 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) { ANNUALLY -> Value.ANNUALLY @@ -221,6 +252,14 @@ private constructor( 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) { ANNUALLY -> Known.ANNUALLY 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 830b64c5..fbf23ba7 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -65,13 +66,15 @@ private constructor( private var validated: Boolean = false fun validate(): PayGroupRetrieveResponse = apply { - if (!validated) { - id() - individualIds() - name() - payFrequencies() - validated = true + if (validated) { + return@apply } + + id() + individualIds() + name() + payFrequencies() + validated = true } fun toBuilder() = Builder().from(this) @@ -81,7 +84,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PayGroupRetrieveResponse]. */ + class Builder internal constructor() { private var id: JsonField? = null private var individualIds: JsonField>? = null @@ -173,12 +177,10 @@ private constructor( fun build(): PayGroupRetrieveResponse = PayGroupRetrieveResponse( - checkNotNull(id) { "`id` is required but was not set" }, - checkNotNull(individualIds) { "`individualIds` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(payFrequencies) { "`payFrequencies` is required but was not set" } - .map { it.toImmutable() }, + checkRequired("id", id), + checkRequired("individualIds", individualIds).map { it.toImmutable() }, + checkRequired("name", name), + checkRequired("payFrequencies", payFrequencies).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -189,6 +191,14 @@ 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 { @@ -214,6 +224,7 @@ private constructor( @JvmStatic fun of(value: String) = PayFrequency(JsonField.of(value)) } + /** An enum containing [PayFrequency]'s known values. */ enum class Known { ANNUALLY, SEMI_ANNUALLY, @@ -226,6 +237,15 @@ private constructor( OTHER, } + /** + * An enum containing [PayFrequency]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PayFrequency] 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 { ANNUALLY, SEMI_ANNUALLY, @@ -236,9 +256,19 @@ private constructor( WEEKLY, DAILY, OTHER, + /** + * An enum member indicating that [PayFrequency] 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) { ANNUALLY -> Value.ANNUALLY @@ -253,6 +283,14 @@ private constructor( 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) { ANNUALLY -> Known.ANNUALLY 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 8edc003b..d529522b 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 @@ -126,19 +126,21 @@ private constructor( private var validated: Boolean = false fun validate(): PayStatement = apply { - if (!validated) { - earnings().map { it.forEach { it?.validate() } } - employeeDeductions().map { it.forEach { it?.validate() } } - employerContributions().map { it.forEach { it?.validate() } } - grossPay().map { it.validate() } - individualId() - netPay().map { it.validate() } - paymentMethod() - taxes().map { it.forEach { it?.validate() } } - totalHours() - type() - validated = true + if (validated) { + return@apply } + + earnings().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() + taxes().ifPresent { it.forEach { it?.validate() } } + totalHours() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -148,7 +150,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PayStatement]. */ + class Builder internal constructor() { private var earnings: JsonField>? = null private var employeeDeductions: JsonField>? = null @@ -433,14 +436,16 @@ private constructor( private var validated: Boolean = false fun validate(): Earning = apply { - if (!validated) { - amount() - currency() - hours() - name() - type() - validated = true + if (validated) { + return@apply } + + amount() + currency() + hours() + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -450,7 +455,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Earning]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -564,12 +570,21 @@ private constructor( ) } + /** The type of earning. */ 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 { @@ -603,6 +618,7 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { SALARY, WAGE, @@ -619,6 +635,15 @@ private constructor( OTHER, } + /** + * 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 { SALARY, WAGE, @@ -633,9 +658,17 @@ private constructor( TIPS, _1099, OTHER, + /** 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) { SALARY -> Value.SALARY @@ -654,6 +687,15 @@ private constructor( 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) { SALARY -> Known.SALARY @@ -765,14 +807,16 @@ private constructor( private var validated: Boolean = false fun validate(): EmployeeDeduction = apply { - if (!validated) { - amount() - currency() - name() - preTax() - type() - validated = true + if (validated) { + return@apply } + + amount() + currency() + name() + preTax() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -782,7 +826,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EmployeeDeduction]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -953,13 +998,15 @@ private constructor( private var validated: Boolean = false fun validate(): EmployerContribution = apply { - if (!validated) { - amount() - currency() - name() - type() - validated = true + if (validated) { + return@apply } + + amount() + currency() + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -969,7 +1016,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EmployerContribution]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -1073,12 +1121,21 @@ private constructor( "EmployerContribution{amount=$amount, currency=$currency, name=$name, type=$type, additionalProperties=$additionalProperties}" } + /** The payment method. */ class PaymentMethod @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 { @@ -1090,17 +1147,38 @@ private constructor( @JvmStatic fun of(value: String) = PaymentMethod(JsonField.of(value)) } + /** An enum containing [PaymentMethod]'s known values. */ enum class Known { CHECK, DIRECT_DEPOSIT, } + /** + * An enum containing [PaymentMethod]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PaymentMethod] 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 { CHECK, DIRECT_DEPOSIT, + /** + * An enum member indicating that [PaymentMethod] 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) { CHECK -> Value.CHECK @@ -1108,6 +1186,14 @@ private constructor( 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) { CHECK -> Known.CHECK @@ -1188,14 +1274,16 @@ private constructor( private var validated: Boolean = false fun validate(): Tax = apply { - if (!validated) { - amount() - currency() - employer() - name() - type() - validated = true + if (validated) { + return@apply } + + amount() + currency() + employer() + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1205,7 +1293,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Tax]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -1307,12 +1396,21 @@ private constructor( ) } + /** The type of taxes. */ 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 { @@ -1328,6 +1426,7 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { STATE, FEDERAL, @@ -1335,14 +1434,31 @@ private constructor( FICA, } + /** + * 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 { STATE, FEDERAL, LOCAL, FICA, + /** 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) { STATE -> Value.STATE @@ -1352,6 +1468,15 @@ private constructor( 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) { STATE -> Known.STATE @@ -1394,12 +1519,21 @@ private constructor( "Tax{amount=$amount, currency=$currency, employer=$employer, name=$name, type=$type, additionalProperties=$additionalProperties}" } + /** The type of the payment associated with the pay statement. */ 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 { @@ -1413,19 +1547,37 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { REGULAR_PAYROLL, OFF_CYCLE_PAYROLL, ONE_TIME_PAYMENT, } + /** + * 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 { REGULAR_PAYROLL, OFF_CYCLE_PAYROLL, ONE_TIME_PAYMENT, + /** 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) { REGULAR_PAYROLL -> Value.REGULAR_PAYROLL @@ -1434,6 +1586,14 @@ private constructor( 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) { REGULAR_PAYROLL -> Known.REGULAR_PAYROLL 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 50bae7d3..37ad59a8 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -42,13 +43,13 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - fun accountId(): String = accountId.getRequired("account_id") + @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - fun companyId(): String = companyId.getRequired("company_id") + @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") /** Unique Finch ID of the connection associated with the webhook event. */ fun connectionId(): Optional = @@ -62,13 +63,19 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ @JsonProperty("connection_id") @@ -93,14 +100,16 @@ private constructor( private var validated: Boolean = false fun validate(): PayStatementEvent = apply { - if (!validated) { - accountId() - companyId() - connectionId() - data().map { it.validate() } - eventType() - validated = true + if (validated) { + return@apply } + + accountId() + companyId() + connectionId() + data().ifPresent { it.validate() } + eventType() + validated = true } fun toBuilder() = Builder().from(this) @@ -110,7 +119,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PayStatementEvent]. */ + class Builder internal constructor() { private var accountId: JsonField? = null private var companyId: JsonField? = null @@ -133,24 +143,28 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: String) = accountId(JsonField.of(accountId)) /** * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: JsonField) = apply { this.accountId = accountId } /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** Unique Finch ID of the connection associated with the webhook event. */ @@ -190,8 +204,8 @@ private constructor( fun build(): PayStatementEvent = PayStatementEvent( - checkNotNull(accountId) { "`accountId` is required but was not set" }, - checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkRequired("accountId", accountId), + checkRequired("companyId", companyId), connectionId, data, eventType, @@ -235,11 +249,13 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - individualId() - paymentId() - validated = true + if (validated) { + return@apply } + + individualId() + paymentId() + validated = true } fun toBuilder() = Builder().from(this) @@ -249,7 +265,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { private var individualId: JsonField = JsonMissing.of() private var paymentId: JsonField = JsonMissing.of() @@ -327,6 +344,14 @@ 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 { @@ -340,19 +365,39 @@ private constructor( @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) } + /** An enum containing [EventType]'s known values. */ enum class Known { PAY_STATEMENT_CREATED, PAY_STATEMENT_UPDATED, PAY_STATEMENT_DELETED, } + /** + * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventType] 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 { PAY_STATEMENT_CREATED, PAY_STATEMENT_UPDATED, PAY_STATEMENT_DELETED, + /** + * An enum member indicating that [EventType] 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) { PAY_STATEMENT_CREATED -> Value.PAY_STATEMENT_CREATED @@ -361,6 +406,14 @@ private constructor( 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) { PAY_STATEMENT_CREATED -> Known.PAY_STATEMENT_CREATED 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 6924dc30..d2b73d6d 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 @@ -49,12 +49,14 @@ private constructor( private var validated: Boolean = false fun validate(): PayStatementResponse = apply { - if (!validated) { - body().map { it.validate() } - code() - paymentId() - validated = true + if (validated) { + return@apply } + + body().ifPresent { it.validate() } + code() + paymentId() + validated = true } fun toBuilder() = Builder().from(this) @@ -64,7 +66,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PayStatementResponse]. */ + class Builder internal constructor() { private var body: JsonField = JsonMissing.of() private var code: JsonField = JsonMissing.of() 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 a14b8564..4fdae059 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 @@ -49,11 +49,13 @@ private constructor( private var validated: Boolean = false fun validate(): PayStatementResponseBody = apply { - if (!validated) { - paging().map { it.validate() } - payStatements().map { it.forEach { it.validate() } } - validated = true + if (validated) { + return@apply } + + paging().ifPresent { it.validate() } + payStatements().ifPresent { it.forEach { it.validate() } } + validated = true } fun toBuilder() = Builder().from(this) @@ -63,7 +65,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PayStatementResponseBody]. */ + class Builder internal constructor() { private var paging: JsonField = JsonMissing.of() private var payStatements: JsonField>? = null 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 6a0c1ffb..a98098da 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 @@ -142,21 +142,23 @@ private constructor( private var validated: Boolean = false fun validate(): Payment = apply { - if (!validated) { - id() - companyDebit().map { it.validate() } - debitDate() - employeeTaxes().map { it.validate() } - employerTaxes().map { it.validate() } - grossPay().map { it.validate() } - individualIds() - netPay().map { it.validate() } - payDate() - payFrequencies() - payGroupIds() - payPeriod().map { it.validate() } - validated = true + if (validated) { + return@apply } + + id() + companyDebit().ifPresent { it.validate() } + debitDate() + employeeTaxes().ifPresent { it.validate() } + employerTaxes().ifPresent { it.validate() } + grossPay().ifPresent { it.validate() } + individualIds() + netPay().ifPresent { it.validate() } + payDate() + payFrequencies() + payGroupIds() + payPeriod().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -166,7 +168,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Payment]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var companyDebit: JsonField = JsonMissing.of() @@ -388,6 +391,14 @@ 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 { @@ -413,6 +424,7 @@ private constructor( @JvmStatic fun of(value: String) = PayFrequency(JsonField.of(value)) } + /** An enum containing [PayFrequency]'s known values. */ enum class Known { ANNUALLY, SEMI_ANNUALLY, @@ -425,6 +437,15 @@ private constructor( OTHER, } + /** + * An enum containing [PayFrequency]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PayFrequency] 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 { ANNUALLY, SEMI_ANNUALLY, @@ -435,9 +456,19 @@ private constructor( WEEKLY, DAILY, OTHER, + /** + * An enum member indicating that [PayFrequency] 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) { ANNUALLY -> Value.ANNUALLY @@ -452,6 +483,14 @@ private constructor( 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) { ANNUALLY -> Known.ANNUALLY @@ -511,11 +550,13 @@ private constructor( private var validated: Boolean = false fun validate(): PayPeriod = apply { - if (!validated) { - endDate() - startDate() - validated = true + if (validated) { + return@apply } + + endDate() + startDate() + validated = true } fun toBuilder() = Builder().from(this) @@ -525,7 +566,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PayPeriod]. */ + class Builder internal constructor() { private var endDate: JsonField = JsonMissing.of() private var startDate: JsonField = JsonMissing.of() 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 169ccfe8..72337ed1 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import java.util.Objects @@ -47,11 +48,13 @@ private constructor( private var validated: Boolean = false fun validate(): PaymentCreateResponse = apply { - if (!validated) { - payDate() - paymentId() - validated = true + if (validated) { + return@apply } + + payDate() + paymentId() + validated = true } fun toBuilder() = Builder().from(this) @@ -61,7 +64,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PaymentCreateResponse]. */ + class Builder internal constructor() { private var payDate: JsonField? = null private var paymentId: JsonField? = null @@ -107,8 +111,8 @@ private constructor( fun build(): PaymentCreateResponse = PaymentCreateResponse( - checkNotNull(payDate) { "`payDate` is required but was not set" }, - checkNotNull(paymentId) { "`paymentId` is required but was not set" }, + checkRequired("payDate", payDate), + checkRequired("paymentId", paymentId), additionalProperties.toImmutable(), ) } 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 6a340eb7..020fc76d 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -44,13 +45,13 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - fun accountId(): String = accountId.getRequired("account_id") + @Deprecated("deprecated") fun accountId(): String = accountId.getRequired("account_id") /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - fun companyId(): String = companyId.getRequired("company_id") + @Deprecated("deprecated") fun companyId(): String = companyId.getRequired("company_id") /** Unique Finch ID of the connection associated with the webhook event. */ fun connectionId(): Optional = @@ -64,13 +65,19 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + @Deprecated("deprecated") + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + @Deprecated("deprecated") + @JsonProperty("company_id") + @ExcludeMissing + fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ @JsonProperty("connection_id") @@ -95,14 +102,16 @@ private constructor( private var validated: Boolean = false fun validate(): PaymentEvent = apply { - if (!validated) { - accountId() - companyId() - connectionId() - data().map { it.validate() } - eventType() - validated = true + if (validated) { + return@apply } + + accountId() + companyId() + connectionId() + data().ifPresent { it.validate() } + eventType() + validated = true } fun toBuilder() = Builder().from(this) @@ -112,7 +121,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PaymentEvent]. */ + class Builder internal constructor() { private var accountId: JsonField? = null private var companyId: JsonField? = null @@ -135,24 +145,28 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: String) = accountId(JsonField.of(accountId)) /** * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun accountId(accountId: JsonField) = apply { this.accountId = accountId } /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: String) = companyId(JsonField.of(companyId)) /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ + @Deprecated("deprecated") fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** Unique Finch ID of the connection associated with the webhook event. */ @@ -192,8 +206,8 @@ private constructor( fun build(): PaymentEvent = PaymentEvent( - checkNotNull(accountId) { "`accountId` is required but was not set" }, - checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkRequired("accountId", accountId), + checkRequired("companyId", companyId), connectionId, data, eventType, @@ -234,11 +248,13 @@ private constructor( private var validated: Boolean = false fun validate(): PaymentIdentifiers = apply { - if (!validated) { - payDate() - paymentId() - validated = true + if (validated) { + return@apply } + + payDate() + paymentId() + validated = true } fun toBuilder() = Builder().from(this) @@ -248,7 +264,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PaymentIdentifiers]. */ + class Builder internal constructor() { private var payDate: JsonField? = null private var paymentId: JsonField? = null @@ -294,8 +311,8 @@ private constructor( fun build(): PaymentIdentifiers = PaymentIdentifiers( - checkNotNull(payDate) { "`payDate` is required but was not set" }, - checkNotNull(paymentId) { "`paymentId` is required but was not set" }, + checkRequired("payDate", payDate), + checkRequired("paymentId", paymentId), additionalProperties.toImmutable(), ) } @@ -324,6 +341,14 @@ 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 { @@ -337,19 +362,39 @@ private constructor( @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) } + /** An enum containing [EventType]'s known values. */ enum class Known { PAYMENT_CREATED, PAYMENT_UPDATED, PAYMENT_DELETED, } + /** + * An enum containing [EventType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventType] 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 { PAYMENT_CREATED, PAYMENT_UPDATED, PAYMENT_DELETED, + /** + * An enum member indicating that [EventType] 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) { PAYMENT_CREATED -> Value.PAYMENT_CREATED @@ -358,6 +403,14 @@ private constructor( 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) { PAYMENT_CREATED -> Known.PAYMENT_CREATED diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPage.kt index 5d6d47b4..51aa4989 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPage.kt @@ -19,6 +19,7 @@ import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** Read company pay groups and frequencies */ class PayrollPayGroupListPage private constructor( private val payGroupsService: PayGroupService, @@ -82,8 +83,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun items(): List = items.getNullable("items") ?: listOf() @JsonProperty("items") @@ -93,11 +92,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - items().map { it.validate() } - validated = true + if (validated) { + return@apply } + + items().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -143,8 +146,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: PayrollPayGroupListPage, ) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPageAsync.kt index a59f56bf..eb29f545 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPageAsync.kt @@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** Read company pay groups and frequencies */ class PayrollPayGroupListPageAsync private constructor( private val payGroupsService: PayGroupServiceAsync, @@ -85,8 +86,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun items(): List = items.getNullable("items") ?: listOf() @JsonProperty("items") @@ -96,11 +95,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - items().map { it.validate() } - validated = true + if (validated) { + return@apply } + + items().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -146,8 +149,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: PayrollPayGroupListPageAsync, ) { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListParams.kt index 979124f0..fe12118b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListParams.kt @@ -3,6 +3,7 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import com.tryfinch.api.core.toImmutable @@ -11,12 +12,12 @@ import java.util.Optional /** Read company pay groups and frequencies */ class PayrollPayGroupListParams -constructor( +private constructor( private val individualId: String?, private val payFrequencies: List?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun individualId(): Optional = Optional.ofNullable(individualId) @@ -26,10 +27,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { + override fun _queryParams(): QueryParams { val queryParams = QueryParams.builder() this.individualId?.let { queryParams.put("individual_id", listOf(it.toString())) } this.payFrequencies?.let { queryParams.put("pay_frequencies[]", it.map(Any::toString)) } @@ -44,8 +44,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [PayrollPayGroupListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var individualId: String? = null private var payFrequencies: MutableList? = null diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupRetrieveParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupRetrieveParams.kt index b355cb27..e78ff6a9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupRetrieveParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupRetrieveParams.kt @@ -3,17 +3,19 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +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 java.util.Objects /** Read information from a single pay group */ class PayrollPayGroupRetrieveParams -constructor( +private constructor( private val payGroupId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun payGroupId(): String = payGroupId @@ -21,9 +23,9 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -39,8 +41,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [PayrollPayGroupRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var payGroupId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -155,7 +158,7 @@ constructor( fun build(): PayrollPayGroupRetrieveParams = PayrollPayGroupRetrieveParams( - checkNotNull(payGroupId) { "`payGroupId` is required but was not set" }, + checkRequired("payGroupId", payGroupId), additionalHeaders.build(), additionalQueryParams.build(), ) 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 3092504d..75479ec8 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -134,19 +135,21 @@ private constructor( private var validated: Boolean = false fun validate(): Provider = apply { - if (!validated) { - id() - authenticationMethods().map { it.forEach { it.validate() } } - beta() - displayName() - icon() - logo() - manual() - mfaRequired() - primaryColor() - products() - validated = true + if (validated) { + return@apply } + + id() + authenticationMethods().ifPresent { it.forEach { it.validate() } } + beta() + displayName() + icon() + logo() + manual() + mfaRequired() + primaryColor() + products() + validated = true } fun toBuilder() = Builder().from(this) @@ -156,7 +159,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Provider]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var authenticationMethods: JsonField>? = null @@ -376,12 +380,14 @@ private constructor( private var validated: Boolean = false fun validate(): AuthenticationMethod = apply { - if (!validated) { - benefitsSupport().map { it.validate() } - supportedFields().map { it.validate() } - type() - validated = true + if (validated) { + return@apply } + + benefitsSupport().ifPresent { it.validate() } + supportedFields().ifPresent { it.validate() } + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -391,7 +397,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [AuthenticationMethod]. */ + class Builder internal constructor() { private var benefitsSupport: JsonField = JsonMissing.of() private var supportedFields: JsonField = JsonMissing.of() @@ -561,16 +568,18 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedFields = apply { - if (!validated) { - company().map { it.validate() } - directory().map { it.validate() } - employment().map { it.validate() } - individual().map { it.validate() } - payGroup().map { it.validate() } - payStatement().map { it.validate() } - payment().map { it.validate() } - validated = true + 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 toBuilder() = Builder().from(this) @@ -580,7 +589,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedFields]. */ + class Builder internal constructor() { private var company: JsonField = JsonMissing.of() private var directory: JsonField = JsonMissing.of() @@ -780,18 +790,20 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedCompanyFields = apply { - if (!validated) { - id() - accounts().map { it.validate() } - departments().map { it.validate() } - ein() - entity().map { it.validate() } - legalName() - locations().map { it.validate() } - primaryEmail() - primaryPhoneNumber() - validated = true - } + 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 toBuilder() = Builder().from(this) @@ -801,7 +813,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedCompanyFields]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var accounts: JsonField = JsonMissing.of() @@ -980,14 +993,16 @@ private constructor( private var validated: Boolean = false fun validate(): Accounts = apply { - if (!validated) { - accountName() - accountNumber() - accountType() - institutionName() - routingNumber() - validated = true + if (validated) { + return@apply } + + accountName() + accountNumber() + accountType() + institutionName() + routingNumber() + validated = true } fun toBuilder() = Builder().from(this) @@ -997,7 +1012,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Accounts]. */ + class Builder internal constructor() { private var accountName: JsonField = JsonMissing.of() private var accountNumber: JsonField = JsonMissing.of() @@ -1135,11 +1151,13 @@ private constructor( private var validated: Boolean = false fun validate(): Departments = apply { - if (!validated) { - name() - parent().map { it.validate() } - validated = true + if (validated) { + return@apply } + + name() + parent().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -1149,7 +1167,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Departments]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var parent: JsonField = JsonMissing.of() @@ -1225,10 +1244,12 @@ private constructor( private var validated: Boolean = false fun validate(): Parent = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -1238,7 +1259,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Parent]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = @@ -1347,11 +1369,13 @@ private constructor( private var validated: Boolean = false fun validate(): Entity = apply { - if (!validated) { - subtype() - type() - validated = true + if (validated) { + return@apply } + + subtype() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1361,7 +1385,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entity]. */ + class Builder internal constructor() { private var subtype: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -1494,15 +1519,17 @@ private constructor( private var validated: Boolean = false fun validate(): Locations = apply { - if (!validated) { - city() - country() - line1() - line2() - postalCode() - state() - validated = true + if (validated) { + return@apply } + + city() + country() + line1() + line2() + postalCode() + state() + validated = true } fun toBuilder() = Builder().from(this) @@ -1512,7 +1539,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Locations]. */ + class Builder internal constructor() { private var city: JsonField = JsonMissing.of() private var country: JsonField = JsonMissing.of() @@ -1662,11 +1690,13 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedDirectoryFields = apply { - if (!validated) { - individuals().map { it.validate() } - paging().map { it.validate() } - validated = true + if (validated) { + return@apply } + + individuals().ifPresent { it.validate() } + paging().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -1676,7 +1706,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedDirectoryFields]. */ + class Builder internal constructor() { private var individuals: JsonField = JsonMissing.of() private var paging: JsonField = JsonMissing.of() @@ -1813,16 +1844,18 @@ private constructor( private var validated: Boolean = false fun validate(): Individuals = apply { - if (!validated) { - id() - department() - firstName() - isActive() - lastName() - manager().map { it.validate() } - middleName() - validated = true + if (validated) { + return@apply } + + id() + department() + firstName() + isActive() + lastName() + manager().ifPresent { it.validate() } + middleName() + validated = true } fun toBuilder() = Builder().from(this) @@ -1832,7 +1865,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Individuals]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var department: JsonField = JsonMissing.of() @@ -1952,10 +1986,12 @@ private constructor( private var validated: Boolean = false fun validate(): Manager = apply { - if (!validated) { - id() - validated = true + if (validated) { + return@apply } + + id() + validated = true } fun toBuilder() = Builder().from(this) @@ -1965,7 +2001,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Manager]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = @@ -2074,11 +2111,13 @@ private constructor( private var validated: Boolean = false fun validate(): Paging = apply { - if (!validated) { - count() - offset() - validated = true + if (validated) { + return@apply } + + count() + offset() + validated = true } fun toBuilder() = Builder().from(this) @@ -2088,7 +2127,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Paging]. */ + class Builder internal constructor() { private var count: JsonField = JsonMissing.of() private var offset: JsonField = JsonMissing.of() @@ -2352,26 +2392,28 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedEmploymentFields = apply { - if (!validated) { - id() - classCode() - customFields() - department().map { it.validate() } - employment().map { it.validate() } - employmentStatus() - endDate() - firstName() - income().map { it.validate() } - incomeHistory() - isActive() - lastName() - location().map { it.validate() } - manager().map { it.validate() } - middleName() - startDate() - title() - validated = true - } + 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 toBuilder() = Builder().from(this) @@ -2381,7 +2423,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedEmploymentFields]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var classCode: JsonField = JsonMissing.of() @@ -2582,10 +2625,12 @@ private constructor( private var validated: Boolean = false fun validate(): Department = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -2595,7 +2640,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Department]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = @@ -2687,11 +2733,13 @@ private constructor( private var validated: Boolean = false fun validate(): Employment = apply { - if (!validated) { - subtype() - type() - validated = true + if (validated) { + return@apply } + + subtype() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -2701,7 +2749,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Employment]. */ + class Builder internal constructor() { private var subtype: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -2813,12 +2862,14 @@ private constructor( private var validated: Boolean = false fun validate(): Income = apply { - if (!validated) { - amount() - currency() - unit() - validated = true + if (validated) { + return@apply } + + amount() + currency() + unit() + validated = true } fun toBuilder() = Builder().from(this) @@ -2828,7 +2879,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Income]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -2970,15 +3022,17 @@ private constructor( private var validated: Boolean = false fun validate(): Location = apply { - if (!validated) { - city() - country() - line1() - line2() - postalCode() - state() - validated = true + if (validated) { + return@apply } + + city() + country() + line1() + line2() + postalCode() + state() + validated = true } fun toBuilder() = Builder().from(this) @@ -2988,7 +3042,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Location]. */ + class Builder internal constructor() { private var city: JsonField = JsonMissing.of() private var country: JsonField = JsonMissing.of() @@ -3110,10 +3165,12 @@ private constructor( private var validated: Boolean = false fun validate(): Manager = apply { - if (!validated) { - id() - validated = true + if (validated) { + return@apply } + + id() + validated = true } fun toBuilder() = Builder().from(this) @@ -3123,7 +3180,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Manager]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = @@ -3330,22 +3388,24 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedIndividualFields = apply { - if (!validated) { - id() - dob() - emails().map { it.validate() } - encryptedSsn() - ethnicity() - firstName() - gender() - lastName() - middleName() - phoneNumbers().map { it.validate() } - preferredName() - residence().map { it.validate() } - ssn() - validated = true - } + 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 toBuilder() = Builder().from(this) @@ -3355,7 +3415,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedIndividualFields]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var dob: JsonField = JsonMissing.of() @@ -3531,11 +3592,13 @@ private constructor( private var validated: Boolean = false fun validate(): Emails = apply { - if (!validated) { - data() - type() - validated = true + if (validated) { + return@apply } + + data() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -3545,7 +3608,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Emails]. */ + class Builder internal constructor() { private var data: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -3644,11 +3708,13 @@ private constructor( private var validated: Boolean = false fun validate(): PhoneNumbers = apply { - if (!validated) { - data() - type() - validated = true + if (validated) { + return@apply } + + data() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -3658,7 +3724,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PhoneNumbers]. */ + class Builder internal constructor() { private var data: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -3791,15 +3858,17 @@ private constructor( private var validated: Boolean = false fun validate(): Residence = apply { - if (!validated) { - city() - country() - line1() - line2() - postalCode() - state() - validated = true + if (validated) { + return@apply } + + city() + country() + line1() + line2() + postalCode() + state() + validated = true } fun toBuilder() = Builder().from(this) @@ -3809,7 +3878,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Residence]. */ + class Builder internal constructor() { private var city: JsonField = JsonMissing.of() private var country: JsonField = JsonMissing.of() @@ -3976,13 +4046,15 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedPayGroupFields = apply { - if (!validated) { - id() - individualIds() - name() - payFrequencies() - validated = true + if (validated) { + return@apply } + + id() + individualIds() + name() + payFrequencies() + validated = true } fun toBuilder() = Builder().from(this) @@ -3992,7 +4064,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedPayGroupFields]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var individualIds: JsonField = JsonMissing.of() @@ -4114,11 +4187,13 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedPayStatementFields = apply { - if (!validated) { - paging().map { it.validate() } - payStatements().map { it.validate() } - validated = true + if (validated) { + return@apply } + + paging().ifPresent { it.validate() } + payStatements().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -4128,7 +4203,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedPayStatementFields]. */ + class Builder internal constructor() { private var paging: JsonField = JsonMissing.of() private var payStatements: JsonField = JsonMissing.of() @@ -4215,11 +4291,13 @@ private constructor( private var validated: Boolean = false fun validate(): Paging = apply { - if (!validated) { - count() - offset() - validated = true + if (validated) { + return@apply } + + count() + offset() + validated = true } fun toBuilder() = Builder().from(this) @@ -4229,7 +4307,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Paging]. */ + class Builder internal constructor() { private var count: JsonField? = null private var offset: JsonField? = null @@ -4275,8 +4354,8 @@ private constructor( fun build(): Paging = Paging( - checkNotNull(count) { "`count` is required but was not set" }, - checkNotNull(offset) { "`offset` is required but was not set" }, + checkRequired("count", count), + checkRequired("offset", offset), additionalProperties.toImmutable(), ) } @@ -4413,19 +4492,21 @@ private constructor( private var validated: Boolean = false fun validate(): PayStatements = apply { - if (!validated) { - earnings().map { it.validate() } - employeeDeductions().map { it.validate() } - employerContributions().map { it.validate() } - grossPay() - individualId() - netPay() - paymentMethod() - taxes().map { it.validate() } - totalHours() - type() - validated = true + 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 toBuilder() = Builder().from(this) @@ -4435,7 +4516,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PayStatements]. */ + class Builder internal constructor() { private var earnings: JsonField = JsonMissing.of() private var employeeDeductions: JsonField = @@ -4616,13 +4698,15 @@ private constructor( private var validated: Boolean = false fun validate(): Earnings = apply { - if (!validated) { - amount() - currency() - name() - type() - validated = true + if (validated) { + return@apply } + + amount() + currency() + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -4632,7 +4716,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Earnings]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -4780,14 +4865,16 @@ private constructor( private var validated: Boolean = false fun validate(): EmployeeDeductions = apply { - if (!validated) { - amount() - currency() - name() - preTax() - type() - validated = true + if (validated) { + return@apply } + + amount() + currency() + name() + preTax() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -4797,7 +4884,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EmployeeDeductions]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -4935,12 +5023,14 @@ private constructor( private var validated: Boolean = false fun validate(): EmployerContributions = apply { - if (!validated) { - amount() - currency() - name() - validated = true + if (validated) { + return@apply } + + amount() + currency() + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -4950,7 +5040,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EmployerContributions]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -5093,14 +5184,16 @@ private constructor( private var validated: Boolean = false fun validate(): Taxes = apply { - if (!validated) { - amount() - currency() - employer() - name() - type() - validated = true + if (validated) { + return@apply } + + amount() + currency() + employer() + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -5110,7 +5203,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Taxes]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -5370,21 +5464,23 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedPaymentFields = apply { - if (!validated) { - id() - companyDebit() - debitDate() - employeeTaxes() - employerTaxes() - grossPay() - individualIds() - netPay() - payDate() - payFrequencies() - payGroupIds() - payPeriod().map { it.validate() } - validated = true - } + if (validated) { + return@apply + } + + id() + companyDebit() + debitDate() + employeeTaxes() + employerTaxes() + grossPay() + individualIds() + netPay() + payDate() + payFrequencies() + payGroupIds() + payPeriod().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -5394,7 +5490,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedPaymentFields]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var companyDebit: JsonField = JsonMissing.of() @@ -5572,11 +5669,13 @@ private constructor( private var validated: Boolean = false fun validate(): PayPeriod = apply { - if (!validated) { - endDate() - startDate() - validated = true + if (validated) { + return@apply } + + endDate() + startDate() + validated = true } fun toBuilder() = Builder().from(this) @@ -5586,7 +5685,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PayPeriod]. */ + class Builder internal constructor() { private var endDate: JsonField = JsonMissing.of() private var startDate: JsonField = JsonMissing.of() @@ -5694,12 +5794,21 @@ private constructor( "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 { @@ -5717,6 +5826,7 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { ASSISTED, CREDENTIAL, @@ -5725,15 +5835,32 @@ private constructor( 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 @@ -5744,6 +5871,15 @@ private constructor( 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 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 9f4ad152..9d818def 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 @@ -19,6 +19,7 @@ import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +/** Return details on all available payroll and HR systems. */ class ProviderListPage private constructor( private val providersService: ProviderService, @@ -77,8 +78,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun items(): List = items.getNullable("items") ?: listOf() @JsonProperty("items") @@ -88,11 +87,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - items().map { it.validate() } - validated = true + if (validated) { + return@apply } + + items().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -138,8 +141,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: ProviderListPage, ) : Iterable { 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 607497d1..92cdf968 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 @@ -20,6 +20,7 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +/** Return details on all available payroll and HR systems. */ class ProviderListPageAsync private constructor( private val providersService: ProviderServiceAsync, @@ -84,8 +85,6 @@ private constructor( private val additionalProperties: Map = immutableEmptyMap(), ) { - private var validated: Boolean = false - fun items(): List = items.getNullable("items") ?: listOf() @JsonProperty("items") @@ -95,11 +94,15 @@ private constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + fun validate(): Response = apply { - if (!validated) { - items().map { it.validate() } - validated = true + if (validated) { + return@apply } + + items().map { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -145,8 +148,7 @@ private constructor( } } - class AutoPager - constructor( + class AutoPager( private val firstPage: ProviderListPageAsync, ) { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListParams.kt index 3adfae98..d73f15c9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListParams.kt @@ -3,24 +3,25 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import java.util.Objects /** Return details on all available payroll and HR systems. */ class ProviderListParams -constructor( +private constructor( private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -29,8 +30,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [ProviderListParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() 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 4e0fb356..86d06978 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 @@ -11,6 +11,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -24,11 +26,11 @@ import java.util.Optional * pull data models directly against an integration’s API. */ class RequestForwardingForwardParams -constructor( +private constructor( private val body: RequestForwardingForwardBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** * The HTTP method for the forwarded request. Valid values include: `GET` , `POST` , `PUT` , @@ -53,7 +55,7 @@ constructor( * object of key-value pairs. Example: `{"Content-Type": "application/xml", "X-API-Version": * "v1" }` */ - fun _headers(): JsonValue = body._headers() + fun _headers_(): JsonValue = body._headers_() /** * The query parameters for the forwarded request. This value must be specified as a valid JSON @@ -85,11 +87,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): RequestForwardingForwardBody = body + @JvmSynthetic internal fun _body(): RequestForwardingForwardBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams /** Forward Request Body */ @NoAutoDetect @@ -134,7 +136,7 @@ constructor( * object of key-value pairs. Example: `{"Content-Type": "application/xml", "X-API-Version": * "v1" }` */ - @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonValue = headers + @JsonProperty("headers") @ExcludeMissing fun _headers_(): JsonValue = headers /** * The query parameters for the forwarded request. This value must be specified as a valid @@ -167,12 +169,14 @@ constructor( private var validated: Boolean = false fun validate(): RequestForwardingForwardBody = apply { - if (!validated) { - method() - route() - data() - validated = true + if (validated) { + return@apply } + + method() + route() + data() + validated = true } fun toBuilder() = Builder().from(this) @@ -182,7 +186,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RequestForwardingForwardBody]. */ + class Builder internal constructor() { private var method: JsonField? = null private var route: JsonField? = null @@ -280,8 +285,8 @@ constructor( fun build(): RequestForwardingForwardBody = RequestForwardingForwardBody( - checkNotNull(method) { "`method` is required but was not set" }, - checkNotNull(route) { "`route` is required but was not set" }, + checkRequired("method", method), + checkRequired("route", route), data, headers, params, @@ -314,8 +319,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [RequestForwardingForwardParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: RequestForwardingForwardBody.Builder = RequestForwardingForwardBody.builder() 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 8fdf3c20..3a8cbd7e 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import java.util.Objects @@ -80,12 +81,14 @@ private constructor( private var validated: Boolean = false fun validate(): RequestForwardingForwardResponse = apply { - if (!validated) { - data() - request().validate() - statusCode() - validated = true + if (validated) { + return@apply } + + data() + request().validate() + statusCode() + validated = true } fun toBuilder() = Builder().from(this) @@ -95,7 +98,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [RequestForwardingForwardResponse]. */ + class Builder internal constructor() { private var data: JsonField? = null private var headers: JsonValue? = null @@ -186,10 +190,10 @@ private constructor( fun build(): RequestForwardingForwardResponse = RequestForwardingForwardResponse( - checkNotNull(data) { "`data` is required but was not set" }, - checkNotNull(headers) { "`headers` is required but was not set" }, - checkNotNull(request) { "`request` is required but was not set" }, - checkNotNull(statusCode) { "`statusCode` is required but was not set" }, + checkRequired("data", data), + checkRequired("headers", headers), + checkRequired("request", request), + checkRequired("statusCode", statusCode), additionalProperties.toImmutable(), ) } @@ -267,12 +271,14 @@ private constructor( private var validated: Boolean = false fun validate(): Request = apply { - if (!validated) { - data() - method() - route() - validated = true + if (validated) { + return@apply } + + data() + method() + route() + validated = true } fun toBuilder() = Builder().from(this) @@ -282,7 +288,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Request]. */ + class Builder internal constructor() { private var data: JsonField? = null private var headers: JsonValue? = null @@ -373,11 +380,11 @@ private constructor( fun build(): Request = Request( - checkNotNull(data) { "`data` is required but was not set" }, - checkNotNull(headers) { "`headers` is required but was not set" }, - checkNotNull(method) { "`method` is required but was not set" }, - checkNotNull(params) { "`params` is required but was not set" }, - checkNotNull(route) { "`route` is required but was not set" }, + checkRequired("data", data), + checkRequired("headers", headers), + checkRequired("method", method), + checkRequired("params", params), + checkRequired("route", route), additionalProperties.toImmutable(), ) } 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 e1fa5d5c..1d725117 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 @@ -12,6 +12,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -22,11 +24,11 @@ import java.util.Optional /** Update a sandbox company's data */ class SandboxCompanyUpdateParams -constructor( +private constructor( private val body: SandboxCompanyUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** An array of bank account objects associated with the payroll/HRIS system. */ fun accounts(): Optional> = body.accounts() @@ -80,11 +82,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): SandboxCompanyUpdateBody = body + @JvmSynthetic internal fun _body(): SandboxCompanyUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect class SandboxCompanyUpdateBody @@ -184,17 +186,19 @@ constructor( private var validated: Boolean = false fun validate(): SandboxCompanyUpdateBody = apply { - if (!validated) { - accounts().map { it.forEach { it.validate() } } - departments().map { it.forEach { it?.validate() } } - ein() - entity().map { it.validate() } - legalName() - locations().map { it.forEach { it?.validate() } } - primaryEmail() - primaryPhoneNumber() - validated = true + if (validated) { + return@apply } + + accounts().ifPresent { it.forEach { it.validate() } } + departments().ifPresent { it.forEach { it?.validate() } } + ein() + entity().ifPresent { it.validate() } + legalName() + locations().ifPresent { it.forEach { it?.validate() } } + primaryEmail() + primaryPhoneNumber() + validated = true } fun toBuilder() = Builder().from(this) @@ -204,7 +208,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SandboxCompanyUpdateBody]. */ + class Builder internal constructor() { private var accounts: JsonField>? = null private var departments: JsonField>? = null @@ -376,19 +381,14 @@ constructor( fun build(): SandboxCompanyUpdateBody = SandboxCompanyUpdateBody( - checkNotNull(accounts) { "`accounts` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(departments) { "`departments` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(ein) { "`ein` is required but was not set" }, - checkNotNull(entity) { "`entity` is required but was not set" }, - checkNotNull(legalName) { "`legalName` is required but was not set" }, - checkNotNull(locations) { "`locations` is required but was not set" } - .map { it.toImmutable() }, - checkNotNull(primaryEmail) { "`primaryEmail` is required but was not set" }, - checkNotNull(primaryPhoneNumber) { - "`primaryPhoneNumber` is required but was not set" - }, + checkRequired("accounts", accounts).map { it.toImmutable() }, + checkRequired("departments", departments).map { it.toImmutable() }, + checkRequired("ein", ein), + checkRequired("entity", entity), + checkRequired("legalName", legalName), + checkRequired("locations", locations).map { it.toImmutable() }, + checkRequired("primaryEmail", primaryEmail), + checkRequired("primaryPhoneNumber", primaryPhoneNumber), additionalProperties.toImmutable(), ) } @@ -418,8 +418,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SandboxCompanyUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: SandboxCompanyUpdateBody.Builder = SandboxCompanyUpdateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() @@ -723,14 +724,16 @@ constructor( private var validated: Boolean = false fun validate(): Account = apply { - if (!validated) { - accountName() - accountNumber() - accountType() - institutionName() - routingNumber() - validated = true + if (validated) { + return@apply } + + accountName() + accountNumber() + accountType() + institutionName() + routingNumber() + validated = true } fun toBuilder() = Builder().from(this) @@ -740,7 +743,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Account]. */ + class Builder internal constructor() { private var accountName: JsonField = JsonMissing.of() private var accountNumber: JsonField = JsonMissing.of() @@ -861,12 +865,21 @@ constructor( ) } + /** The type of bank account. */ class AccountType @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 { @@ -878,17 +891,38 @@ constructor( @JvmStatic fun of(value: String) = AccountType(JsonField.of(value)) } + /** An enum containing [AccountType]'s known values. */ enum class Known { CHECKING, SAVINGS, } + /** + * An enum containing [AccountType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AccountType] 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 { CHECKING, SAVINGS, + /** + * An enum member indicating that [AccountType] 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) { CHECKING -> Value.CHECKING @@ -896,6 +930,15 @@ constructor( 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) { CHECKING -> Known.CHECKING @@ -969,11 +1012,13 @@ constructor( private var validated: Boolean = false fun validate(): Department = apply { - if (!validated) { - name() - parent().map { it.validate() } - validated = true + if (validated) { + return@apply } + + name() + parent().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -983,7 +1028,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Department]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var parent: JsonField = JsonMissing.of() @@ -1066,10 +1112,12 @@ constructor( private var validated: Boolean = false fun validate(): Parent = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -1079,7 +1127,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Parent]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1192,11 +1241,13 @@ constructor( private var validated: Boolean = false fun validate(): Entity = apply { - if (!validated) { - subtype() - type() - validated = true + if (validated) { + return@apply } + + subtype() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1206,7 +1257,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Entity]. */ + class Builder internal constructor() { private var subtype: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -1264,12 +1316,21 @@ constructor( ) } + /** The tax payer subtype of the company. */ class Subtype @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1283,19 +1344,39 @@ constructor( @JvmStatic fun of(value: String) = Subtype(JsonField.of(value)) } + /** An enum containing [Subtype]'s known values. */ enum class Known { S_CORPORATION, C_CORPORATION, B_CORPORATION, } + /** + * An enum containing [Subtype]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Subtype] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { S_CORPORATION, C_CORPORATION, B_CORPORATION, + /** + * An enum member indicating that [Subtype] was instantiated with an unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { S_CORPORATION -> Value.S_CORPORATION @@ -1304,6 +1385,15 @@ constructor( 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) { S_CORPORATION -> Known.S_CORPORATION @@ -1327,12 +1417,21 @@ constructor( override fun toString() = value.toString() } + /** The tax payer type of the company. */ 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 { @@ -1354,6 +1453,7 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { LLC, LP, @@ -1364,6 +1464,15 @@ constructor( COOPERATIVE, } + /** + * 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 { LLC, LP, @@ -1372,9 +1481,17 @@ constructor( NON_PROFIT, PARTNERSHIP, COOPERATIVE, + /** 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) { LLC -> Value.LLC @@ -1387,6 +1504,15 @@ constructor( 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) { LLC -> Known.LLC 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 62b1169c..d212b752 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 @@ -12,6 +12,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -22,11 +24,11 @@ import java.util.Optional /** Create a new account for an existing connection (company/provider pair) */ class SandboxConnectionAccountCreateParams -constructor( +private constructor( private val body: SandboxConnectionAccountCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun companyId(): String = body.companyId() @@ -60,11 +62,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): SandboxConnectionAccountCreateBody = body + @JvmSynthetic internal fun _body(): SandboxConnectionAccountCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect class SandboxConnectionAccountCreateBody @@ -127,13 +129,15 @@ constructor( private var validated: Boolean = false fun validate(): SandboxConnectionAccountCreateBody = apply { - if (!validated) { - companyId() - providerId() - authenticationType() - products() - validated = true + if (validated) { + return@apply } + + companyId() + providerId() + authenticationType() + products() + validated = true } fun toBuilder() = Builder().from(this) @@ -143,7 +147,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SandboxConnectionAccountCreateBody]. */ + class Builder internal constructor() { private var companyId: JsonField? = null private var providerId: JsonField? = null @@ -232,8 +237,8 @@ constructor( fun build(): SandboxConnectionAccountCreateBody = SandboxConnectionAccountCreateBody( - checkNotNull(companyId) { "`companyId` is required but was not set" }, - checkNotNull(providerId) { "`providerId` is required but was not set" }, + checkRequired("companyId", companyId), + checkRequired("providerId", providerId), authenticationType, (products ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), @@ -265,8 +270,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SandboxConnectionAccountCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: SandboxConnectionAccountCreateBody.Builder = SandboxConnectionAccountCreateBody.builder() @@ -450,6 +456,14 @@ 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 { @@ -465,6 +479,7 @@ constructor( @JvmStatic fun of(value: String) = AuthenticationType(JsonField.of(value)) } + /** An enum containing [AuthenticationType]'s known values. */ enum class Known { CREDENTIAL, API_TOKEN, @@ -472,14 +487,34 @@ constructor( ASSISTED, } + /** + * An enum containing [AuthenticationType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AuthenticationType] 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 { CREDENTIAL, API_TOKEN, OAUTH, ASSISTED, + /** + * An enum member indicating that [AuthenticationType] 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) { CREDENTIAL -> Value.CREDENTIAL @@ -489,6 +524,14 @@ constructor( 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) { CREDENTIAL -> Known.CREDENTIAL 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 1e675c2b..41bffb71 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import com.tryfinch.api.core.immutableEmptyMap @@ -23,11 +24,11 @@ import java.util.Optional * responds. */ class SandboxConnectionAccountUpdateParams -constructor( +private constructor( private val body: SandboxConnectionAccountUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun connectionStatus(): Optional = body.connectionStatus() @@ -39,11 +40,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): SandboxConnectionAccountUpdateBody = body + @JvmSynthetic internal fun _body(): SandboxConnectionAccountUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect class SandboxConnectionAccountUpdateBody @@ -70,10 +71,12 @@ constructor( private var validated: Boolean = false fun validate(): SandboxConnectionAccountUpdateBody = apply { - if (!validated) { - connectionStatus() - validated = true + if (validated) { + return@apply } + + connectionStatus() + validated = true } fun toBuilder() = Builder().from(this) @@ -83,7 +86,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SandboxConnectionAccountUpdateBody]. */ + class Builder internal constructor() { private var connectionStatus: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -155,8 +159,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SandboxConnectionAccountUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: SandboxConnectionAccountUpdateBody.Builder = SandboxConnectionAccountUpdateBody.builder() 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 0530185d..9201ae74 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 @@ -12,6 +12,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -22,11 +24,11 @@ import java.util.Optional /** Create a new connection (new company/provider pair) with a new account */ class SandboxConnectionCreateParams -constructor( +private constructor( private val body: SandboxConnectionCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** The provider associated with the connection */ fun providerId(): String = body.providerId() @@ -62,11 +64,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): SandboxConnectionCreateBody = body + @JvmSynthetic internal fun _body(): SandboxConnectionCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect class SandboxConnectionCreateBody @@ -134,13 +136,15 @@ constructor( private var validated: Boolean = false fun validate(): SandboxConnectionCreateBody = apply { - if (!validated) { - providerId() - authenticationType() - employeeSize() - products() - validated = true + if (validated) { + return@apply } + + providerId() + authenticationType() + employeeSize() + products() + validated = true } fun toBuilder() = Builder().from(this) @@ -150,7 +154,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SandboxConnectionCreateBody]. */ + class Builder internal constructor() { private var providerId: JsonField? = null private var authenticationType: JsonField = JsonMissing.of() @@ -237,7 +242,7 @@ constructor( fun build(): SandboxConnectionCreateBody = SandboxConnectionCreateBody( - checkNotNull(providerId) { "`providerId` is required but was not set" }, + checkRequired("providerId", providerId), authenticationType, employeeSize, (products ?: JsonMissing.of()).map { it.toImmutable() }, @@ -270,8 +275,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SandboxConnectionCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: SandboxConnectionCreateBody.Builder = SandboxConnectionCreateBody.builder() @@ -450,6 +456,14 @@ 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 { @@ -465,6 +479,7 @@ constructor( @JvmStatic fun of(value: String) = AuthenticationType(JsonField.of(value)) } + /** An enum containing [AuthenticationType]'s known values. */ enum class Known { CREDENTIAL, API_TOKEN, @@ -472,14 +487,34 @@ constructor( ASSISTED, } + /** + * An enum containing [AuthenticationType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AuthenticationType] 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 { CREDENTIAL, API_TOKEN, OAUTH, ASSISTED, + /** + * An enum member indicating that [AuthenticationType] 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) { CREDENTIAL -> Value.CREDENTIAL @@ -489,6 +524,14 @@ constructor( 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) { CREDENTIAL -> Known.CREDENTIAL 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 c8633465..da8089a4 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 @@ -12,6 +12,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -22,11 +24,11 @@ import java.util.Optional /** Add new individuals to a sandbox company */ class SandboxDirectoryCreateParams -constructor( +private constructor( private val body: List, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** * Array of individuals to create. Takes all combined fields from `/individual` and @@ -38,11 +40,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): List = body + @JvmSynthetic internal fun _body(): List = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -51,8 +53,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SandboxDirectoryCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: MutableList? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -179,7 +182,7 @@ constructor( fun build(): SandboxDirectoryCreateParams = SandboxDirectoryCreateParams( - checkNotNull(body) { "`body` is required but was not set" }.toImmutable(), + checkRequired("body", body).toImmutable(), additionalHeaders.build(), additionalQueryParams.build(), ) @@ -487,36 +490,38 @@ constructor( private var validated: Boolean = false fun validate(): IndividualOrEmployment = apply { - if (!validated) { - classCode() - customFields().map { it.forEach { it.validate() } } - department().map { it.validate() } - dob() - emails().map { it.forEach { it.validate() } } - employment().map { it.validate() } - employmentStatus() - encryptedSsn() - endDate() - ethnicity() - firstName() - gender() - income().map { it.validate() } - incomeHistory().map { it.forEach { it?.validate() } } - isActive() - lastName() - latestRehireDate() - location().map { it.validate() } - manager().map { it.validate() } - middleName() - phoneNumbers().map { it.forEach { it?.validate() } } - preferredName() - residence().map { it.validate() } - sourceId() - ssn() - startDate() - title() - validated = true + if (validated) { + return@apply } + + classCode() + customFields().ifPresent { it.forEach { it.validate() } } + department().ifPresent { it.validate() } + dob() + emails().ifPresent { it.forEach { it.validate() } } + employment().ifPresent { it.validate() } + employmentStatus() + encryptedSsn() + endDate() + ethnicity() + firstName() + gender() + income().ifPresent { it.validate() } + incomeHistory().ifPresent { it.forEach { it?.validate() } } + isActive() + lastName() + latestRehireDate() + location().ifPresent { it.validate() } + manager().ifPresent { it.validate() } + middleName() + phoneNumbers().ifPresent { it.forEach { it?.validate() } } + preferredName() + residence().ifPresent { it.validate() } + sourceId() + ssn() + startDate() + title() + validated = true } fun toBuilder() = Builder().from(this) @@ -526,7 +531,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [IndividualOrEmployment]. */ + class Builder internal constructor() { private var classCode: JsonField = JsonMissing.of() private var customFields: JsonField>? = null @@ -1015,10 +1021,12 @@ constructor( private var validated: Boolean = false fun validate(): CustomField = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -1028,7 +1036,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [CustomField]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var value: JsonValue = JsonMissing.of() @@ -1122,10 +1131,12 @@ constructor( private var validated: Boolean = false fun validate(): Department = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -1135,7 +1146,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Department]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1227,11 +1239,13 @@ constructor( private var validated: Boolean = false fun validate(): Email = apply { - if (!validated) { - data() - type() - validated = true + if (validated) { + return@apply } + + data() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1241,7 +1255,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Email]. */ + class Builder internal constructor() { private var data: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -1300,6 +1315,14 @@ 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 { @@ -1311,17 +1334,37 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { WORK, PERSONAL, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { WORK, PERSONAL, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ fun value(): Value = when (this) { WORK -> Value.WORK @@ -1329,6 +1372,15 @@ constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { WORK -> Known.WORK @@ -1409,11 +1461,13 @@ constructor( private var validated: Boolean = false fun validate(): Employment = apply { - if (!validated) { - subtype() - type() - validated = true + if (validated) { + return@apply } + + subtype() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1423,7 +1477,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Employment]. */ + class Builder internal constructor() { private var subtype: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -1493,12 +1548,24 @@ constructor( ) } + /** + * The secondary employment type of the individual. Options: `full_time`, `part_time`, + * `intern`, `temp`, `seasonal` and `individual_contractor`. + */ class Subtype @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1518,6 +1585,7 @@ constructor( @JvmStatic fun of(value: String) = Subtype(JsonField.of(value)) } + /** An enum containing [Subtype]'s known values. */ enum class Known { FULL_TIME, INTERN, @@ -1527,6 +1595,15 @@ constructor( INDIVIDUAL_CONTRACTOR, } + /** + * An enum containing [Subtype]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Subtype] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { FULL_TIME, INTERN, @@ -1534,9 +1611,20 @@ constructor( TEMP, SEASONAL, INDIVIDUAL_CONTRACTOR, + /** + * An enum member indicating that [Subtype] was instantiated with an unknown + * value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ fun value(): Value = when (this) { FULL_TIME -> Value.FULL_TIME @@ -1548,6 +1636,15 @@ constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { FULL_TIME -> Known.FULL_TIME @@ -1574,12 +1671,21 @@ constructor( override fun toString() = value.toString() } + /** The main employment type of the individual. */ class Type @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1591,17 +1697,37 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { EMPLOYEE, CONTRACTOR, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { EMPLOYEE, CONTRACTOR, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ fun value(): Value = when (this) { EMPLOYEE -> Value.EMPLOYEE @@ -1609,6 +1735,15 @@ constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { EMPLOYEE -> Known.EMPLOYEE @@ -1649,12 +1784,21 @@ constructor( "Employment{subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" } + /** The detailed employment status of the individual. */ class EmploymentStatus @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 { @@ -1676,6 +1820,7 @@ constructor( @JvmStatic fun of(value: String) = EmploymentStatus(JsonField.of(value)) } + /** An enum containing [EmploymentStatus]'s known values. */ enum class Known { ACTIVE, DECEASED, @@ -1686,6 +1831,16 @@ constructor( TERMINATED, } + /** + * An enum containing [EmploymentStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [EmploymentStatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { ACTIVE, DECEASED, @@ -1694,9 +1849,20 @@ constructor( PREHIRE, RETIRED, TERMINATED, + /** + * An enum member indicating that [EmploymentStatus] 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) { ACTIVE -> Value.ACTIVE @@ -1709,6 +1875,15 @@ constructor( 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) { ACTIVE -> Known.ACTIVE @@ -1736,12 +1911,21 @@ constructor( override fun toString() = value.toString() } + /** The EEOC-defined ethnicity of the individual. */ class Ethnicity @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1767,6 +1951,7 @@ constructor( @JvmStatic fun of(value: String) = Ethnicity(JsonField.of(value)) } + /** An enum containing [Ethnicity]'s known values. */ enum class Known { ASIAN, WHITE, @@ -1778,6 +1963,15 @@ constructor( DECLINE_TO_SPECIFY, } + /** + * An enum containing [Ethnicity]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Ethnicity] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { ASIAN, WHITE, @@ -1787,9 +1981,20 @@ constructor( HISPANIC_OR_LATINO, TWO_OR_MORE_RACES, DECLINE_TO_SPECIFY, + /** + * An enum member indicating that [Ethnicity] 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) { ASIAN -> Value.ASIAN @@ -1803,6 +2008,15 @@ constructor( 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) { ASIAN -> Known.ASIAN @@ -1831,12 +2045,21 @@ constructor( override fun toString() = value.toString() } + /** The gender of the individual. */ class Gender @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 { @@ -1852,6 +2075,7 @@ constructor( @JvmStatic fun of(value: String) = Gender(JsonField.of(value)) } + /** An enum containing [Gender]'s known values. */ enum class Known { FEMALE, MALE, @@ -1859,14 +2083,33 @@ constructor( DECLINE_TO_SPECIFY, } + /** + * An enum containing [Gender]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Gender] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { FEMALE, MALE, OTHER, DECLINE_TO_SPECIFY, + /** + * An enum member indicating that [Gender] was instantiated with an unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { FEMALE -> Value.FEMALE @@ -1876,6 +2119,15 @@ constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { FEMALE -> Known.FEMALE @@ -1925,10 +2177,12 @@ constructor( private var validated: Boolean = false fun validate(): Manager = apply { - if (!validated) { - id() - validated = true + if (validated) { + return@apply } + + id() + validated = true } fun toBuilder() = Builder().from(this) @@ -1938,7 +2192,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Manager]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2026,11 +2281,13 @@ constructor( private var validated: Boolean = false fun validate(): PhoneNumber = apply { - if (!validated) { - data() - type() - validated = true + if (validated) { + return@apply } + + data() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -2040,7 +2297,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PhoneNumber]. */ + class Builder internal constructor() { private var data: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -2099,6 +2357,14 @@ 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 { @@ -2110,17 +2376,37 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { WORK, PERSONAL, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { WORK, PERSONAL, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ fun value(): Value = when (this) { WORK -> Value.WORK @@ -2128,6 +2414,15 @@ constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { WORK -> Known.WORK 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 1b4eda05..251c39f9 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 @@ -12,6 +12,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -22,12 +24,12 @@ import java.util.Optional /** Update sandbox employment */ class SandboxEmploymentUpdateParams -constructor( +private constructor( private val individualId: String, private val body: SandboxEmploymentUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun individualId(): String = individualId @@ -151,11 +153,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): SandboxEmploymentUpdateBody = body + @JvmSynthetic internal fun _body(): SandboxEmploymentUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -368,27 +370,29 @@ constructor( private var validated: Boolean = false fun validate(): SandboxEmploymentUpdateBody = apply { - if (!validated) { - classCode() - customFields().map { it.forEach { it.validate() } } - department().map { it.validate() } - employment().map { it.validate() } - employmentStatus() - endDate() - firstName() - income().map { it.validate() } - incomeHistory().map { it.forEach { it?.validate() } } - isActive() - lastName() - latestRehireDate() - location().map { it.validate() } - manager().map { it.validate() } - middleName() - sourceId() - startDate() - title() - validated = true + if (validated) { + return@apply } + + classCode() + customFields().ifPresent { it.forEach { it.validate() } } + department().ifPresent { it.validate() } + employment().ifPresent { it.validate() } + employmentStatus() + endDate() + firstName() + income().ifPresent { it.validate() } + incomeHistory().ifPresent { it.forEach { it?.validate() } } + isActive() + lastName() + latestRehireDate() + location().ifPresent { it.validate() } + manager().ifPresent { it.validate() } + middleName() + sourceId() + startDate() + title() + validated = true } fun toBuilder() = Builder().from(this) @@ -398,7 +402,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SandboxEmploymentUpdateBody]. */ + class Builder internal constructor() { private var classCode: JsonField = JsonMissing.of() private var customFields: JsonField>? = null @@ -728,8 +733,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SandboxEmploymentUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var individualId: String? = null private var body: SandboxEmploymentUpdateBody.Builder = @@ -1060,7 +1066,7 @@ constructor( fun build(): SandboxEmploymentUpdateParams = SandboxEmploymentUpdateParams( - checkNotNull(individualId) { "`individualId` is required but was not set" }, + checkRequired("individualId", individualId), body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -1092,10 +1098,12 @@ constructor( private var validated: Boolean = false fun validate(): CustomField = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -1105,7 +1113,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [CustomField]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var value: JsonValue = JsonMissing.of() @@ -1196,10 +1205,12 @@ constructor( private var validated: Boolean = false fun validate(): Department = apply { - if (!validated) { - name() - validated = true + if (validated) { + return@apply } + + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -1209,7 +1220,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Department]. */ + class Builder internal constructor() { private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1307,11 +1319,13 @@ constructor( private var validated: Boolean = false fun validate(): Employment = apply { - if (!validated) { - subtype() - type() - validated = true + if (validated) { + return@apply } + + subtype() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1321,7 +1335,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Employment]. */ + class Builder internal constructor() { private var subtype: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -1388,12 +1403,24 @@ constructor( ) } + /** + * The secondary employment type of the individual. Options: `full_time`, `part_time`, + * `intern`, `temp`, `seasonal` and `individual_contractor`. + */ class Subtype @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1413,6 +1440,7 @@ constructor( @JvmStatic fun of(value: String) = Subtype(JsonField.of(value)) } + /** An enum containing [Subtype]'s known values. */ enum class Known { FULL_TIME, INTERN, @@ -1422,6 +1450,15 @@ constructor( INDIVIDUAL_CONTRACTOR, } + /** + * An enum containing [Subtype]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Subtype] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { FULL_TIME, INTERN, @@ -1429,9 +1466,19 @@ constructor( TEMP, SEASONAL, INDIVIDUAL_CONTRACTOR, + /** + * An enum member indicating that [Subtype] was instantiated with an unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { FULL_TIME -> Value.FULL_TIME @@ -1443,6 +1490,15 @@ constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { FULL_TIME -> Known.FULL_TIME @@ -1469,12 +1525,21 @@ constructor( override fun toString() = value.toString() } + /** The main employment type of the individual. */ class Type @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1486,17 +1551,35 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { EMPLOYEE, CONTRACTOR, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { EMPLOYEE, CONTRACTOR, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { EMPLOYEE -> Value.EMPLOYEE @@ -1504,6 +1587,15 @@ constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { EMPLOYEE -> Known.EMPLOYEE @@ -1544,12 +1636,21 @@ constructor( "Employment{subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" } + /** The detailed employment status of the individual. */ class EmploymentStatus @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 { @@ -1571,6 +1672,7 @@ constructor( @JvmStatic fun of(value: String) = EmploymentStatus(JsonField.of(value)) } + /** An enum containing [EmploymentStatus]'s known values. */ enum class Known { ACTIVE, DECEASED, @@ -1581,6 +1683,15 @@ constructor( TERMINATED, } + /** + * An enum containing [EmploymentStatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EmploymentStatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { ACTIVE, DECEASED, @@ -1589,9 +1700,20 @@ constructor( PREHIRE, RETIRED, TERMINATED, + /** + * An enum member indicating that [EmploymentStatus] 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) { ACTIVE -> Value.ACTIVE @@ -1604,6 +1726,14 @@ constructor( 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) { ACTIVE -> Known.ACTIVE @@ -1654,10 +1784,12 @@ constructor( private var validated: Boolean = false fun validate(): Manager = apply { - if (!validated) { - id() - validated = true + if (validated) { + return@apply } + + id() + validated = true } fun toBuilder() = Builder().from(this) @@ -1667,7 +1799,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Manager]. */ + class Builder internal constructor() { private var id: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() 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 536b4c89..694c9061 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 @@ -12,6 +12,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -22,12 +24,12 @@ import java.util.Optional /** Update sandbox individual */ class SandboxIndividualUpdateParams -constructor( +private constructor( private val individualId: String, private val body: SandboxIndividualUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun individualId(): String = individualId @@ -117,11 +119,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): SandboxIndividualUpdateBody = body + @JvmSynthetic internal fun _body(): SandboxIndividualUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun getPathParam(index: Int): String { return when (index) { @@ -273,21 +275,23 @@ constructor( private var validated: Boolean = false fun validate(): SandboxIndividualUpdateBody = apply { - if (!validated) { - dob() - emails().map { it.forEach { it.validate() } } - encryptedSsn() - ethnicity() - firstName() - gender() - lastName() - middleName() - phoneNumbers().map { it.forEach { it?.validate() } } - preferredName() - residence().map { it.validate() } - ssn() - validated = true + if (validated) { + return@apply } + + dob() + emails().ifPresent { it.forEach { it.validate() } } + encryptedSsn() + ethnicity() + firstName() + gender() + lastName() + middleName() + phoneNumbers().ifPresent { it.forEach { it?.validate() } } + preferredName() + residence().ifPresent { it.validate() } + ssn() + validated = true } fun toBuilder() = Builder().from(this) @@ -297,7 +301,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SandboxIndividualUpdateBody]. */ + class Builder internal constructor() { private var dob: JsonField = JsonMissing.of() private var emails: JsonField>? = null @@ -553,8 +558,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SandboxIndividualUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var individualId: String? = null private var body: SandboxIndividualUpdateBody.Builder = @@ -825,7 +831,7 @@ constructor( fun build(): SandboxIndividualUpdateParams = SandboxIndividualUpdateParams( - checkNotNull(individualId) { "`individualId` is required but was not set" }, + checkRequired("individualId", individualId), body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -859,11 +865,13 @@ constructor( private var validated: Boolean = false fun validate(): Email = apply { - if (!validated) { - data() - type() - validated = true + if (validated) { + return@apply } + + data() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -873,7 +881,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Email]. */ + class Builder internal constructor() { private var data: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -929,6 +938,14 @@ 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 { @@ -940,17 +957,35 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { WORK, PERSONAL, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { WORK, PERSONAL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { WORK -> Value.WORK @@ -958,6 +993,15 @@ constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { WORK -> Known.WORK @@ -998,12 +1042,21 @@ constructor( "Email{data=$data, type=$type, additionalProperties=$additionalProperties}" } + /** The EEOC-defined ethnicity of the individual. */ class Ethnicity @JsonCreator private constructor( private val value: JsonField, ) : Enum { + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { @@ -1028,6 +1081,7 @@ constructor( @JvmStatic fun of(value: String) = Ethnicity(JsonField.of(value)) } + /** An enum containing [Ethnicity]'s known values. */ enum class Known { ASIAN, WHITE, @@ -1039,6 +1093,15 @@ constructor( DECLINE_TO_SPECIFY, } + /** + * An enum containing [Ethnicity]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Ethnicity] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { ASIAN, WHITE, @@ -1048,9 +1111,19 @@ constructor( HISPANIC_OR_LATINO, TWO_OR_MORE_RACES, DECLINE_TO_SPECIFY, + /** + * An enum member indicating that [Ethnicity] 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) { ASIAN -> Value.ASIAN @@ -1064,6 +1137,14 @@ constructor( 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) { ASIAN -> Known.ASIAN @@ -1092,12 +1173,21 @@ constructor( override fun toString() = value.toString() } + /** The gender of the individual. */ class Gender @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 { @@ -1113,6 +1203,7 @@ constructor( @JvmStatic fun of(value: String) = Gender(JsonField.of(value)) } + /** An enum containing [Gender]'s known values. */ enum class Known { FEMALE, MALE, @@ -1120,14 +1211,31 @@ constructor( DECLINE_TO_SPECIFY, } + /** + * An enum containing [Gender]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Gender] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { FEMALE, MALE, OTHER, DECLINE_TO_SPECIFY, + /** An enum member indicating that [Gender] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { FEMALE -> Value.FEMALE @@ -1137,6 +1245,14 @@ constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { FEMALE -> Known.FEMALE @@ -1188,11 +1304,13 @@ constructor( private var validated: Boolean = false fun validate(): PhoneNumber = apply { - if (!validated) { - data() - type() - validated = true + if (validated) { + return@apply } + + data() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1202,7 +1320,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PhoneNumber]. */ + class Builder internal constructor() { private var data: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -1258,6 +1377,14 @@ 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 { @@ -1269,17 +1396,35 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { WORK, PERSONAL, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { WORK, PERSONAL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ fun value(): Value = when (this) { WORK -> Value.WORK @@ -1287,6 +1432,15 @@ constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { WORK -> Known.WORK 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 3a260bdd..874c66b6 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException @@ -45,11 +46,13 @@ private constructor( private var validated: Boolean = false fun validate(): SandboxJobConfiguration = apply { - if (!validated) { - completionStatus() - type() - validated = true + if (validated) { + return@apply } + + completionStatus() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -59,7 +62,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SandboxJobConfiguration]. */ + class Builder internal constructor() { private var completionStatus: JsonField? = null private var type: JsonField? = null @@ -104,8 +108,8 @@ private constructor( fun build(): SandboxJobConfiguration = SandboxJobConfiguration( - checkNotNull(completionStatus) { "`completionStatus` is required but was not set" }, - checkNotNull(type) { "`type` is required but was not set" }, + checkRequired("completionStatus", completionStatus), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -116,6 +120,14 @@ 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 { @@ -131,6 +143,7 @@ private constructor( @JvmStatic fun of(value: String) = CompletionStatus(JsonField.of(value)) } + /** An enum containing [CompletionStatus]'s known values. */ enum class Known { COMPLETE, REAUTH_ERROR, @@ -138,14 +151,34 @@ private constructor( ERROR, } + /** + * An enum containing [CompletionStatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [CompletionStatus] 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 { COMPLETE, REAUTH_ERROR, PERMISSIONS_ERROR, ERROR, + /** + * An enum member indicating that [CompletionStatus] 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) { COMPLETE -> Value.COMPLETE @@ -155,6 +188,14 @@ private constructor( 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) { COMPLETE -> Known.COMPLETE @@ -185,6 +226,14 @@ 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 { @@ -194,21 +243,47 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { DATA_SYNC_ALL, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { DATA_SYNC_ALL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { DATA_SYNC_ALL -> Value.DATA_SYNC_ALL else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { DATA_SYNC_ALL -> Known.DATA_SYNC_ALL diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfigurationRetrieveParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfigurationRetrieveParams.kt index 92235e08..0eeb3408 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfigurationRetrieveParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfigurationRetrieveParams.kt @@ -3,24 +3,25 @@ package com.tryfinch.api.models import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import java.util.Objects /** Get configurations for sandbox jobs */ class SandboxJobConfigurationRetrieveParams -constructor( +private constructor( private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) @@ -29,8 +30,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SandboxJobConfigurationRetrieveParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfigurationUpdateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfigurationUpdateParams.kt index 0ccd3dcf..6b54e4c1 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfigurationUpdateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfigurationUpdateParams.kt @@ -12,6 +12,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -21,11 +23,11 @@ import java.util.Objects /** Update configurations for sandbox jobs */ class SandboxJobConfigurationUpdateParams -constructor( +private constructor( private val body: SandboxJobConfigurationUpdateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun completionStatus(): CompletionStatus = body.completionStatus() @@ -41,11 +43,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): SandboxJobConfigurationUpdateBody = body + @JvmSynthetic internal fun _body(): SandboxJobConfigurationUpdateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect class SandboxJobConfigurationUpdateBody @@ -76,11 +78,13 @@ constructor( private var validated: Boolean = false fun validate(): SandboxJobConfigurationUpdateBody = apply { - if (!validated) { - completionStatus() - type() - validated = true + if (validated) { + return@apply } + + completionStatus() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -90,7 +94,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SandboxJobConfigurationUpdateBody]. */ + class Builder internal constructor() { private var completionStatus: JsonField? = null private var type: JsonField? = null @@ -138,10 +143,8 @@ constructor( fun build(): SandboxJobConfigurationUpdateBody = SandboxJobConfigurationUpdateBody( - checkNotNull(completionStatus) { - "`completionStatus` is required but was not set" - }, - checkNotNull(type) { "`type` is required but was not set" }, + checkRequired("completionStatus", completionStatus), + checkRequired("type", type), additionalProperties.toImmutable(), ) } @@ -171,8 +174,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SandboxJobConfigurationUpdateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: SandboxJobConfigurationUpdateBody.Builder = SandboxJobConfigurationUpdateBody.builder() @@ -332,6 +336,14 @@ 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 { @@ -347,6 +359,7 @@ constructor( @JvmStatic fun of(value: String) = CompletionStatus(JsonField.of(value)) } + /** An enum containing [CompletionStatus]'s known values. */ enum class Known { COMPLETE, REAUTH_ERROR, @@ -354,14 +367,34 @@ constructor( ERROR, } + /** + * An enum containing [CompletionStatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [CompletionStatus] 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 { COMPLETE, REAUTH_ERROR, PERMISSIONS_ERROR, ERROR, + /** + * An enum member indicating that [CompletionStatus] 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) { COMPLETE -> Value.COMPLETE @@ -371,6 +404,14 @@ constructor( 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) { COMPLETE -> Known.COMPLETE @@ -401,6 +442,14 @@ 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 { @@ -410,21 +459,47 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { DATA_SYNC_ALL, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { DATA_SYNC_ALL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { DATA_SYNC_ALL -> Value.DATA_SYNC_ALL else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { DATA_SYNC_ALL -> Known.DATA_SYNC_ALL 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 23c24cf8..8babd659 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 @@ -12,6 +12,8 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +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.immutableEmptyMap @@ -21,11 +23,11 @@ import java.util.Objects /** Enqueue a new sandbox job */ class SandboxJobCreateParams -constructor( +private constructor( private val body: SandboxJobCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { /** The type of job to start. Currently the only supported type is `data_sync_all` */ fun type(): Type = body.type() @@ -39,11 +41,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): SandboxJobCreateBody = body + @JvmSynthetic internal fun _body(): SandboxJobCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams @NoAutoDetect class SandboxJobCreateBody @@ -67,10 +69,12 @@ constructor( private var validated: Boolean = false fun validate(): SandboxJobCreateBody = apply { - if (!validated) { - type() - validated = true + if (validated) { + return@apply } + + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -80,7 +84,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SandboxJobCreateBody]. */ + class Builder internal constructor() { private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -118,7 +123,7 @@ constructor( fun build(): SandboxJobCreateBody = SandboxJobCreateBody( - checkNotNull(type) { "`type` is required but was not set" }, + checkRequired("type", type), additionalProperties.toImmutable() ) } @@ -148,8 +153,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SandboxJobCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: SandboxJobCreateBody.Builder = SandboxJobCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() @@ -293,12 +299,21 @@ constructor( ) } + /** The type of job to start. Currently the only supported type is `data_sync_all` */ 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 { @@ -308,21 +323,47 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { DATA_SYNC_ALL, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { DATA_SYNC_ALL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { DATA_SYNC_ALL -> Value.DATA_SYNC_ALL else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { DATA_SYNC_ALL -> Known.DATA_SYNC_ALL 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 3aefbc7b..c0829f94 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.Params import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import com.tryfinch.api.core.immutableEmptyMap @@ -22,11 +23,11 @@ import java.util.Optional /** Add a new sandbox payment */ class SandboxPaymentCreateParams -constructor( +private constructor( private val body: SandboxPaymentCreateBody, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun endDate(): Optional = body.endDate() @@ -46,11 +47,11 @@ constructor( fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getBody(): SandboxPaymentCreateBody = body + @JvmSynthetic internal fun _body(): SandboxPaymentCreateBody = body - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + override fun _headers(): Headers = additionalHeaders - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = additionalQueryParams /** * Fields to configure the payment. Takes all fields from the `/payment` endpoint. All fields @@ -95,12 +96,14 @@ constructor( private var validated: Boolean = false fun validate(): SandboxPaymentCreateBody = apply { - if (!validated) { - endDate() - payStatements().map { it.forEach { it.validate() } } - startDate() - validated = true + if (validated) { + return@apply } + + endDate() + payStatements().ifPresent { it.forEach { it.validate() } } + startDate() + validated = true } fun toBuilder() = Builder().from(this) @@ -110,7 +113,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SandboxPaymentCreateBody]. */ + class Builder internal constructor() { private var endDate: JsonField = JsonMissing.of() private var payStatements: JsonField>? = null @@ -206,8 +210,9 @@ constructor( @JvmStatic fun builder() = Builder() } + /** A builder for [SandboxPaymentCreateParams]. */ @NoAutoDetect - class Builder { + class Builder internal constructor() { private var body: SandboxPaymentCreateBody.Builder = SandboxPaymentCreateBody.builder() private var additionalHeaders: Headers.Builder = Headers.builder() @@ -481,19 +486,21 @@ constructor( private var validated: Boolean = false fun validate(): PayStatement = apply { - if (!validated) { - earnings().map { it.forEach { it?.validate() } } - employeeDeductions().map { it.forEach { it?.validate() } } - employerContributions().map { it.forEach { it?.validate() } } - grossPay().map { it.validate() } - individualId() - netPay().map { it.validate() } - paymentMethod() - taxes().map { it.forEach { it?.validate() } } - totalHours() - type() - validated = true + if (validated) { + return@apply } + + earnings().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() + taxes().ifPresent { it.forEach { it?.validate() } } + totalHours() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -503,7 +510,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [PayStatement]. */ + class Builder internal constructor() { private var earnings: JsonField>? = null private var employeeDeductions: JsonField>? = null @@ -794,14 +802,16 @@ constructor( private var validated: Boolean = false fun validate(): Earning = apply { - if (!validated) { - amount() - currency() - hours() - name() - type() - validated = true + if (validated) { + return@apply } + + amount() + currency() + hours() + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -811,7 +821,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Earning]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -928,12 +939,21 @@ constructor( ) } + /** The type of earning. */ 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 { @@ -967,6 +987,7 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { SALARY, WAGE, @@ -983,6 +1004,15 @@ constructor( OTHER, } + /** + * 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 { SALARY, WAGE, @@ -997,9 +1027,19 @@ constructor( TIPS, _1099, OTHER, + /** + * 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) { SALARY -> Value.SALARY @@ -1018,6 +1058,15 @@ constructor( 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) { SALARY -> Known.SALARY @@ -1129,14 +1178,16 @@ constructor( private var validated: Boolean = false fun validate(): EmployeeDeduction = apply { - if (!validated) { - amount() - currency() - name() - preTax() - type() - validated = true + if (validated) { + return@apply } + + amount() + currency() + name() + preTax() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1146,7 +1197,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EmployeeDeduction]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -1320,13 +1372,15 @@ constructor( private var validated: Boolean = false fun validate(): EmployerContribution = apply { - if (!validated) { - amount() - currency() - name() - type() - validated = true + if (validated) { + return@apply } + + amount() + currency() + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1336,7 +1390,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [EmployerContribution]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -1443,12 +1498,21 @@ constructor( "EmployerContribution{amount=$amount, currency=$currency, name=$name, type=$type, additionalProperties=$additionalProperties}" } + /** The payment method. */ class PaymentMethod @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 { @@ -1460,17 +1524,38 @@ constructor( @JvmStatic fun of(value: String) = PaymentMethod(JsonField.of(value)) } + /** An enum containing [PaymentMethod]'s known values. */ enum class Known { CHECK, DIRECT_DEPOSIT, } + /** + * An enum containing [PaymentMethod]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PaymentMethod] 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 { CHECK, DIRECT_DEPOSIT, + /** + * An enum member indicating that [PaymentMethod] 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) { CHECK -> Value.CHECK @@ -1478,6 +1563,15 @@ constructor( 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) { CHECK -> Known.CHECK @@ -1561,14 +1655,16 @@ constructor( private var validated: Boolean = false fun validate(): Tax = apply { - if (!validated) { - amount() - currency() - employer() - name() - type() - validated = true + if (validated) { + return@apply } + + amount() + currency() + employer() + name() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -1578,7 +1674,8 @@ constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Tax]. */ + class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var currency: JsonField = JsonMissing.of() @@ -1684,12 +1781,21 @@ constructor( ) } + /** The type of taxes. */ 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 { @@ -1705,6 +1811,7 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { STATE, FEDERAL, @@ -1712,14 +1819,33 @@ constructor( FICA, } + /** + * 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 { STATE, FEDERAL, LOCAL, FICA, + /** + * 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) { STATE -> Value.STATE @@ -1729,6 +1855,15 @@ constructor( 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) { STATE -> Known.STATE @@ -1771,12 +1906,21 @@ constructor( "Tax{amount=$amount, currency=$currency, employer=$employer, name=$name, type=$type, additionalProperties=$additionalProperties}" } + /** The type of the payment associated with the pay statement. */ 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 { @@ -1790,19 +1934,37 @@ constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { REGULAR_PAYROLL, OFF_CYCLE_PAYROLL, ONE_TIME_PAYMENT, } + /** + * 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 { REGULAR_PAYROLL, OFF_CYCLE_PAYROLL, ONE_TIME_PAYMENT, + /** 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) { REGULAR_PAYROLL -> Value.REGULAR_PAYROLL @@ -1811,6 +1973,15 @@ constructor( 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) { REGULAR_PAYROLL -> Known.REGULAR_PAYROLL 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 9a9624c4..43a46246 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import java.util.Objects @@ -47,11 +48,13 @@ private constructor( private var validated: Boolean = false fun validate(): SessionNewResponse = apply { - if (!validated) { - connectUrl() - sessionId() - validated = true + if (validated) { + return@apply } + + connectUrl() + sessionId() + validated = true } fun toBuilder() = Builder().from(this) @@ -61,7 +64,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SessionNewResponse]. */ + class Builder internal constructor() { private var connectUrl: JsonField? = null private var sessionId: JsonField? = null @@ -107,8 +111,8 @@ private constructor( fun build(): SessionNewResponse = SessionNewResponse( - checkNotNull(connectUrl) { "`connectUrl` is required but was not set" }, - checkNotNull(sessionId) { "`sessionId` is required but was not set" }, + checkRequired("connectUrl", connectUrl), + checkRequired("sessionId", sessionId), additionalProperties.toImmutable(), ) } 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 0de2251e..b6fe7686 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import java.util.Objects @@ -47,11 +48,13 @@ private constructor( private var validated: Boolean = false fun validate(): SessionReauthenticateResponse = apply { - if (!validated) { - connectUrl() - sessionId() - validated = true + if (validated) { + return@apply } + + connectUrl() + sessionId() + validated = true } fun toBuilder() = Builder().from(this) @@ -61,7 +64,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SessionReauthenticateResponse]. */ + class Builder internal constructor() { private var connectUrl: JsonField? = null private var sessionId: JsonField? = null @@ -107,8 +111,8 @@ private constructor( fun build(): SessionReauthenticateResponse = SessionReauthenticateResponse( - checkNotNull(connectUrl) { "`connectUrl` is required but was not set" }, - checkNotNull(sessionId) { "`sessionId` is required but was not set" }, + checkRequired("connectUrl", connectUrl), + checkRequired("sessionId", sessionId), additionalProperties.toImmutable(), ) } 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 48530069..34774cef 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 @@ -50,11 +50,13 @@ private constructor( private var validated: Boolean = false fun validate(): SupportPerBenefitType = apply { - if (!validated) { - companyBenefits().map { it.validate() } - individualBenefits().map { it.validate() } - validated = true + if (validated) { + return@apply } + + companyBenefits().ifPresent { it.validate() } + individualBenefits().ifPresent { it.validate() } + validated = true } fun toBuilder() = Builder().from(this) @@ -64,7 +66,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportPerBenefitType]. */ + class Builder internal constructor() { private var companyBenefits: JsonField = JsonMissing.of() private var individualBenefits: JsonField = JsonMissing.of() 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 34cf0cd6..174b02b1 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 @@ -130,17 +130,19 @@ private constructor( private var validated: Boolean = false fun validate(): SupportedBenefit = apply { - if (!validated) { - annualMaximum() - catchUp() - companyContribution() - description() - employeeDeduction() - frequencies() - hsaContributionLimit() - type() - validated = true + if (validated) { + return@apply } + + annualMaximum() + catchUp() + companyContribution() + description() + employeeDeduction() + frequencies() + hsaContributionLimit() + type() + validated = true } fun toBuilder() = Builder().from(this) @@ -150,7 +152,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [SupportedBenefit]. */ + class Builder internal constructor() { private var annualMaximum: JsonField = JsonMissing.of() private var catchUp: JsonField = JsonMissing.of() @@ -397,6 +400,14 @@ 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 { @@ -408,17 +419,38 @@ private constructor( @JvmStatic fun of(value: String) = CompanyContribution(JsonField.of(value)) } + /** An enum containing [CompanyContribution]'s known values. */ enum class Known { FIXED, PERCENT, } + /** + * An enum containing [CompanyContribution]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [CompanyContribution] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { FIXED, PERCENT, + /** + * An enum member indicating that [CompanyContribution] was instantiated with an unknown + * value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { FIXED -> Value.FIXED @@ -426,6 +458,14 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { FIXED -> Known.FIXED @@ -454,6 +494,14 @@ 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 { @@ -465,17 +513,38 @@ private constructor( @JvmStatic fun of(value: String) = EmployeeDeduction(JsonField.of(value)) } + /** An enum containing [EmployeeDeduction]'s known values. */ enum class Known { FIXED, PERCENT, } + /** + * An enum containing [EmployeeDeduction]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EmployeeDeduction] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { FIXED, PERCENT, + /** + * An enum member indicating that [EmployeeDeduction] was instantiated with an unknown + * value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { FIXED -> Value.FIXED @@ -483,6 +552,14 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { FIXED -> Known.FIXED @@ -511,6 +588,14 @@ 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 { @@ -522,17 +607,39 @@ private constructor( @JvmStatic fun of(value: String) = HsaContributionLimit(JsonField.of(value)) } + /** An enum containing [HsaContributionLimit]'s known values. */ enum class Known { INDIVIDUAL, FAMILY, } + /** + * An enum containing [HsaContributionLimit]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [HsaContributionLimit] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { INDIVIDUAL, FAMILY, + /** + * An enum member indicating that [HsaContributionLimit] was instantiated with an + * unknown value. + */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { INDIVIDUAL -> Value.INDIVIDUAL @@ -540,6 +647,14 @@ private constructor( else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { INDIVIDUAL -> Known.INDIVIDUAL diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividual.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividual.kt index 4902ebb5..ade72313 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividual.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividual.kt @@ -52,12 +52,14 @@ private constructor( private var validated: Boolean = false fun validate(): UnenrolledIndividual = apply { - if (!validated) { - body().map { it.validate() } - code() - individualId() - validated = true + if (validated) { + return@apply } + + body().ifPresent { it.validate() } + code() + individualId() + validated = true } fun toBuilder() = Builder().from(this) @@ -67,7 +69,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [UnenrolledIndividual]. */ + class Builder internal constructor() { private var body: JsonField = JsonMissing.of() private var code: JsonField = JsonMissing.of() @@ -168,12 +171,14 @@ private constructor( private var validated: Boolean = false fun validate(): Body = apply { - if (!validated) { - finchCode() - message() - name() - validated = true + if (validated) { + return@apply } + + finchCode() + message() + name() + validated = true } fun toBuilder() = Builder().from(this) @@ -183,7 +188,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Body]. */ + class Builder internal constructor() { private var finchCode: JsonField = JsonMissing.of() private var message: JsonField = JsonMissing.of() 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 e6f3e0ad..d1a7e8ba 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 @@ -11,6 +11,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.immutableEmptyMap import com.tryfinch.api.core.toImmutable import java.util.Objects @@ -36,10 +37,12 @@ private constructor( private var validated: Boolean = false fun validate(): UpdateCompanyBenefitResponse = apply { - if (!validated) { - benefitId() - validated = true + if (validated) { + return@apply } + + benefitId() + validated = true } fun toBuilder() = Builder().from(this) @@ -49,7 +52,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [UpdateCompanyBenefitResponse]. */ + class Builder internal constructor() { private var benefitId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -85,7 +89,7 @@ private constructor( fun build(): UpdateCompanyBenefitResponse = UpdateCompanyBenefitResponse( - checkNotNull(benefitId) { "`benefitId` is required but was not set" }, + checkRequired("benefitId", benefitId), additionalProperties.toImmutable() ) } 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 6cdb84bf..98111406 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 @@ -57,12 +57,14 @@ private constructor( private var validated: Boolean = false fun validate(): W42005 = apply { - if (!validated) { - data().map { it.validate() } - type() - year() - validated = true + if (validated) { + return@apply } + + data().ifPresent { it.validate() } + type() + year() + validated = true } fun toBuilder() = Builder().from(this) @@ -72,7 +74,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [W42005]. */ + class Builder internal constructor() { private var data: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -216,14 +219,16 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - additionalWithholding() - exemption() - filingStatus() - individualId() - totalNumberOfAllowances() - validated = true + if (validated) { + return@apply } + + additionalWithholding() + exemption() + filingStatus() + individualId() + totalNumberOfAllowances() + validated = true } fun toBuilder() = Builder().from(this) @@ -233,7 +238,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { private var additionalWithholding: JsonField = JsonMissing.of() private var exemption: JsonField = JsonMissing.of() @@ -340,12 +346,21 @@ private constructor( ) } + /** Indicates exemption status from federal tax withholding. */ class Exemption @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 { @@ -357,17 +372,38 @@ private constructor( @JvmStatic fun of(value: String) = Exemption(JsonField.of(value)) } + /** An enum containing [Exemption]'s known values. */ enum class Known { EXEMPT, NON_EXEMPT, } + /** + * An enum containing [Exemption]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Exemption] 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 { EXEMPT, NON_EXEMPT, + /** + * An enum member indicating that [Exemption] 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) { EXEMPT -> Value.EXEMPT @@ -375,6 +411,15 @@ private constructor( 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) { EXEMPT -> Known.EXEMPT @@ -397,12 +442,21 @@ private constructor( override fun toString() = value.toString() } + /** The individual's filing status for tax purposes. */ class FilingStatus @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 { @@ -418,19 +472,40 @@ private constructor( @JvmStatic fun of(value: String) = FilingStatus(JsonField.of(value)) } + /** An enum containing [FilingStatus]'s known values. */ enum class Known { MARRIED, MARRIED_BUT_WITHHOLD_AT_HIGHER_SINGLE_RATE, SINGLE, } + /** + * An enum containing [FilingStatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FilingStatus] 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 { MARRIED, MARRIED_BUT_WITHHOLD_AT_HIGHER_SINGLE_RATE, SINGLE, + /** + * An enum member indicating that [FilingStatus] 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) { MARRIED -> Value.MARRIED @@ -440,6 +515,15 @@ private constructor( 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) { MARRIED -> Known.MARRIED @@ -482,12 +566,21 @@ private constructor( "Data{additionalWithholding=$additionalWithholding, exemption=$exemption, filingStatus=$filingStatus, individualId=$individualId, totalNumberOfAllowances=$totalNumberOfAllowances, additionalProperties=$additionalProperties}" } + /** Specifies the form type, indicating that this document is a 2005 W4 form. */ 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 { @@ -497,21 +590,47 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { W4_2005, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { W4_2005, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { W4_2005 -> Value.W4_2005 else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { W4_2005 -> Known.W4_2005 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 7314afca..91bf811e 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 @@ -57,12 +57,14 @@ private constructor( private var validated: Boolean = false fun validate(): W42020 = apply { - if (!validated) { - data().map { it.validate() } - type() - year() - validated = true + if (validated) { + return@apply } + + data().ifPresent { it.validate() } + type() + year() + validated = true } fun toBuilder() = Builder().from(this) @@ -72,7 +74,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [W42020]. */ + class Builder internal constructor() { private var data: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -259,17 +262,19 @@ private constructor( private var validated: Boolean = false fun validate(): Data = apply { - if (!validated) { - amountForOtherDependents() - amountForQualifyingChildrenUnder17() - deductions() - extraWithholding() - filingStatus() - individualId() - otherIncome() - totalClaimDependentAndOtherCredits() - validated = true + if (validated) { + return@apply } + + amountForOtherDependents() + amountForQualifyingChildrenUnder17() + deductions() + extraWithholding() + filingStatus() + individualId() + otherIncome() + totalClaimDependentAndOtherCredits() + validated = true } fun toBuilder() = Builder().from(this) @@ -279,7 +284,8 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + /** A builder for [Data]. */ + class Builder internal constructor() { private var amountForOtherDependents: JsonField = JsonMissing.of() private var amountForQualifyingChildrenUnder17: JsonField = JsonMissing.of() @@ -474,12 +480,21 @@ private constructor( ) } + /** The individual's filing status for tax purposes. */ class FilingStatus @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 { @@ -496,19 +511,40 @@ private constructor( @JvmStatic fun of(value: String) = FilingStatus(JsonField.of(value)) } + /** An enum containing [FilingStatus]'s known values. */ enum class Known { HEAD_OF_HOUSEHOLD, MARRIED_FILING_JOINTLY_OR_QUALIFYING_SURVIVING_SPOUSE, SINGLE_OR_MARRIED_FILING_SEPARATELY, } + /** + * An enum containing [FilingStatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FilingStatus] 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 { HEAD_OF_HOUSEHOLD, MARRIED_FILING_JOINTLY_OR_QUALIFYING_SURVIVING_SPOUSE, SINGLE_OR_MARRIED_FILING_SEPARATELY, + /** + * An enum member indicating that [FilingStatus] 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) { HEAD_OF_HOUSEHOLD -> Value.HEAD_OF_HOUSEHOLD @@ -518,6 +554,15 @@ private constructor( 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) { HEAD_OF_HOUSEHOLD -> Known.HEAD_OF_HOUSEHOLD @@ -560,12 +605,21 @@ private constructor( "Data{amountForOtherDependents=$amountForOtherDependents, amountForQualifyingChildrenUnder17=$amountForQualifyingChildrenUnder17, deductions=$deductions, extraWithholding=$extraWithholding, filingStatus=$filingStatus, individualId=$individualId, otherIncome=$otherIncome, totalClaimDependentAndOtherCredits=$totalClaimDependentAndOtherCredits, additionalProperties=$additionalProperties}" } + /** Specifies the form type, indicating that this document is a 2020 W4 form. */ 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 { @@ -575,21 +629,47 @@ private constructor( @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } + /** An enum containing [Type]'s known values. */ enum class Known { W4_2020, } + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { W4_2020, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { W4_2020 -> Value.W4_2020 else -> Value._UNKNOWN } + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ fun known(): Known = when (this) { W4_2020 -> Known.W4_2020 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/WebhookEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/WebhookEvent.kt index 82ad6b1c..57c76c37 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/WebhookEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/WebhookEvent.kt @@ -21,101 +21,124 @@ import java.util.Optional @JsonSerialize(using = WebhookEvent.Serializer::class) class WebhookEvent private constructor( - private val accountUpdateEvent: AccountUpdateEvent? = null, - private val jobCompletionEvent: JobCompletionEvent? = null, - private val companyEvent: CompanyEvent? = null, - private val directoryEvent: DirectoryEvent? = null, - private val employmentEvent: EmploymentEvent? = null, - private val individualEvent: IndividualEvent? = null, - private val paymentEvent: PaymentEvent? = null, - private val payStatementEvent: PayStatementEvent? = null, + private val accountUpdate: AccountUpdateEvent? = null, + private val jobCompletion: JobCompletionEvent? = null, + private val company: CompanyEvent? = null, + private val directory: DirectoryEvent? = null, + private val employment: EmploymentEvent? = null, + private val individual: IndividualEvent? = null, + private val payment: PaymentEvent? = null, + private val payStatement: PayStatementEvent? = null, private val _json: JsonValue? = null, ) { - private var validated: Boolean = false - - fun accountUpdateEvent(): Optional = Optional.ofNullable(accountUpdateEvent) + fun accountUpdate(): Optional = Optional.ofNullable(accountUpdate) - fun jobCompletionEvent(): Optional = Optional.ofNullable(jobCompletionEvent) + fun jobCompletion(): Optional = Optional.ofNullable(jobCompletion) - fun companyEvent(): Optional = Optional.ofNullable(companyEvent) + fun company(): Optional = Optional.ofNullable(company) - fun directoryEvent(): Optional = Optional.ofNullable(directoryEvent) + fun directory(): Optional = Optional.ofNullable(directory) - fun employmentEvent(): Optional = Optional.ofNullable(employmentEvent) + fun employment(): Optional = Optional.ofNullable(employment) - fun individualEvent(): Optional = Optional.ofNullable(individualEvent) + fun individual(): Optional = Optional.ofNullable(individual) - fun paymentEvent(): Optional = Optional.ofNullable(paymentEvent) + fun payment(): Optional = Optional.ofNullable(payment) - fun payStatementEvent(): Optional = Optional.ofNullable(payStatementEvent) + fun payStatement(): Optional = Optional.ofNullable(payStatement) - fun isAccountUpdateEvent(): Boolean = accountUpdateEvent != null + fun isAccountUpdate(): Boolean = accountUpdate != null - fun isJobCompletionEvent(): Boolean = jobCompletionEvent != null + fun isJobCompletion(): Boolean = jobCompletion != null - fun isCompanyEvent(): Boolean = companyEvent != null + fun isCompany(): Boolean = company != null - fun isDirectoryEvent(): Boolean = directoryEvent != null + fun isDirectory(): Boolean = directory != null - fun isEmploymentEvent(): Boolean = employmentEvent != null + fun isEmployment(): Boolean = employment != null - fun isIndividualEvent(): Boolean = individualEvent != null + fun isIndividual(): Boolean = individual != null - fun isPaymentEvent(): Boolean = paymentEvent != null + fun isPayment(): Boolean = payment != null - fun isPayStatementEvent(): Boolean = payStatementEvent != null + fun isPayStatement(): Boolean = payStatement != null - fun asAccountUpdateEvent(): AccountUpdateEvent = - accountUpdateEvent.getOrThrow("accountUpdateEvent") + fun asAccountUpdate(): AccountUpdateEvent = accountUpdate.getOrThrow("accountUpdate") - fun asJobCompletionEvent(): JobCompletionEvent = - jobCompletionEvent.getOrThrow("jobCompletionEvent") + fun asJobCompletion(): JobCompletionEvent = jobCompletion.getOrThrow("jobCompletion") - fun asCompanyEvent(): CompanyEvent = companyEvent.getOrThrow("companyEvent") + fun asCompany(): CompanyEvent = company.getOrThrow("company") - fun asDirectoryEvent(): DirectoryEvent = directoryEvent.getOrThrow("directoryEvent") + fun asDirectory(): DirectoryEvent = directory.getOrThrow("directory") - fun asEmploymentEvent(): EmploymentEvent = employmentEvent.getOrThrow("employmentEvent") + fun asEmployment(): EmploymentEvent = employment.getOrThrow("employment") - fun asIndividualEvent(): IndividualEvent = individualEvent.getOrThrow("individualEvent") + fun asIndividual(): IndividualEvent = individual.getOrThrow("individual") - fun asPaymentEvent(): PaymentEvent = paymentEvent.getOrThrow("paymentEvent") + fun asPayment(): PaymentEvent = payment.getOrThrow("payment") - fun asPayStatementEvent(): PayStatementEvent = payStatementEvent.getOrThrow("payStatementEvent") + fun asPayStatement(): PayStatementEvent = payStatement.getOrThrow("payStatement") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T { return when { - accountUpdateEvent != null -> visitor.visitAccountUpdateEvent(accountUpdateEvent) - jobCompletionEvent != null -> visitor.visitJobCompletionEvent(jobCompletionEvent) - companyEvent != null -> visitor.visitCompanyEvent(companyEvent) - directoryEvent != null -> visitor.visitDirectoryEvent(directoryEvent) - employmentEvent != null -> visitor.visitEmploymentEvent(employmentEvent) - individualEvent != null -> visitor.visitIndividualEvent(individualEvent) - paymentEvent != null -> visitor.visitPaymentEvent(paymentEvent) - payStatementEvent != null -> visitor.visitPayStatementEvent(payStatementEvent) + accountUpdate != null -> visitor.visitAccountUpdate(accountUpdate) + jobCompletion != null -> visitor.visitJobCompletion(jobCompletion) + company != null -> visitor.visitCompany(company) + directory != null -> visitor.visitDirectory(directory) + employment != null -> visitor.visitEmployment(employment) + individual != null -> visitor.visitIndividual(individual) + payment != null -> visitor.visitPayment(payment) + payStatement != null -> visitor.visitPayStatement(payStatement) else -> visitor.unknown(_json) } } + private var validated: Boolean = false + fun validate(): WebhookEvent = apply { - if (!validated) { - if ( - accountUpdateEvent == null && - jobCompletionEvent == null && - companyEvent == null && - directoryEvent == null && - employmentEvent == null && - individualEvent == null && - paymentEvent == null && - payStatementEvent == null - ) { - throw FinchInvalidDataException("Unknown WebhookEvent: $_json") - } - validated = true + if (validated) { + return@apply } + + accept( + object : Visitor { + override fun visitAccountUpdate(accountUpdate: AccountUpdateEvent) { + accountUpdate.validate() + } + + override fun visitJobCompletion(jobCompletion: JobCompletionEvent) { + jobCompletion.validate() + } + + override fun visitCompany(company: CompanyEvent) { + company.validate() + } + + override fun visitDirectory(directory: DirectoryEvent) { + directory.validate() + } + + override fun visitEmployment(employment: EmploymentEvent) { + employment.validate() + } + + override fun visitIndividual(individual: IndividualEvent) { + individual.validate() + } + + override fun visitPayment(payment: PaymentEvent) { + payment.validate() + } + + override fun visitPayStatement(payStatement: PayStatementEvent) { + payStatement.validate() + } + } + ) + validated = true } override fun equals(other: Any?): Boolean { @@ -123,21 +146,21 @@ private constructor( return true } - return /* spotless:off */ other is WebhookEvent && accountUpdateEvent == other.accountUpdateEvent && jobCompletionEvent == other.jobCompletionEvent && companyEvent == other.companyEvent && directoryEvent == other.directoryEvent && employmentEvent == other.employmentEvent && individualEvent == other.individualEvent && paymentEvent == other.paymentEvent && payStatementEvent == other.payStatementEvent /* spotless:on */ + return /* spotless:off */ other is WebhookEvent && accountUpdate == other.accountUpdate && jobCompletion == other.jobCompletion && company == other.company && directory == other.directory && employment == other.employment && individual == other.individual && payment == other.payment && payStatement == other.payStatement /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(accountUpdateEvent, jobCompletionEvent, companyEvent, directoryEvent, employmentEvent, individualEvent, paymentEvent, payStatementEvent) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(accountUpdate, jobCompletion, company, directory, employment, individual, payment, payStatement) /* spotless:on */ override fun toString(): String = when { - accountUpdateEvent != null -> "WebhookEvent{accountUpdateEvent=$accountUpdateEvent}" - jobCompletionEvent != null -> "WebhookEvent{jobCompletionEvent=$jobCompletionEvent}" - companyEvent != null -> "WebhookEvent{companyEvent=$companyEvent}" - directoryEvent != null -> "WebhookEvent{directoryEvent=$directoryEvent}" - employmentEvent != null -> "WebhookEvent{employmentEvent=$employmentEvent}" - individualEvent != null -> "WebhookEvent{individualEvent=$individualEvent}" - paymentEvent != null -> "WebhookEvent{paymentEvent=$paymentEvent}" - payStatementEvent != null -> "WebhookEvent{payStatementEvent=$payStatementEvent}" + accountUpdate != null -> "WebhookEvent{accountUpdate=$accountUpdate}" + jobCompletion != null -> "WebhookEvent{jobCompletion=$jobCompletion}" + company != null -> "WebhookEvent{company=$company}" + directory != null -> "WebhookEvent{directory=$directory}" + employment != null -> "WebhookEvent{employment=$employment}" + individual != null -> "WebhookEvent{individual=$individual}" + payment != null -> "WebhookEvent{payment=$payment}" + payStatement != null -> "WebhookEvent{payStatement=$payStatement}" _json != null -> "WebhookEvent{_unknown=$_json}" else -> throw IllegalStateException("Invalid WebhookEvent") } @@ -145,94 +168,108 @@ private constructor( companion object { @JvmStatic - fun ofAccountUpdateEvent(accountUpdateEvent: AccountUpdateEvent) = - WebhookEvent(accountUpdateEvent = accountUpdateEvent) + fun ofAccountUpdate(accountUpdate: AccountUpdateEvent) = + WebhookEvent(accountUpdate = accountUpdate) @JvmStatic - fun ofJobCompletionEvent(jobCompletionEvent: JobCompletionEvent) = - WebhookEvent(jobCompletionEvent = jobCompletionEvent) + fun ofJobCompletion(jobCompletion: JobCompletionEvent) = + WebhookEvent(jobCompletion = jobCompletion) - @JvmStatic - fun ofCompanyEvent(companyEvent: CompanyEvent) = WebhookEvent(companyEvent = companyEvent) + @JvmStatic fun ofCompany(company: CompanyEvent) = WebhookEvent(company = company) - @JvmStatic - fun ofDirectoryEvent(directoryEvent: DirectoryEvent) = - WebhookEvent(directoryEvent = directoryEvent) + @JvmStatic fun ofDirectory(directory: DirectoryEvent) = WebhookEvent(directory = directory) @JvmStatic - fun ofEmploymentEvent(employmentEvent: EmploymentEvent) = - WebhookEvent(employmentEvent = employmentEvent) + fun ofEmployment(employment: EmploymentEvent) = WebhookEvent(employment = employment) @JvmStatic - fun ofIndividualEvent(individualEvent: IndividualEvent) = - WebhookEvent(individualEvent = individualEvent) + fun ofIndividual(individual: IndividualEvent) = WebhookEvent(individual = individual) - @JvmStatic - fun ofPaymentEvent(paymentEvent: PaymentEvent) = WebhookEvent(paymentEvent = paymentEvent) + @JvmStatic fun ofPayment(payment: PaymentEvent) = WebhookEvent(payment = payment) @JvmStatic - fun ofPayStatementEvent(payStatementEvent: PayStatementEvent) = - WebhookEvent(payStatementEvent = payStatementEvent) + fun ofPayStatement(payStatement: PayStatementEvent) = + WebhookEvent(payStatement = payStatement) } + /** + * An interface that defines how to map each variant of [WebhookEvent] to a value of type [T]. + */ interface Visitor { - fun visitAccountUpdateEvent(accountUpdateEvent: AccountUpdateEvent): T + fun visitAccountUpdate(accountUpdate: AccountUpdateEvent): T - fun visitJobCompletionEvent(jobCompletionEvent: JobCompletionEvent): T + fun visitJobCompletion(jobCompletion: JobCompletionEvent): T - fun visitCompanyEvent(companyEvent: CompanyEvent): T + fun visitCompany(company: CompanyEvent): T - fun visitDirectoryEvent(directoryEvent: DirectoryEvent): T + fun visitDirectory(directory: DirectoryEvent): T - fun visitEmploymentEvent(employmentEvent: EmploymentEvent): T + fun visitEmployment(employment: EmploymentEvent): T - fun visitIndividualEvent(individualEvent: IndividualEvent): T + fun visitIndividual(individual: IndividualEvent): T - fun visitPaymentEvent(paymentEvent: PaymentEvent): T + fun visitPayment(payment: PaymentEvent): T - fun visitPayStatementEvent(payStatementEvent: PayStatementEvent): T + fun visitPayStatement(payStatement: PayStatementEvent): T + /** + * Maps an unknown variant of [WebhookEvent] to a value of type [T]. + * + * An instance of [WebhookEvent] 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 WebhookEvent: $json") } } - class Deserializer : BaseDeserializer(WebhookEvent::class) { + internal class Deserializer : BaseDeserializer(WebhookEvent::class) { override fun ObjectCodec.deserialize(node: JsonNode): WebhookEvent { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return WebhookEvent(accountUpdateEvent = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return WebhookEvent(jobCompletionEvent = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return WebhookEvent(companyEvent = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return WebhookEvent(directoryEvent = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return WebhookEvent(employmentEvent = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return WebhookEvent(individualEvent = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return WebhookEvent(paymentEvent = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return WebhookEvent(payStatementEvent = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return WebhookEvent(accountUpdate = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return WebhookEvent(jobCompletion = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return WebhookEvent(company = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return WebhookEvent(directory = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return WebhookEvent(employment = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return WebhookEvent(individual = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return WebhookEvent(payment = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return WebhookEvent(payStatement = it, _json = json) + } return WebhookEvent(_json = json) } } - class Serializer : BaseSerializer(WebhookEvent::class) { + internal class Serializer : BaseSerializer(WebhookEvent::class) { override fun serialize( value: WebhookEvent, @@ -240,14 +277,14 @@ private constructor( provider: SerializerProvider ) { when { - value.accountUpdateEvent != null -> generator.writeObject(value.accountUpdateEvent) - value.jobCompletionEvent != null -> generator.writeObject(value.jobCompletionEvent) - value.companyEvent != null -> generator.writeObject(value.companyEvent) - value.directoryEvent != null -> generator.writeObject(value.directoryEvent) - value.employmentEvent != null -> generator.writeObject(value.employmentEvent) - value.individualEvent != null -> generator.writeObject(value.individualEvent) - value.paymentEvent != null -> generator.writeObject(value.paymentEvent) - value.payStatementEvent != null -> generator.writeObject(value.payStatementEvent) + value.accountUpdate != null -> generator.writeObject(value.accountUpdate) + value.jobCompletion != null -> generator.writeObject(value.jobCompletion) + value.company != null -> generator.writeObject(value.company) + value.directory != null -> generator.writeObject(value.directory) + value.employment != null -> generator.writeObject(value.employment) + value.individual != null -> generator.writeObject(value.individual) + value.payment != null -> generator.writeObject(value.payment) + value.payStatement != null -> generator.writeObject(value.payStatement) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid WebhookEvent") } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncImpl.kt index 40c87fc5..16392293 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.errors.FinchException import com.tryfinch.api.models.AccessTokenCreateParams @@ -18,7 +19,7 @@ import com.tryfinch.api.models.CreateAccessTokenResponse import java.util.concurrent.CompletableFuture class AccessTokenServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AccessTokenServiceAsync { @@ -60,20 +61,22 @@ constructor( .method(HttpMethod.POST) .addPathSegments("auth", "token") .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) + .replaceAllQueryParams(params._queryParams()) .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, modifiedParams.getBody())) + .putAllHeaders(params._headers()) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt index df3dbbd5..12fb92bd 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.AccountDisconnectParams import com.tryfinch.api.models.AccountIntrospectParams @@ -19,7 +20,7 @@ import com.tryfinch.api.models.Introspection import java.util.concurrent.CompletableFuture class AccountServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AccountServiceAsync { @@ -37,22 +38,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("disconnect") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { disconnectHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { disconnectHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val introspectHandler: Handler = @@ -67,20 +66,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("introspect") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { introspectHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { introspectHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsyncImpl.kt index f4de95dd..f86fb285 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsyncImpl.kt @@ -7,7 +7,7 @@ import com.tryfinch.api.services.async.connect.SessionServiceAsync import com.tryfinch.api.services.async.connect.SessionServiceAsyncImpl class ConnectServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ConnectServiceAsync { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsyncImpl.kt index ad82c240..d39d2925 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsyncImpl.kt @@ -21,7 +21,7 @@ import com.tryfinch.api.services.async.hris.PaymentServiceAsync import com.tryfinch.api.services.async.hris.PaymentServiceAsyncImpl class HrisServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : HrisServiceAsync { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsyncImpl.kt index ad50cc4a..a8a0006f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsyncImpl.kt @@ -9,7 +9,7 @@ import com.tryfinch.api.services.async.jobs.ManualServiceAsync import com.tryfinch.api.services.async.jobs.ManualServiceAsyncImpl class JobServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : JobServiceAsync { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsyncImpl.kt index 91b9aad5..6431023a 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsyncImpl.kt @@ -7,7 +7,7 @@ import com.tryfinch.api.services.async.payroll.PayGroupServiceAsync import com.tryfinch.api.services.async.payroll.PayGroupServiceAsyncImpl class PayrollServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : PayrollServiceAsync { 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 feecd79d..ace4182b 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 @@ -10,6 +10,7 @@ import com.tryfinch.api.core.handlers.withErrorHandler import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.Provider import com.tryfinch.api.models.ProviderListPageAsync @@ -17,7 +18,7 @@ import com.tryfinch.api.models.ProviderListParams import java.util.concurrent.CompletableFuture class ProviderServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ProviderServiceAsync { @@ -35,22 +36,25 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("providers") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } + } } - } - .let { ProviderListPageAsync.Response.Builder().items(it).build() } - .let { ProviderListPageAsync.of(this, params, it) } - } + .let { + ProviderListPageAsync.of( + this, + params, + ProviderListPageAsync.Response.builder().items(it).build() + ) + } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncImpl.kt index 70cf33df..70742b77 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncImpl.kt @@ -11,13 +11,14 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.RequestForwardingForwardParams import com.tryfinch.api.models.RequestForwardingForwardResponse import java.util.concurrent.CompletableFuture class RequestForwardingServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : RequestForwardingServiceAsync { @@ -40,21 +41,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("forward") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { forwardHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { forwardHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsyncImpl.kt index 3054e2d0..1557fa1a 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsyncImpl.kt @@ -19,7 +19,7 @@ import com.tryfinch.api.services.async.sandbox.PaymentServiceAsync import com.tryfinch.api.services.async.sandbox.PaymentServiceAsyncImpl class SandboxServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : SandboxServiceAsync { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsyncImpl.kt index f47b6f97..d85619e0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsyncImpl.kt @@ -19,7 +19,7 @@ import javax.crypto.Mac import javax.crypto.spec.SecretKeySpec class WebhookServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : WebhookServiceAsync { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncImpl.kt index 641cc8a4..b2d06dbc 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.ConnectSessionNewParams import com.tryfinch.api.models.ConnectSessionReauthenticateParams @@ -19,7 +20,7 @@ import com.tryfinch.api.models.SessionReauthenticateResponse import java.util.concurrent.CompletableFuture class SessionServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : SessionServiceAsync { @@ -37,22 +38,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("connect", "sessions") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { newHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { newHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val reauthenticateHandler: Handler = @@ -68,21 +67,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("connect", "sessions", "reauthenticate") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { reauthenticateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { reauthenticateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt index 611853e5..cf6c3816 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.CompanyBenefit import com.tryfinch.api.models.CreateCompanyBenefitsResponse @@ -28,7 +29,7 @@ import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsyncImpl import java.util.concurrent.CompletableFuture class BenefitServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : BenefitServiceAsync { @@ -56,22 +57,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("employer", "benefits") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -86,21 +85,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "benefits", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -116,22 +113,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("employer", "benefits", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler> = @@ -146,23 +141,26 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "benefits") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } + } } - } - .let { HrisBenefitListPageAsync.Response.Builder().items(it).build() } - .let { HrisBenefitListPageAsync.of(this, params, it) } - } + .let { + HrisBenefitListPageAsync.of( + this, + params, + HrisBenefitListPageAsync.Response.builder().items(it).build() + ) + } + } } private val listSupportedBenefitsHandler: Handler> = @@ -177,24 +175,27 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "benefits", "meta") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listSupportedBenefitsHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listSupportedBenefitsHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } + } + } + .let { + HrisBenefitListSupportedBenefitsPageAsync.of( + this, + params, + HrisBenefitListSupportedBenefitsPageAsync.Response.builder() + .items(it) + .build() + ) } - } - .let { - HrisBenefitListSupportedBenefitsPageAsync.Response.Builder().items(it).build() - } - .let { HrisBenefitListSupportedBenefitsPageAsync.of(this, params, it) } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsyncImpl.kt index de0deb6f..fe766f4a 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsyncImpl.kt @@ -10,13 +10,14 @@ import com.tryfinch.api.core.handlers.withErrorHandler import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.Company import com.tryfinch.api.models.HrisCompanyRetrieveParams import java.util.concurrent.CompletableFuture class CompanyServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : CompanyServiceAsync { @@ -34,20 +35,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "company") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt index a61173f8..6c42d153 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt @@ -21,8 +21,8 @@ interface DirectoryServiceAsync { ): CompletableFuture /** Read company directory and organization structure */ - @JvmOverloads @Deprecated("use `list` instead") + @JvmOverloads fun listIndividuals( params: HrisDirectoryListIndividualsParams, requestOptions: RequestOptions = RequestOptions.none() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncImpl.kt index 34b21439..2c864b2b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncImpl.kt @@ -10,6 +10,7 @@ import com.tryfinch.api.core.handlers.withErrorHandler import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.HrisDirectoryListIndividualsPageAsync import com.tryfinch.api.models.HrisDirectoryListIndividualsParams @@ -18,7 +19,7 @@ import com.tryfinch.api.models.HrisDirectoryListParams import java.util.concurrent.CompletableFuture class DirectoryServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : DirectoryServiceAsync { @@ -37,22 +38,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "directory") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { HrisDirectoryListPageAsync.of(this, params, it) } - } + .let { HrisDirectoryListPageAsync.of(this, params, it) } + } } private val listIndividualsHandler: Handler = @@ -69,21 +68,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "directory") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listIndividualsHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listIndividualsHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { HrisDirectoryListIndividualsPageAsync.of(this, params, it) } - } + .let { HrisDirectoryListIndividualsPageAsync.of(this, params, it) } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsyncImpl.kt index 6220340d..ee9d305e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsyncImpl.kt @@ -10,6 +10,7 @@ import com.tryfinch.api.core.handlers.withErrorHandler import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.DocumentListResponse import com.tryfinch.api.models.DocumentRetreiveResponse @@ -18,7 +19,7 @@ import com.tryfinch.api.models.HrisDocumentRetreiveParams import java.util.concurrent.CompletableFuture class DocumentServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : DocumentServiceAsync { @@ -38,21 +39,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "documents") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retreiveHandler: Handler = @@ -71,20 +70,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "documents", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retreiveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retreiveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsyncImpl.kt index ff2b0852..4641c6dc 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsyncImpl.kt @@ -11,13 +11,14 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.HrisEmploymentRetrieveManyPageAsync import com.tryfinch.api.models.HrisEmploymentRetrieveManyParams import java.util.concurrent.CompletableFuture class EmploymentServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : EmploymentServiceAsync { @@ -36,22 +37,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("employer", "employment") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveManyHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveManyHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { HrisEmploymentRetrieveManyPageAsync.of(this, params, it) } - } + .let { HrisEmploymentRetrieveManyPageAsync.of(this, params, it) } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsyncImpl.kt index 54028d1b..8ee3f4d5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsyncImpl.kt @@ -11,13 +11,14 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.HrisIndividualRetrieveManyPageAsync import com.tryfinch.api.models.HrisIndividualRetrieveManyParams import java.util.concurrent.CompletableFuture class IndividualServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : IndividualServiceAsync { @@ -36,22 +37,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("employer", "individual") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveManyHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveManyHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { HrisIndividualRetrieveManyPageAsync.of(this, params, it) } - } + .let { HrisIndividualRetrieveManyPageAsync.of(this, params, it) } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsyncImpl.kt index 9767c9c7..92a73112 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsyncImpl.kt @@ -11,13 +11,14 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.HrisPayStatementRetrieveManyPageAsync import com.tryfinch.api.models.HrisPayStatementRetrieveManyParams import java.util.concurrent.CompletableFuture class PayStatementServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : PayStatementServiceAsync { @@ -40,22 +41,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("employer", "pay-statement") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveManyHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveManyHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { HrisPayStatementRetrieveManyPageAsync.of(this, params, it) } - } + .let { HrisPayStatementRetrieveManyPageAsync.of(this, params, it) } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsyncImpl.kt index 8748962c..d78ed34b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsyncImpl.kt @@ -10,6 +10,7 @@ import com.tryfinch.api.core.handlers.withErrorHandler import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.HrisPaymentListPageAsync import com.tryfinch.api.models.HrisPaymentListParams @@ -17,7 +18,7 @@ import com.tryfinch.api.models.Payment import java.util.concurrent.CompletableFuture class PaymentServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : PaymentServiceAsync { @@ -35,22 +36,25 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "payment") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } + } } - } - .let { HrisPaymentListPageAsync.Response.Builder().items(it).build() } - .let { HrisPaymentListPageAsync.of(this, params, it) } - } + .let { + HrisPaymentListPageAsync.of( + this, + params, + HrisPaymentListPageAsync.Response.builder().items(it).build() + ) + } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncImpl.kt index 1442cf1f..b60550b9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsPageAsync @@ -23,7 +24,7 @@ import com.tryfinch.api.models.UnenrolledIndividual import java.util.concurrent.CompletableFuture class IndividualServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : IndividualServiceAsync { @@ -42,21 +43,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "benefits", params.getPathParam(0), "enrolled") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { enrolledIdsHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { enrolledIdsHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveManyBenefitsHandler: Handler> = @@ -72,27 +71,28 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "benefits", params.getPathParam(0), "individuals") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveManyBenefitsHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveManyBenefitsHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } + } } - } - .let { - HrisBenefitIndividualRetrieveManyBenefitsPageAsync.Response.Builder() - .items(it) - .build() - } - .let { HrisBenefitIndividualRetrieveManyBenefitsPageAsync.of(this, params, it) } - } + .let { + HrisBenefitIndividualRetrieveManyBenefitsPageAsync.of( + this, + params, + HrisBenefitIndividualRetrieveManyBenefitsPageAsync.Response.builder() + .items(it) + .build() + ) + } + } } private val unenrollManyHandler: Handler> = @@ -108,25 +108,28 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("employer", "benefits", params.getPathParam(0), "individuals") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { unenrollManyHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { unenrollManyHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } + } + } + .let { + HrisBenefitIndividualUnenrollManyPageAsync.of( + this, + params, + HrisBenefitIndividualUnenrollManyPageAsync.Response.builder() + .items(it) + .build() + ) } - } - .let { - HrisBenefitIndividualUnenrollManyPageAsync.Response.Builder().items(it).build() - } - .let { HrisBenefitIndividualUnenrollManyPageAsync.of(this, params, it) } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncImpl.kt index c32fa74c..b40330e6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.AutomatedAsyncJob import com.tryfinch.api.models.AutomatedCreateResponse @@ -21,7 +22,7 @@ import com.tryfinch.api.models.JobAutomatedRetrieveParams import java.util.concurrent.CompletableFuture class AutomatedServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AutomatedServiceAsync { @@ -54,22 +55,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("jobs", "automated") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val retrieveHandler: Handler = @@ -84,21 +83,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("jobs", "automated", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler = @@ -118,21 +115,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("jobs", "automated") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - .let { JobAutomatedListPageAsync.of(this, params, it) } - } + .let { JobAutomatedListPageAsync.of(this, params, it) } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncImpl.kt index 381fa46a..bc85ac72 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncImpl.kt @@ -10,13 +10,14 @@ import com.tryfinch.api.core.handlers.withErrorHandler import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.JobManualRetrieveParams import com.tryfinch.api.models.ManualAsyncJob import java.util.concurrent.CompletableFuture class ManualServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ManualServiceAsync { @@ -37,20 +38,18 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("jobs", "manual", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsyncImpl.kt index 21d27e59..a62ed715 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsyncImpl.kt @@ -10,6 +10,7 @@ import com.tryfinch.api.core.handlers.withErrorHandler import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.PayGroupListResponse import com.tryfinch.api.models.PayGroupRetrieveResponse @@ -19,7 +20,7 @@ import com.tryfinch.api.models.PayrollPayGroupRetrieveParams import java.util.concurrent.CompletableFuture class PayGroupServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : PayGroupServiceAsync { @@ -38,21 +39,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "pay-groups", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val listHandler: Handler> = @@ -68,22 +67,25 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "pay-groups") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } + } } - } - .let { PayrollPayGroupListPageAsync.Response.Builder().items(it).build() } - .let { PayrollPayGroupListPageAsync.of(this, params, it) } - } + .let { + PayrollPayGroupListPageAsync.of( + this, + params, + PayrollPayGroupListPageAsync.Response.builder().items(it).build() + ) + } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncImpl.kt index 628b691e..f3a188cf 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncImpl.kt @@ -11,13 +11,14 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.CompanyUpdateResponse import com.tryfinch.api.models.SandboxCompanyUpdateParams import java.util.concurrent.CompletableFuture class CompanyServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : CompanyServiceAsync { @@ -35,21 +36,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("sandbox", "company") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncImpl.kt index df722b81..f3fbb40c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.ConnectionCreateResponse import com.tryfinch.api.models.SandboxConnectionCreateParams @@ -19,7 +20,7 @@ import com.tryfinch.api.services.async.sandbox.connections.AccountServiceAsyncIm import java.util.concurrent.CompletableFuture class ConnectionServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ConnectionServiceAsync { @@ -42,21 +43,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("sandbox", "connections") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncImpl.kt index 488215cd..a85a58fc 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncImpl.kt @@ -12,12 +12,13 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.SandboxDirectoryCreateParams import java.util.concurrent.CompletableFuture class DirectoryServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : DirectoryServiceAsync { @@ -35,15 +36,11 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("sandbox", "directory") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response.use { createHandler.handle(it) } - } + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> response.use { createHandler.handle(it) } } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncImpl.kt index 1fd0be2e..aa2c9d0b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncImpl.kt @@ -11,13 +11,14 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.EmploymentUpdateResponse import com.tryfinch.api.models.SandboxEmploymentUpdateParams import java.util.concurrent.CompletableFuture class EmploymentServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : EmploymentServiceAsync { @@ -36,21 +37,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("sandbox", "employment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncImpl.kt index c7381d5d..f01dc64f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncImpl.kt @@ -11,13 +11,14 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.IndividualUpdateResponse import com.tryfinch.api.models.SandboxIndividualUpdateParams import java.util.concurrent.CompletableFuture class IndividualServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : IndividualServiceAsync { @@ -36,21 +37,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("sandbox", "individual", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsyncImpl.kt index de27a873..ec086214 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.JobCreateResponse import com.tryfinch.api.models.SandboxJobCreateParams @@ -19,7 +20,7 @@ import com.tryfinch.api.services.async.sandbox.jobs.ConfigurationServiceAsyncImp import java.util.concurrent.CompletableFuture class JobServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : JobServiceAsync { @@ -43,21 +44,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("sandbox", "jobs") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncImpl.kt index 28499c98..6aa24d29 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncImpl.kt @@ -11,13 +11,14 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.PaymentCreateResponse import com.tryfinch.api.models.SandboxPaymentCreateParams import java.util.concurrent.CompletableFuture class PaymentServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : PaymentServiceAsync { @@ -35,21 +36,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("sandbox", "payment") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncImpl.kt index d392bb15..acaf2640 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.AccountCreateResponse import com.tryfinch.api.models.AccountUpdateResponse @@ -19,7 +20,7 @@ import com.tryfinch.api.models.SandboxConnectionAccountUpdateParams import java.util.concurrent.CompletableFuture class AccountServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AccountServiceAsync { @@ -37,22 +38,20 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("sandbox", "connections", "accounts") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } private val updateHandler: Handler = @@ -70,21 +69,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("sandbox", "connections", "accounts") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncImpl.kt index b7ea0c42..3929d315 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.SandboxJobConfiguration import com.tryfinch.api.models.SandboxJobConfigurationRetrieveParams @@ -18,7 +19,7 @@ import com.tryfinch.api.models.SandboxJobConfigurationUpdateParams import java.util.concurrent.CompletableFuture class ConfigurationServiceAsyncImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ConfigurationServiceAsync { @@ -37,21 +38,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("sandbox", "jobs", "configuration") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } + } } - } - } + } } private val updateHandler: Handler = @@ -67,21 +66,19 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("sandbox", "jobs", "configuration") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + .prepareAsync(clientOptions, params) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() + } } - } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceImpl.kt index ffe8cd3b..00fb601b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceImpl.kt @@ -11,13 +11,14 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.errors.FinchException import com.tryfinch.api.models.AccessTokenCreateParams import com.tryfinch.api.models.CreateAccessTokenResponse class AccessTokenServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AccessTokenService { @@ -59,19 +60,19 @@ constructor( .method(HttpMethod.POST) .addPathSegments("auth", "token") .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) + .replaceAllQueryParams(params._queryParams()) .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, modifiedParams.getBody())) + .putAllHeaders(params._headers()) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt index 0229ef6f..a636d599 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.AccountDisconnectParams import com.tryfinch.api.models.AccountIntrospectParams @@ -18,7 +19,7 @@ import com.tryfinch.api.models.DisconnectResponse import com.tryfinch.api.models.Introspection class AccountServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AccountService { @@ -36,21 +37,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("disconnect") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { disconnectHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { disconnectHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val introspectHandler: Handler = @@ -65,19 +62,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("introspect") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { introspectHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { introspectHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectServiceImpl.kt index 6a051d58..33ad8280 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectServiceImpl.kt @@ -7,7 +7,7 @@ import com.tryfinch.api.services.blocking.connect.SessionService import com.tryfinch.api.services.blocking.connect.SessionServiceImpl class ConnectServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ConnectService { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisServiceImpl.kt index 16a39aa7..7815bd7c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisServiceImpl.kt @@ -21,7 +21,7 @@ import com.tryfinch.api.services.blocking.hris.PaymentService import com.tryfinch.api.services.blocking.hris.PaymentServiceImpl class HrisServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : HrisService { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobServiceImpl.kt index 706b94d5..e66f9efc 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobServiceImpl.kt @@ -9,7 +9,7 @@ import com.tryfinch.api.services.blocking.jobs.ManualService import com.tryfinch.api.services.blocking.jobs.ManualServiceImpl class JobServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : JobService { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollServiceImpl.kt index 1d99c82a..574b007b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollServiceImpl.kt @@ -7,7 +7,7 @@ import com.tryfinch.api.services.blocking.payroll.PayGroupService import com.tryfinch.api.services.blocking.payroll.PayGroupServiceImpl class PayrollServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : PayrollService { 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 9e98c4df..e27d7069 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 @@ -10,13 +10,14 @@ import com.tryfinch.api.core.handlers.withErrorHandler import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.Provider import com.tryfinch.api.models.ProviderListPage import com.tryfinch.api.models.ProviderListParams class ProviderServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ProviderService { @@ -34,21 +35,22 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("providers") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } } - .let { ProviderListPage.Response.Builder().items(it).build() } - .let { ProviderListPage.of(this, params, it) } - } + } + .let { + ProviderListPage.of( + this, + params, + ProviderListPage.Response.builder().items(it).build() + ) + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceImpl.kt index 4bb0d8ee..7b041fc3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceImpl.kt @@ -11,12 +11,13 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.RequestForwardingForwardParams import com.tryfinch.api.models.RequestForwardingForwardResponse class RequestForwardingServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : RequestForwardingService { @@ -39,20 +40,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("forward") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { forwardHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { forwardHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxServiceImpl.kt index 5a919bfb..e93cb9d6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxServiceImpl.kt @@ -19,7 +19,7 @@ import com.tryfinch.api.services.blocking.sandbox.PaymentService import com.tryfinch.api.services.blocking.sandbox.PaymentServiceImpl class SandboxServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : SandboxService { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookServiceImpl.kt index 0f688adc..0330cb2e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookServiceImpl.kt @@ -19,7 +19,7 @@ import javax.crypto.Mac import javax.crypto.spec.SecretKeySpec class WebhookServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : WebhookService { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceImpl.kt index 19f293c2..5bd2beaf 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.ConnectSessionNewParams import com.tryfinch.api.models.ConnectSessionReauthenticateParams @@ -18,7 +19,7 @@ import com.tryfinch.api.models.SessionNewResponse import com.tryfinch.api.models.SessionReauthenticateResponse class SessionServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : SessionService { @@ -36,21 +37,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("connect", "sessions") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { newHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { newHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val reauthenticateHandler: Handler = @@ -66,20 +63,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("connect", "sessions", "reauthenticate") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { reauthenticateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { reauthenticateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt index 41949c15..2cd734de 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.CompanyBenefit import com.tryfinch.api.models.CreateCompanyBenefitsResponse @@ -27,7 +28,7 @@ import com.tryfinch.api.services.blocking.hris.benefits.IndividualService import com.tryfinch.api.services.blocking.hris.benefits.IndividualServiceImpl class BenefitServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : BenefitService { @@ -53,21 +54,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("employer", "benefits") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -82,20 +79,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "benefits", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -111,21 +104,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("employer", "benefits", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler> = @@ -140,22 +129,23 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "benefits") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } } - .let { HrisBenefitListPage.Response.Builder().items(it).build() } - .let { HrisBenefitListPage.of(this, params, it) } - } + } + .let { + HrisBenefitListPage.of( + this, + params, + HrisBenefitListPage.Response.builder().items(it).build() + ) + } } private val listSupportedBenefitsHandler: Handler> = @@ -170,21 +160,22 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "benefits", "meta") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listSupportedBenefitsHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listSupportedBenefitsHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } } - .let { HrisBenefitListSupportedBenefitsPage.Response.Builder().items(it).build() } - .let { HrisBenefitListSupportedBenefitsPage.of(this, params, it) } - } + } + .let { + HrisBenefitListSupportedBenefitsPage.of( + this, + params, + HrisBenefitListSupportedBenefitsPage.Response.builder().items(it).build() + ) + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyServiceImpl.kt index ce9b30a3..46b695b3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyServiceImpl.kt @@ -10,12 +10,13 @@ import com.tryfinch.api.core.handlers.withErrorHandler import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.Company import com.tryfinch.api.models.HrisCompanyRetrieveParams class CompanyServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : CompanyService { @@ -33,19 +34,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "company") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryService.kt index 6add41c8..8c8e64c0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryService.kt @@ -20,8 +20,8 @@ interface DirectoryService { ): HrisDirectoryListPage /** Read company directory and organization structure */ - @JvmOverloads @Deprecated("use `list` instead") + @JvmOverloads fun listIndividuals( params: HrisDirectoryListIndividualsParams, requestOptions: RequestOptions = RequestOptions.none() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceImpl.kt index e4a941b0..5d98caa5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceImpl.kt @@ -10,6 +10,7 @@ import com.tryfinch.api.core.handlers.withErrorHandler import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.HrisDirectoryListIndividualsPage import com.tryfinch.api.models.HrisDirectoryListIndividualsParams @@ -17,7 +18,7 @@ import com.tryfinch.api.models.HrisDirectoryListPage import com.tryfinch.api.models.HrisDirectoryListParams class DirectoryServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : DirectoryService { @@ -36,21 +37,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "directory") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { HrisDirectoryListPage.of(this, params, it) } - } + } + .let { HrisDirectoryListPage.of(this, params, it) } } private val listIndividualsHandler: Handler = @@ -67,20 +64,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "directory") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listIndividualsHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listIndividualsHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { HrisDirectoryListIndividualsPage.of(this, params, it) } - } + } + .let { HrisDirectoryListIndividualsPage.of(this, params, it) } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceImpl.kt index 6a3f4cad..b823de32 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceImpl.kt @@ -10,6 +10,7 @@ import com.tryfinch.api.core.handlers.withErrorHandler import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.DocumentListResponse import com.tryfinch.api.models.DocumentRetreiveResponse @@ -17,7 +18,7 @@ import com.tryfinch.api.models.HrisDocumentListParams import com.tryfinch.api.models.HrisDocumentRetreiveParams class DocumentServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : DocumentService { @@ -37,20 +38,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "documents") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retreiveHandler: Handler = @@ -69,19 +66,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "documents", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retreiveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retreiveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentServiceImpl.kt index 293e707d..caa1ddb0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentServiceImpl.kt @@ -11,12 +11,13 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.HrisEmploymentRetrieveManyPage import com.tryfinch.api.models.HrisEmploymentRetrieveManyParams class EmploymentServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : EmploymentService { @@ -35,21 +36,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("employer", "employment") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveManyHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveManyHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { HrisEmploymentRetrieveManyPage.of(this, params, it) } - } + } + .let { HrisEmploymentRetrieveManyPage.of(this, params, it) } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualServiceImpl.kt index 9d97bf6b..1c6acb60 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualServiceImpl.kt @@ -11,12 +11,13 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.HrisIndividualRetrieveManyPage import com.tryfinch.api.models.HrisIndividualRetrieveManyParams class IndividualServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : IndividualService { @@ -35,21 +36,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("employer", "individual") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveManyHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveManyHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { HrisIndividualRetrieveManyPage.of(this, params, it) } - } + } + .let { HrisIndividualRetrieveManyPage.of(this, params, it) } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementServiceImpl.kt index 7233afb4..38bd156c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementServiceImpl.kt @@ -11,12 +11,13 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.HrisPayStatementRetrieveManyPage import com.tryfinch.api.models.HrisPayStatementRetrieveManyParams class PayStatementServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : PayStatementService { @@ -39,21 +40,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("employer", "pay-statement") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveManyHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveManyHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { HrisPayStatementRetrieveManyPage.of(this, params, it) } - } + } + .let { HrisPayStatementRetrieveManyPage.of(this, params, it) } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentServiceImpl.kt index c4899295..4f20d692 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentServiceImpl.kt @@ -10,13 +10,14 @@ import com.tryfinch.api.core.handlers.withErrorHandler import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.HrisPaymentListPage import com.tryfinch.api.models.HrisPaymentListParams import com.tryfinch.api.models.Payment class PaymentServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : PaymentService { @@ -34,21 +35,22 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "payment") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } } - .let { HrisPaymentListPage.Response.Builder().items(it).build() } - .let { HrisPaymentListPage.of(this, params, it) } - } + } + .let { + HrisPaymentListPage.of( + this, + params, + HrisPaymentListPage.Response.builder().items(it).build() + ) + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt index 66665585..2de79b77 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsPage @@ -22,7 +23,7 @@ import com.tryfinch.api.models.IndividualEnrolledIdsResponse import com.tryfinch.api.models.UnenrolledIndividual class IndividualServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : IndividualService { @@ -41,20 +42,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "benefits", params.getPathParam(0), "enrolled") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { enrolledIdsHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { enrolledIdsHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveManyBenefitsHandler: Handler> = @@ -70,26 +67,25 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "benefits", params.getPathParam(0), "individuals") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveManyBenefitsHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveManyBenefitsHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } } - .let { - HrisBenefitIndividualRetrieveManyBenefitsPage.Response.Builder() + } + .let { + HrisBenefitIndividualRetrieveManyBenefitsPage.of( + this, + params, + HrisBenefitIndividualRetrieveManyBenefitsPage.Response.builder() .items(it) .build() - } - .let { HrisBenefitIndividualRetrieveManyBenefitsPage.of(this, params, it) } - } + ) + } } private val unenrollManyHandler: Handler> = @@ -105,22 +101,23 @@ constructor( HttpRequest.builder() .method(HttpMethod.DELETE) .addPathSegments("employer", "benefits", params.getPathParam(0), "individuals") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { unenrollManyHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { unenrollManyHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } } - .let { HrisBenefitIndividualUnenrollManyPage.Response.Builder().items(it).build() } - .let { HrisBenefitIndividualUnenrollManyPage.of(this, params, it) } - } + } + .let { + HrisBenefitIndividualUnenrollManyPage.of( + this, + params, + HrisBenefitIndividualUnenrollManyPage.Response.builder().items(it).build() + ) + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceImpl.kt index 0fd1aecc..ac866243 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.AutomatedAsyncJob import com.tryfinch.api.models.AutomatedCreateResponse @@ -20,7 +21,7 @@ import com.tryfinch.api.models.JobAutomatedListParams import com.tryfinch.api.models.JobAutomatedRetrieveParams class AutomatedServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AutomatedService { @@ -53,21 +54,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("jobs", "automated") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val retrieveHandler: Handler = @@ -82,20 +79,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("jobs", "automated", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler = @@ -115,20 +108,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("jobs", "automated") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - .let { JobAutomatedListPage.of(this, params, it) } - } + } + .let { JobAutomatedListPage.of(this, params, it) } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceImpl.kt index 7c128717..27291f16 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceImpl.kt @@ -10,12 +10,13 @@ import com.tryfinch.api.core.handlers.withErrorHandler import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.JobManualRetrieveParams import com.tryfinch.api.models.ManualAsyncJob class ManualServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ManualService { @@ -36,19 +37,15 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("jobs", "manual", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupServiceImpl.kt index 43fca99c..6a494736 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupServiceImpl.kt @@ -10,6 +10,7 @@ import com.tryfinch.api.core.handlers.withErrorHandler import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.PayGroupListResponse import com.tryfinch.api.models.PayGroupRetrieveResponse @@ -18,7 +19,7 @@ import com.tryfinch.api.models.PayrollPayGroupListParams import com.tryfinch.api.models.PayrollPayGroupRetrieveParams class PayGroupServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : PayGroupService { @@ -37,20 +38,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "pay-groups", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val listHandler: Handler> = @@ -66,21 +63,22 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("employer", "pay-groups") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } } - .let { PayrollPayGroupListPage.Response.Builder().items(it).build() } - .let { PayrollPayGroupListPage.of(this, params, it) } - } + } + .let { + PayrollPayGroupListPage.of( + this, + params, + PayrollPayGroupListPage.Response.builder().items(it).build() + ) + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceImpl.kt index a3e81c36..e2f62a1d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceImpl.kt @@ -11,12 +11,13 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.CompanyUpdateResponse import com.tryfinch.api.models.SandboxCompanyUpdateParams class CompanyServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : CompanyService { @@ -34,20 +35,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("sandbox", "company") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceImpl.kt index 88562d06..c0ce13ef 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.ConnectionCreateResponse import com.tryfinch.api.models.SandboxConnectionCreateParams @@ -18,7 +19,7 @@ import com.tryfinch.api.services.blocking.sandbox.connections.AccountService import com.tryfinch.api.services.blocking.sandbox.connections.AccountServiceImpl class ConnectionServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ConnectionService { @@ -41,20 +42,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("sandbox", "connections") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceImpl.kt index 233f06c0..1f992263 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceImpl.kt @@ -12,11 +12,12 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.SandboxDirectoryCreateParams class DirectoryServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : DirectoryService { @@ -34,14 +35,10 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("sandbox", "directory") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response.use { createHandler.handle(it) } - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.use { createHandler.handle(it) } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceImpl.kt index fa46cd45..742a804c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceImpl.kt @@ -11,12 +11,13 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.EmploymentUpdateResponse import com.tryfinch.api.models.SandboxEmploymentUpdateParams class EmploymentServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : EmploymentService { @@ -35,20 +36,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("sandbox", "employment", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceImpl.kt index e6bab225..3333a62a 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceImpl.kt @@ -11,12 +11,13 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.IndividualUpdateResponse import com.tryfinch.api.models.SandboxIndividualUpdateParams class IndividualServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : IndividualService { @@ -35,20 +36,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("sandbox", "individual", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobServiceImpl.kt index 0c90c100..589c02eb 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobServiceImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.JobCreateResponse import com.tryfinch.api.models.SandboxJobCreateParams @@ -18,7 +19,7 @@ import com.tryfinch.api.services.blocking.sandbox.jobs.ConfigurationService import com.tryfinch.api.services.blocking.sandbox.jobs.ConfigurationServiceImpl class JobServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : JobService { @@ -42,20 +43,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("sandbox", "jobs") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceImpl.kt index 69ca921f..d8e902a1 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceImpl.kt @@ -11,12 +11,13 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.PaymentCreateResponse import com.tryfinch.api.models.SandboxPaymentCreateParams class PaymentServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : PaymentService { @@ -34,20 +35,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("sandbox", "payment") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceImpl.kt index ef43cc7c..d42f5064 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceImpl.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.AccountCreateResponse import com.tryfinch.api.models.AccountUpdateResponse @@ -18,7 +19,7 @@ import com.tryfinch.api.models.SandboxConnectionAccountCreateParams import com.tryfinch.api.models.SandboxConnectionAccountUpdateParams class AccountServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : AccountService { @@ -36,21 +37,17 @@ constructor( HttpRequest.builder() .method(HttpMethod.POST) .addPathSegments("sandbox", "connections", "accounts") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } private val updateHandler: Handler = @@ -68,20 +65,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("sandbox", "connections", "accounts") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceImpl.kt index 65c9d523..70a26346 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceImpl.kt @@ -11,13 +11,14 @@ import com.tryfinch.api.core.http.HttpMethod import com.tryfinch.api.core.http.HttpRequest import com.tryfinch.api.core.http.HttpResponse.Handler import com.tryfinch.api.core.json +import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchError import com.tryfinch.api.models.SandboxJobConfiguration import com.tryfinch.api.models.SandboxJobConfigurationRetrieveParams import com.tryfinch.api.models.SandboxJobConfigurationUpdateParams class ConfigurationServiceImpl -constructor( +internal constructor( private val clientOptions: ClientOptions, ) : ConfigurationService { @@ -36,20 +37,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.GET) .addPathSegments("sandbox", "jobs", "configuration") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - forEach { it.validate() } - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.forEach { it.validate() } } - } + } } private val updateHandler: Handler = @@ -65,20 +62,16 @@ constructor( HttpRequest.builder() .method(HttpMethod.PUT) .addPathSegments("sandbox", "jobs", "configuration") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) + .body(json(clientOptions.jsonMapper, params._body())) .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } + .prepare(clientOptions, params) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + it.validate() } - } + } } } 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 9b37a54f..40ab4321 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 @@ -5,38 +5,83 @@ import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo 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 java.io.InputStream +import java.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource @WireMockTest internal class RetryingHttpClientTest { + private var openResponseCount = 0 private lateinit var httpClient: HttpClient @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - httpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + val okHttpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + httpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions + ): HttpResponse = trackClose(okHttpClient.execute(request, requestOptions)) + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions + ): CompletableFuture = + okHttpClient.executeAsync(request, requestOptions).thenApply { trackClose(it) } + + override fun close() = okHttpClient.close() + + private fun trackClose(response: HttpResponse): HttpResponse { + openResponseCount++ + return object : HttpResponse { + private var isClosed = false + + override fun statusCode(): Int = response.statusCode() + + override fun headers(): Headers = response.headers() + + override fun body(): InputStream = response.body() + + override fun close() { + response.close() + if (isClosed) { + return + } + openResponseCount-- + isClosed = true + } + } + } + } resetAllScenarios() } - @Test - fun byDefaultShouldNotAddIdempotencyHeaderToRequest() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute(async: Boolean) { stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).build() - val response = retryingClient.execute(request) + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async + ) + assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } - @Test - fun whenProvidedShouldAddIdempotencyHeaderToRequest() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withIdempotencyHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) @@ -45,21 +90,28 @@ internal class RetryingHttpClientTest { val retryingClient = RetryingHttpClient.builder() .httpClient(httpClient) + .maxRetries(2) .idempotencyHeader("X-Some-Header") .build() - val response = retryingClient.execute(request) + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async + ) + assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) - fun retryAfterHeader(async: Boolean) { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + fun execute_withRetryAfterHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // first we fail with a retry after header given as a date + // First we fail with a retry after header given as a date + .inScenario("foo") .whenScenarioStateIs(Scenario.STARTED) .willReturn( serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") @@ -68,14 +120,16 @@ internal class RetryingHttpClientTest { ) stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // then we fail with a retry after header given as a delay + // Then we fail with a retry after header given as a delay + .inScenario("foo") .whenScenarioStateIs("RETRY_AFTER_DATE") .willReturn(serviceUnavailable().withHeader("Retry-After", "1.234")) .willSetStateTo("RETRY_AFTER_DELAY") ) stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // then we return a success + // Then we return a success + .inScenario("foo") .whenScenarioStateIs("RETRY_AFTER_DELAY") .willReturn(ok()) .willSetStateTo("COMPLETED") @@ -84,8 +138,10 @@ internal class RetryingHttpClientTest { RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() val response = - if (async) retryingClient.executeAsync(request).get() - else retryingClient.execute(request) + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async + ) assertThat(response.statusCode()).isEqualTo(200) verify( @@ -103,17 +159,12 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("2")) ) + assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) - fun overwriteRetryCountHeader(async: Boolean) { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegment("something") - .putHeader("x-stainless-retry-count", "42") - .build() + fun execute_withOverwrittenRetryCountHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") // first we fail with a retry after header given as a date @@ -134,8 +185,14 @@ internal class RetryingHttpClientTest { RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() val response = - if (async) retryingClient.executeAsync(request).get() - else retryingClient.execute(request) + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegment("something") + .putHeader("x-stainless-retry-count", "42") + .build(), + async + ) assertThat(response.statusCode()).isEqualTo(200) verify( @@ -143,12 +200,12 @@ internal class RetryingHttpClientTest { postRequestedFor(urlPathEqualTo("/something")) .withHeader("x-stainless-retry-count", equalTo("42")) ) + assertNoResponseLeaks() } - @Test - fun retryAfterMsHeader() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") @@ -165,8 +222,22 @@ internal class RetryingHttpClientTest { ) val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).maxRetries(1).build() - val response = retryingClient.execute(request) + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async + ) + assertThat(response.statusCode()).isEqualTo(200) verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } + + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = + if (async) executeAsync(request).get() else execute(request) + + // When retrying, all failed responses should be closed. Only the final returned response should + // be open. + private fun assertNoResponseLeaks() = assertThat(openResponseCount).isEqualTo(1) } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/core/http/SerializerTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/core/http/SerializerTest.kt index 129648eb..59d8dece 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/core/http/SerializerTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/core/http/SerializerTest.kt @@ -65,7 +65,8 @@ internal class SerializerTest { } @NoAutoDetect - class Builder { + class Builder internal constructor() { + private var isActive: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() 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 e4779e68..a95c01db 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 @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class AccessTokenCreateParamsTest { @Test - fun createAccessTokenCreateParams() { + fun create() { AccessTokenCreateParams.builder() .code("") .clientId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -18,7 +18,7 @@ class AccessTokenCreateParamsTest { } @Test - fun getBody() { + fun body() { val params = AccessTokenCreateParams.builder() .code("") @@ -26,7 +26,7 @@ class AccessTokenCreateParamsTest { .clientSecret("") .redirectUri("https://example.com") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.code()).isEqualTo("") assertThat(body.clientId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -35,9 +35,9 @@ class AccessTokenCreateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = AccessTokenCreateParams.builder().code("").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.code()).isEqualTo("") } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountCreateResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountCreateResponseTest.kt index e650a68d..77ad0cd6 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountCreateResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountCreateResponseTest.kt @@ -16,7 +16,7 @@ class AccountCreateResponseTest { .authenticationType(AccountCreateResponse.AuthenticationType.CREDENTIAL) .companyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .connectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .products(listOf("string")) + .addProduct("string") .providerId("provider_id") .build() assertThat(accountCreateResponse).isNotNull diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountDisconnectParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountDisconnectParamsTest.kt index 03b7bffb..939d87df 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountDisconnectParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountDisconnectParamsTest.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test class AccountDisconnectParamsTest { @Test - fun createAccountDisconnectParams() { + fun create() { AccountDisconnectParams.builder().build() } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountIntrospectParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountIntrospectParamsTest.kt index c886e760..df68f2aa 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountIntrospectParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountIntrospectParamsTest.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test class AccountIntrospectParamsTest { @Test - fun createAccountIntrospectParams() { + fun create() { AccountIntrospectParams.builder().build() } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountUpdateResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountUpdateResponseTest.kt index 69375e43..822eb797 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountUpdateResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountUpdateResponseTest.kt @@ -14,7 +14,7 @@ class AccountUpdateResponseTest { .accountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .authenticationType(AccountUpdateResponse.AuthenticationType.CREDENTIAL) .companyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .products(listOf("string")) + .addProduct("string") .providerId("provider_id") .connectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AutomatedAsyncJobTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AutomatedAsyncJobTest.kt index 7393f7a9..4b581077 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AutomatedAsyncJobTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AutomatedAsyncJobTest.kt @@ -16,6 +16,7 @@ class AutomatedAsyncJobTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .jobUrl("job_url") + .params(AutomatedAsyncJob.Params.builder().individualId("individual_id").build()) .scheduledAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .status(AutomatedAsyncJob.Status.PENDING) @@ -28,6 +29,8 @@ class AutomatedAsyncJobTest { .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(automatedAsyncJob.jobId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(automatedAsyncJob.jobUrl()).isEqualTo("job_url") + assertThat(automatedAsyncJob.params()) + .contains(AutomatedAsyncJob.Params.builder().individualId("individual_id").build()) assertThat(automatedAsyncJob.scheduledAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(automatedAsyncJob.startedAt()) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperationsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperationsTest.kt index 5e6dbb7f..c9ceed88 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperationsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperationsTest.kt @@ -15,24 +15,17 @@ class BenefitFeaturesAndOperationsTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution.FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -63,21 +56,16 @@ class BenefitFeaturesAndOperationsTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution.FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution.FIXED ) .description("description") - .employeeDeduction( - listOf(BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit.INDIVIDUAL ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitsSupportTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitsSupportTest.kt index c9651d4f..1d3cc3cb 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitsSupportTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitsSupportTest.kt @@ -17,28 +17,19 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -70,28 +61,19 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -123,28 +105,19 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -176,28 +149,19 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -229,28 +193,19 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -282,28 +237,19 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -335,28 +281,19 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -388,28 +325,19 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -441,28 +369,19 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -494,28 +413,19 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -547,28 +457,19 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -600,28 +501,19 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -656,25 +548,18 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -707,25 +592,18 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -758,25 +636,18 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -809,25 +680,18 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -860,25 +724,18 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -911,25 +768,18 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -962,25 +812,18 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1013,25 +856,18 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1064,25 +900,18 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1115,25 +944,18 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1166,25 +988,18 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1217,25 +1032,18 @@ class BenefitsSupportTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit + .INDIVIDUAL ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyTest.kt index cde80a41..4ca6ddb3 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyTest.kt @@ -12,24 +12,20 @@ class CompanyTest { val company = Company.builder() .id("id") - .accounts( - listOf( - Company.Account.builder() - .accountName("account_name") - .accountNumber("account_number") - .accountType(Company.Account.AccountType.CHECKING) - .institutionName("institution_name") - .routingNumber("routing_number") - .build() - ) + .addAccount( + Company.Account.builder() + .accountName("account_name") + .accountNumber("account_number") + .accountType(Company.Account.AccountType.CHECKING) + .institutionName("institution_name") + .routingNumber("routing_number") + .build() ) - .departments( - listOf( - Company.Department.builder() - .name("name") - .parent(Company.Department.Parent.builder().name("name").build()) - .build() - ) + .addDepartment( + Company.Department.builder() + .name("name") + .parent(Company.Department.Parent.builder().name("name").build()) + .build() ) .ein("ein") .entity( @@ -39,19 +35,17 @@ class CompanyTest { .build() ) .legalName("legal_name") - .locations( - listOf( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .name("name") - .postalCode("postal_code") - .sourceId("source_id") - .state("state") - .build() - ) + .addLocation( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() ) .primaryEmail("primary_email") .primaryPhoneNumber("primary_phone_number") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyUpdateResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyUpdateResponseTest.kt index 832816a2..c08e1171 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyUpdateResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyUpdateResponseTest.kt @@ -11,28 +11,22 @@ class CompanyUpdateResponseTest { fun createCompanyUpdateResponse() { val companyUpdateResponse = CompanyUpdateResponse.builder() - .accounts( - listOf( - CompanyUpdateResponse.Account.builder() - .accountName("account_name") - .accountNumber("account_number") - .accountType(CompanyUpdateResponse.Account.AccountType.CHECKING) - .institutionName("institution_name") - .routingNumber("routing_number") - .build() - ) + .addAccount( + CompanyUpdateResponse.Account.builder() + .accountName("account_name") + .accountNumber("account_number") + .accountType(CompanyUpdateResponse.Account.AccountType.CHECKING) + .institutionName("institution_name") + .routingNumber("routing_number") + .build() ) - .departments( - listOf( - CompanyUpdateResponse.Department.builder() - .name("name") - .parent( - CompanyUpdateResponse.Department.Parent.builder() - .name("name") - .build() - ) - .build() - ) + .addDepartment( + CompanyUpdateResponse.Department.builder() + .name("name") + .parent( + CompanyUpdateResponse.Department.Parent.builder().name("name").build() + ) + .build() ) .ein("ein") .entity( @@ -42,19 +36,17 @@ class CompanyUpdateResponseTest { .build() ) .legalName("legal_name") - .locations( - listOf( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .name("name") - .postalCode("postal_code") - .sourceId("source_id") - .state("state") - .build() - ) + .addLocation( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() ) .primaryEmail("primary_email") .primaryPhoneNumber("primary_phone_number") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ConnectSessionNewParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ConnectSessionNewParamsTest.kt index 0710ca50..fa0cbf4b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ConnectSessionNewParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ConnectSessionNewParamsTest.kt @@ -8,11 +8,11 @@ import org.junit.jupiter.api.Test class ConnectSessionNewParamsTest { @Test - fun createConnectSessionNewParams() { + fun create() { ConnectSessionNewParams.builder() .customerId("x") .customerName("x") - .products(listOf(ConnectSessionNewParams.ConnectProducts.COMPANY)) + .addProduct(ConnectSessionNewParams.ConnectProducts.COMPANY) .customerEmail("dev@stainlessapi.com") .integration( ConnectSessionNewParams.Integration.builder() @@ -28,12 +28,12 @@ class ConnectSessionNewParamsTest { } @Test - fun getBody() { + fun body() { val params = ConnectSessionNewParams.builder() .customerId("x") .customerName("x") - .products(listOf(ConnectSessionNewParams.ConnectProducts.COMPANY)) + .addProduct(ConnectSessionNewParams.ConnectProducts.COMPANY) .customerEmail("dev@stainlessapi.com") .integration( ConnectSessionNewParams.Integration.builder() @@ -46,7 +46,7 @@ class ConnectSessionNewParamsTest { .redirectUri("redirect_uri") .sandbox(ConnectSessionNewParams.Sandbox.FINCH) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.customerId()).isEqualTo("x") assertThat(body.customerName()).isEqualTo("x") @@ -67,14 +67,14 @@ class ConnectSessionNewParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ConnectSessionNewParams.builder() .customerId("x") .customerName("x") - .products(listOf(ConnectSessionNewParams.ConnectProducts.COMPANY)) + .addProduct(ConnectSessionNewParams.ConnectProducts.COMPANY) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.customerId()).isEqualTo("x") assertThat(body.customerName()).isEqualTo("x") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ConnectSessionReauthenticateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ConnectSessionReauthenticateParamsTest.kt index 8bcdce50..8e65bd3a 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ConnectSessionReauthenticateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ConnectSessionReauthenticateParamsTest.kt @@ -8,25 +8,25 @@ import org.junit.jupiter.api.Test class ConnectSessionReauthenticateParamsTest { @Test - fun createConnectSessionReauthenticateParams() { + fun create() { ConnectSessionReauthenticateParams.builder() .connectionId("connection_id") .minutesToExpire(0L) - .products(listOf(ConnectSessionReauthenticateParams.ConnectProducts.COMPANY)) + .addProduct(ConnectSessionReauthenticateParams.ConnectProducts.COMPANY) .redirectUri("https://example.com") .build() } @Test - fun getBody() { + fun body() { val params = ConnectSessionReauthenticateParams.builder() .connectionId("connection_id") .minutesToExpire(0L) - .products(listOf(ConnectSessionReauthenticateParams.ConnectProducts.COMPANY)) + .addProduct(ConnectSessionReauthenticateParams.ConnectProducts.COMPANY) .redirectUri("https://example.com") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.connectionId()).isEqualTo("connection_id") assertThat(body.minutesToExpire()).contains(0L) @@ -36,10 +36,10 @@ class ConnectSessionReauthenticateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = ConnectSessionReauthenticateParams.builder().connectionId("connection_id").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.connectionId()).isEqualTo("connection_id") } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ConnectionCreateResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ConnectionCreateResponseTest.kt index 887d1fc3..742816d8 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ConnectionCreateResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ConnectionCreateResponseTest.kt @@ -16,7 +16,7 @@ class ConnectionCreateResponseTest { .authenticationType(ConnectionCreateResponse.AuthenticationType.CREDENTIAL) .companyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .connectionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .products(listOf("string")) + .addProduct("string") .providerId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .tokenType("token_type") .build() 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 6ad1c497..86c7535f 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 @@ -17,7 +17,7 @@ class CreateAccessTokenResponseTest { .companyId("company_id") .connectionId("connection_id") .connectionType(CreateAccessTokenResponse.ConnectionType.PROVIDER) - .products(listOf("string")) + .addProduct("string") .providerId("provider_id") .customerId("customer_id") .tokenType("token_type") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DocumentListResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DocumentListResponseTest.kt index 2804ce70..ace92517 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DocumentListResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/DocumentListResponseTest.kt @@ -11,16 +11,14 @@ class DocumentListResponseTest { fun createDocumentListResponse() { val documentListResponse = DocumentListResponse.builder() - .documents( - listOf( - DocumentResponse.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .individualId("individual_id") - .type(DocumentResponse.Type.W4_2020) - .url("https://example.com") - .year(0.0) - .build() - ) + .addDocument( + DocumentResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .individualId("individual_id") + .type(DocumentResponse.Type.W4_2020) + .url("https://example.com") + .year(0.0) + .build() ) .paging(Paging.builder().count(0L).offset(0L).build()) .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt index b09c2cae..e35bbacf 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt @@ -16,13 +16,11 @@ class EmploymentDataResponseTest { EmploymentData.builder() .id("id") .classCode("class_code") - .customFields( - listOf( - EmploymentData.CustomField.builder() - .name("name") - .value(JsonValue.from(mapOf())) - .build() - ) + .addCustomField( + EmploymentData.CustomField.builder() + .name("name") + .value(JsonValue.from(mapOf())) + .build() ) .department(EmploymentData.Department.builder().name("name").build()) .employment( @@ -42,15 +40,13 @@ class EmploymentDataResponseTest { .unit(Income.Unit.YEARLY) .build() ) - .incomeHistory( - listOf( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() ) .isActive(true) .lastName("last_name") @@ -84,13 +80,11 @@ class EmploymentDataResponseTest { EmploymentData.builder() .id("id") .classCode("class_code") - .customFields( - listOf( - EmploymentData.CustomField.builder() - .name("name") - .value(JsonValue.from(mapOf())) - .build() - ) + .addCustomField( + EmploymentData.CustomField.builder() + .name("name") + .value(JsonValue.from(mapOf())) + .build() ) .department(EmploymentData.Department.builder().name("name").build()) .employment( @@ -110,15 +104,13 @@ class EmploymentDataResponseTest { .unit(Income.Unit.YEARLY) .build() ) - .incomeHistory( - listOf( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() ) .isActive(true) .lastName("last_name") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt index e941eb13..2eea0b0b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt @@ -14,13 +14,11 @@ class EmploymentDataTest { EmploymentData.builder() .id("id") .classCode("class_code") - .customFields( - listOf( - EmploymentData.CustomField.builder() - .name("name") - .value(JsonValue.from(mapOf())) - .build() - ) + .addCustomField( + EmploymentData.CustomField.builder() + .name("name") + .value(JsonValue.from(mapOf())) + .build() ) .department(EmploymentData.Department.builder().name("name").build()) .employment( @@ -40,15 +38,13 @@ class EmploymentDataTest { .unit(Income.Unit.YEARLY) .build() ) - .incomeHistory( - listOf( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() ) .isActive(true) .lastName("last_name") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentUpdateResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentUpdateResponseTest.kt index 0c0a48d3..282c47ae 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentUpdateResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentUpdateResponseTest.kt @@ -14,13 +14,11 @@ class EmploymentUpdateResponseTest { EmploymentUpdateResponse.builder() .id("id") .classCode("class_code") - .customFields( - listOf( - EmploymentUpdateResponse.CustomField.builder() - .name("name") - .value(JsonValue.from(mapOf())) - .build() - ) + .addCustomField( + EmploymentUpdateResponse.CustomField.builder() + .name("name") + .value(JsonValue.from(mapOf())) + .build() ) .department(EmploymentUpdateResponse.Department.builder().name("name").build()) .employment( @@ -40,15 +38,13 @@ class EmploymentUpdateResponseTest { .unit(Income.Unit.YEARLY) .build() ) - .incomeHistory( - listOf( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() ) .isActive(true) .lastName("last_name") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitCreateParamsTest.kt index 342c46e5..f2041397 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitCreateParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class HrisBenefitCreateParamsTest { @Test - fun createHrisBenefitCreateParams() { + fun create() { HrisBenefitCreateParams.builder() .description("description") .frequency(BenefitFrequency.ONE_TIME) @@ -17,14 +17,14 @@ class HrisBenefitCreateParamsTest { } @Test - fun getBody() { + fun body() { val params = HrisBenefitCreateParams.builder() .description("description") .frequency(BenefitFrequency.ONE_TIME) .type(BenefitType._401K) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.description()).contains("description") assertThat(body.frequency()).contains(BenefitFrequency.ONE_TIME) @@ -32,9 +32,9 @@ class HrisBenefitCreateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = HrisBenefitCreateParams.builder().build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualEnrolledIdsParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualEnrolledIdsParamsTest.kt index a1e82c83..de75d8dc 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualEnrolledIdsParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualEnrolledIdsParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class HrisBenefitIndividualEnrolledIdsParamsTest { @Test - fun createHrisBenefitIndividualEnrolledIdsParams() { + fun create() { HrisBenefitIndividualEnrolledIdsParams.builder().benefitId("benefit_id").build() } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsParamsTest.kt index a49f8c39..926ce855 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsParamsTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test class HrisBenefitIndividualRetrieveManyBenefitsParamsTest { @Test - fun createHrisBenefitIndividualRetrieveManyBenefitsParams() { + fun create() { HrisBenefitIndividualRetrieveManyBenefitsParams.builder() .benefitId("benefit_id") .individualIds( @@ -19,7 +19,7 @@ class HrisBenefitIndividualRetrieveManyBenefitsParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = HrisBenefitIndividualRetrieveManyBenefitsParams.builder() .benefitId("benefit_id") @@ -32,17 +32,17 @@ class HrisBenefitIndividualRetrieveManyBenefitsParamsTest { "individual_ids", "d675d2b7-6d7b-41a8-b2d3-001eb3fb88f6,d02a6346-1f08-4312-a064-49ff3cafaa7a" ) - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = HrisBenefitIndividualRetrieveManyBenefitsParams.builder() .benefitId("benefit_id") .build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyParamsTest.kt index 74ebc36e..4c52c39d 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyParamsTest.kt @@ -8,30 +8,30 @@ import org.junit.jupiter.api.Test class HrisBenefitIndividualUnenrollManyParamsTest { @Test - fun createHrisBenefitIndividualUnenrollManyParams() { + fun create() { HrisBenefitIndividualUnenrollManyParams.builder() .benefitId("benefit_id") - .individualIds(listOf("string")) + .addIndividualId("string") .build() } @Test - fun getBody() { + fun body() { val params = HrisBenefitIndividualUnenrollManyParams.builder() .benefitId("benefit_id") - .individualIds(listOf("string")) + .addIndividualId("string") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.individualIds()).contains(listOf("string")) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = HrisBenefitIndividualUnenrollManyParams.builder().benefitId("benefit_id").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitListParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitListParamsTest.kt index ed540958..587d8917 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitListParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitListParamsTest.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test class HrisBenefitListParamsTest { @Test - fun createHrisBenefitListParams() { + fun create() { HrisBenefitListParams.builder().build() } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsParamsTest.kt index 4f8d686e..5aaf456f 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsParamsTest.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test class HrisBenefitListSupportedBenefitsParamsTest { @Test - fun createHrisBenefitListSupportedBenefitsParams() { + fun create() { HrisBenefitListSupportedBenefitsParams.builder().build() } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitRetrieveParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitRetrieveParamsTest.kt index 44a855b3..ca7ecf00 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitRetrieveParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitRetrieveParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class HrisBenefitRetrieveParamsTest { @Test - fun createHrisBenefitRetrieveParams() { + fun create() { HrisBenefitRetrieveParams.builder().benefitId("benefit_id").build() } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitUpdateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitUpdateParamsTest.kt index cc9b6ab7..f4adeb22 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitUpdateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitUpdateParamsTest.kt @@ -8,26 +8,26 @@ import org.junit.jupiter.api.Test class HrisBenefitUpdateParamsTest { @Test - fun createHrisBenefitUpdateParams() { + fun create() { HrisBenefitUpdateParams.builder().benefitId("benefit_id").description("description").build() } @Test - fun getBody() { + fun body() { val params = HrisBenefitUpdateParams.builder() .benefitId("benefit_id") .description("description") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.description()).contains("description") } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = HrisBenefitUpdateParams.builder().benefitId("benefit_id").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyRetrieveParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyRetrieveParamsTest.kt index 5ee3d609..ba444bb0 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyRetrieveParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyRetrieveParamsTest.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test class HrisCompanyRetrieveParamsTest { @Test - fun createHrisCompanyRetrieveParams() { + fun create() { HrisCompanyRetrieveParams.builder().build() } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsParamsTest.kt index 1b52e5af..42efb8a4 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsParamsTest.kt @@ -9,23 +9,23 @@ import org.junit.jupiter.api.Test class HrisDirectoryListIndividualsParamsTest { @Test - fun createHrisDirectoryListIndividualsParams() { + fun create() { HrisDirectoryListIndividualsParams.builder().limit(0L).offset(0L).build() } @Test - fun getQueryParams() { + fun queryParams() { val params = HrisDirectoryListIndividualsParams.builder().limit(0L).offset(0L).build() val expected = QueryParams.builder() expected.put("limit", "0") expected.put("offset", "0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = HrisDirectoryListIndividualsParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListParamsTest.kt index bf7133bb..fdfd708a 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListParamsTest.kt @@ -9,23 +9,23 @@ import org.junit.jupiter.api.Test class HrisDirectoryListParamsTest { @Test - fun createHrisDirectoryListParams() { + fun create() { HrisDirectoryListParams.builder().limit(0L).offset(0L).build() } @Test - fun getQueryParams() { + fun queryParams() { val params = HrisDirectoryListParams.builder().limit(0L).offset(0L).build() val expected = QueryParams.builder() expected.put("limit", "0") expected.put("offset", "0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = HrisDirectoryListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDocumentListParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDocumentListParamsTest.kt index 5c413161..4b3093ef 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDocumentListParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDocumentListParamsTest.kt @@ -9,36 +9,36 @@ import org.junit.jupiter.api.Test class HrisDocumentListParamsTest { @Test - fun createHrisDocumentListParams() { + fun create() { HrisDocumentListParams.builder() - .individualIds(listOf("string")) + .addIndividualId("string") .limit(0L) .offset(0L) - .types(listOf(HrisDocumentListParams.Type.W4_2020)) + .addType(HrisDocumentListParams.Type.W4_2020) .build() } @Test - fun getQueryParams() { + fun queryParams() { val params = HrisDocumentListParams.builder() - .individualIds(listOf("string")) + .addIndividualId("string") .limit(0L) .offset(0L) - .types(listOf(HrisDocumentListParams.Type.W4_2020)) + .addType(HrisDocumentListParams.Type.W4_2020) .build() val expected = QueryParams.builder() expected.put("individual_ids[]", "string") expected.put("limit", "0") expected.put("offset", "0") expected.put("types[]", HrisDocumentListParams.Type.W4_2020.toString()) - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = HrisDocumentListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDocumentRetreiveParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDocumentRetreiveParamsTest.kt index a521478d..89a0e4c9 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDocumentRetreiveParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDocumentRetreiveParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class HrisDocumentRetreiveParamsTest { @Test - fun createHrisDocumentRetreiveParams() { + fun create() { HrisDocumentRetreiveParams.builder().documentId("document_id").build() } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyParamsTest.kt index f601384d..2f9ce6e5 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyParamsTest.kt @@ -8,31 +8,27 @@ import org.junit.jupiter.api.Test class HrisEmploymentRetrieveManyParamsTest { @Test - fun createHrisEmploymentRetrieveManyParams() { + fun create() { HrisEmploymentRetrieveManyParams.builder() - .requests( - listOf( - HrisEmploymentRetrieveManyParams.Request.builder() - .individualId("individual_id") - .build() - ) + .addRequest( + HrisEmploymentRetrieveManyParams.Request.builder() + .individualId("individual_id") + .build() ) .build() } @Test - fun getBody() { + fun body() { val params = HrisEmploymentRetrieveManyParams.builder() - .requests( - listOf( - HrisEmploymentRetrieveManyParams.Request.builder() - .individualId("individual_id") - .build() - ) + .addRequest( + HrisEmploymentRetrieveManyParams.Request.builder() + .individualId("individual_id") + .build() ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.requests()) .isEqualTo( @@ -45,18 +41,16 @@ class HrisEmploymentRetrieveManyParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = HrisEmploymentRetrieveManyParams.builder() - .requests( - listOf( - HrisEmploymentRetrieveManyParams.Request.builder() - .individualId("individual_id") - .build() - ) + .addRequest( + HrisEmploymentRetrieveManyParams.Request.builder() + .individualId("individual_id") + .build() ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.requests()) .isEqualTo( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyParamsTest.kt index 6cb7fdac..a3e690dd 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyParamsTest.kt @@ -8,43 +8,37 @@ import org.junit.jupiter.api.Test class HrisIndividualRetrieveManyParamsTest { @Test - fun createHrisIndividualRetrieveManyParams() { + fun create() { HrisIndividualRetrieveManyParams.builder() .options( - HrisIndividualRetrieveManyParams.Options.builder().include(listOf("string")).build() + HrisIndividualRetrieveManyParams.Options.builder().addInclude("string").build() ) - .requests( - listOf( - HrisIndividualRetrieveManyParams.Request.builder() - .individualId("individual_id") - .build() - ) + .addRequest( + HrisIndividualRetrieveManyParams.Request.builder() + .individualId("individual_id") + .build() ) .build() } @Test - fun getBody() { + fun body() { val params = HrisIndividualRetrieveManyParams.builder() .options( - HrisIndividualRetrieveManyParams.Options.builder() - .include(listOf("string")) - .build() + HrisIndividualRetrieveManyParams.Options.builder().addInclude("string").build() ) - .requests( - listOf( - HrisIndividualRetrieveManyParams.Request.builder() - .individualId("individual_id") - .build() - ) + .addRequest( + HrisIndividualRetrieveManyParams.Request.builder() + .individualId("individual_id") + .build() ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.options()) .contains( - HrisIndividualRetrieveManyParams.Options.builder().include(listOf("string")).build() + HrisIndividualRetrieveManyParams.Options.builder().addInclude("string").build() ) assertThat(body.requests()) .contains( @@ -57,9 +51,9 @@ class HrisIndividualRetrieveManyParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = HrisIndividualRetrieveManyParams.builder().build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyParamsTest.kt index af667e5b..350813e1 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyParamsTest.kt @@ -8,35 +8,31 @@ import org.junit.jupiter.api.Test class HrisPayStatementRetrieveManyParamsTest { @Test - fun createHrisPayStatementRetrieveManyParams() { + fun create() { HrisPayStatementRetrieveManyParams.builder() - .requests( - listOf( - HrisPayStatementRetrieveManyParams.Request.builder() - .paymentId("string") - .limit(50L) - .offset(0L) - .build() - ) + .addRequest( + HrisPayStatementRetrieveManyParams.Request.builder() + .paymentId("string") + .limit(50L) + .offset(0L) + .build() ) .build() } @Test - fun getBody() { + fun body() { val params = HrisPayStatementRetrieveManyParams.builder() - .requests( - listOf( - HrisPayStatementRetrieveManyParams.Request.builder() - .paymentId("string") - .limit(50L) - .offset(0L) - .build() - ) + .addRequest( + HrisPayStatementRetrieveManyParams.Request.builder() + .paymentId("string") + .limit(50L) + .offset(0L) + .build() ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.requests()) .isEqualTo( @@ -51,18 +47,14 @@ class HrisPayStatementRetrieveManyParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = HrisPayStatementRetrieveManyParams.builder() - .requests( - listOf( - HrisPayStatementRetrieveManyParams.Request.builder() - .paymentId("string") - .build() - ) + .addRequest( + HrisPayStatementRetrieveManyParams.Request.builder().paymentId("string").build() ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.requests()) .isEqualTo( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPaymentListParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPaymentListParamsTest.kt index ba8f5d39..573bdb2c 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPaymentListParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPaymentListParamsTest.kt @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test class HrisPaymentListParamsTest { @Test - fun createHrisPaymentListParams() { + fun create() { HrisPaymentListParams.builder() .endDate(LocalDate.parse("2021-01-01")) .startDate(LocalDate.parse("2021-01-01")) @@ -18,7 +18,7 @@ class HrisPaymentListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = HrisPaymentListParams.builder() .endDate(LocalDate.parse("2021-01-01")) @@ -27,11 +27,11 @@ class HrisPaymentListParamsTest { val expected = QueryParams.builder() expected.put("end_date", "2021-01-01") expected.put("start_date", "2021-01-01") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = HrisPaymentListParams.builder() .endDate(LocalDate.parse("2021-01-01")) @@ -40,6 +40,6 @@ class HrisPaymentListParamsTest { val expected = QueryParams.builder() expected.put("end_date", "2021-01-01") expected.put("start_date", "2021-01-01") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualEnrolledIdsResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualEnrolledIdsResponseTest.kt index 0f9fd0d1..02aedfcf 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualEnrolledIdsResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualEnrolledIdsResponseTest.kt @@ -12,7 +12,7 @@ class IndividualEnrolledIdsResponseTest { val individualEnrolledIdsResponse = IndividualEnrolledIdsResponse.builder() .benefitId("benefit_id") - .individualIds(listOf("string")) + .addIndividualId("string") .build() assertThat(individualEnrolledIdsResponse).isNotNull assertThat(individualEnrolledIdsResponse.benefitId()).isEqualTo("benefit_id") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt index e8514a24..a2663ff8 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualResponseTest.kt @@ -15,13 +15,11 @@ class IndividualResponseTest { Individual.builder() .id("id") .dob("dob") - .emails( - listOf( - Individual.Email.builder() - .data("data") - .type(Individual.Email.Type.WORK) - .build() - ) + .addEmail( + Individual.Email.builder() + .data("data") + .type(Individual.Email.Type.WORK) + .build() ) .encryptedSsn("encrypted_ssn") .ethnicity(Individual.Ethnicity.ASIAN) @@ -29,13 +27,11 @@ class IndividualResponseTest { .gender(Individual.Gender.FEMALE) .lastName("last_name") .middleName("middle_name") - .phoneNumbers( - listOf( - Individual.PhoneNumber.builder() - .data("data") - .type(Individual.PhoneNumber.Type.WORK) - .build() - ) + .addPhoneNumber( + Individual.PhoneNumber.builder() + .data("data") + .type(Individual.PhoneNumber.Type.WORK) + .build() ) .preferredName("preferred_name") .residence( @@ -62,13 +58,11 @@ class IndividualResponseTest { Individual.builder() .id("id") .dob("dob") - .emails( - listOf( - Individual.Email.builder() - .data("data") - .type(Individual.Email.Type.WORK) - .build() - ) + .addEmail( + Individual.Email.builder() + .data("data") + .type(Individual.Email.Type.WORK) + .build() ) .encryptedSsn("encrypted_ssn") .ethnicity(Individual.Ethnicity.ASIAN) @@ -76,13 +70,11 @@ class IndividualResponseTest { .gender(Individual.Gender.FEMALE) .lastName("last_name") .middleName("middle_name") - .phoneNumbers( - listOf( - Individual.PhoneNumber.builder() - .data("data") - .type(Individual.PhoneNumber.Type.WORK) - .build() - ) + .addPhoneNumber( + Individual.PhoneNumber.builder() + .data("data") + .type(Individual.PhoneNumber.Type.WORK) + .build() ) .preferredName("preferred_name") .residence( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt index 0dae2405..80107aeb 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualTest.kt @@ -13,13 +13,8 @@ class IndividualTest { Individual.builder() .id("id") .dob("dob") - .emails( - listOf( - Individual.Email.builder() - .data("data") - .type(Individual.Email.Type.WORK) - .build() - ) + .addEmail( + Individual.Email.builder().data("data").type(Individual.Email.Type.WORK).build() ) .encryptedSsn("encrypted_ssn") .ethnicity(Individual.Ethnicity.ASIAN) @@ -27,13 +22,11 @@ class IndividualTest { .gender(Individual.Gender.FEMALE) .lastName("last_name") .middleName("middle_name") - .phoneNumbers( - listOf( - Individual.PhoneNumber.builder() - .data("data") - .type(Individual.PhoneNumber.Type.WORK) - .build() - ) + .addPhoneNumber( + Individual.PhoneNumber.builder() + .data("data") + .type(Individual.PhoneNumber.Type.WORK) + .build() ) .preferredName("preferred_name") .residence( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUpdateResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUpdateResponseTest.kt index 3527cf91..20525b44 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUpdateResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUpdateResponseTest.kt @@ -13,13 +13,11 @@ class IndividualUpdateResponseTest { IndividualUpdateResponse.builder() .id("id") .dob("dob") - .emails( - listOf( - IndividualUpdateResponse.Email.builder() - .data("data") - .type(IndividualUpdateResponse.Email.Type.WORK) - .build() - ) + .addEmail( + IndividualUpdateResponse.Email.builder() + .data("data") + .type(IndividualUpdateResponse.Email.Type.WORK) + .build() ) .encryptedSsn("encrypted_ssn") .ethnicity(IndividualUpdateResponse.Ethnicity.ASIAN) @@ -27,13 +25,11 @@ class IndividualUpdateResponseTest { .gender(IndividualUpdateResponse.Gender.FEMALE) .lastName("last_name") .middleName("middle_name") - .phoneNumbers( - listOf( - IndividualUpdateResponse.PhoneNumber.builder() - .data("data") - .type(IndividualUpdateResponse.PhoneNumber.Type.WORK) - .build() - ) + .addPhoneNumber( + IndividualUpdateResponse.PhoneNumber.builder() + .data("data") + .type(IndividualUpdateResponse.PhoneNumber.Type.WORK) + .build() ) .preferredName("preferred_name") .residence( 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 94d1b0fd..573f19a4 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 @@ -12,19 +12,17 @@ class IntrospectionTest { val introspection = Introspection.builder() .accountId("account_id") - .authenticationMethods( - listOf( - Introspection.AuthenticationMethod.builder() - .connectionStatus( - Introspection.AuthenticationMethod.ConnectionStatus.builder() - .message("message") - .status(ConnectionStatusType.PENDING) - .build() - ) - .products(listOf("string")) - .type(Introspection.AuthenticationMethod.Type.ASSISTED) - .build() - ) + .addAuthenticationMethod( + Introspection.AuthenticationMethod.builder() + .connectionStatus( + Introspection.AuthenticationMethod.ConnectionStatus.builder() + .message("message") + .status(ConnectionStatusType.PENDING) + .build() + ) + .addProduct("string") + .type(Introspection.AuthenticationMethod.Type.ASSISTED) + .build() ) .clientId("client_id") .clientType(Introspection.ClientType.PRODUCTION) @@ -42,7 +40,7 @@ class IntrospectionTest { .customerName("customer_name") .manual(true) .payrollProviderId("payroll_provider_id") - .products(listOf("string")) + .addProduct("string") .providerId("provider_id") .username("username") .build() @@ -57,7 +55,7 @@ class IntrospectionTest { .status(ConnectionStatusType.PENDING) .build() ) - .products(listOf("string")) + .addProduct("string") .type(Introspection.AuthenticationMethod.Type.ASSISTED) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedCreateParamsTest.kt index d481de8a..38a4981e 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/JobAutomatedCreateParamsTest.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test class JobAutomatedCreateParamsTest { @Test - fun createJobAutomatedCreateParams() { + fun create() { JobAutomatedCreateParams.builder() .forDataSyncAll( JobAutomatedCreateParams.DataSyncAll.builder() 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 9716e659..7d8eb4e6 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 @@ -9,23 +9,23 @@ import org.junit.jupiter.api.Test class JobAutomatedListParamsTest { @Test - fun createJobAutomatedListParams() { + fun create() { JobAutomatedListParams.builder().limit(0L).offset(0L).build() } @Test - fun getQueryParams() { + fun queryParams() { val params = JobAutomatedListParams.builder().limit(0L).offset(0L).build() val expected = QueryParams.builder() expected.put("limit", "0") expected.put("offset", "0") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = JobAutomatedListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } 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 68d537ec..3aaceca0 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 @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class JobAutomatedRetrieveParamsTest { @Test - fun createJobAutomatedRetrieveParams() { + fun create() { JobAutomatedRetrieveParams.builder().jobId("job_id").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 e917ef1f..9ae5ed32 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 @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class JobManualRetrieveParamsTest { @Test - fun createJobManualRetrieveParams() { + fun create() { JobManualRetrieveParams.builder().jobId("job_id").build() } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ManualAsyncJobTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ManualAsyncJobTest.kt index 65c05386..198d409a 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ManualAsyncJobTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ManualAsyncJobTest.kt @@ -12,7 +12,7 @@ class ManualAsyncJobTest { fun createManualAsyncJob() { val manualAsyncJob = ManualAsyncJob.builder() - .body(listOf(JsonValue.from(mapOf()))) + .addBody(JsonValue.from(mapOf())) .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .status(ManualAsyncJob.Status.PENDING) .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayGroupListResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayGroupListResponseTest.kt index 3a826480..f3c2561b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayGroupListResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayGroupListResponseTest.kt @@ -13,7 +13,7 @@ class PayGroupListResponseTest { PayGroupListResponse.builder() .id("id") .name("name") - .payFrequencies(listOf(PayGroupListResponse.PayFrequency.ANNUALLY)) + .addPayFrequency(PayGroupListResponse.PayFrequency.ANNUALLY) .build() assertThat(payGroupListResponse).isNotNull assertThat(payGroupListResponse.id()).contains("id") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayGroupRetrieveResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayGroupRetrieveResponseTest.kt index 60e9aed7..21f2f7c9 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayGroupRetrieveResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayGroupRetrieveResponseTest.kt @@ -12,9 +12,9 @@ class PayGroupRetrieveResponseTest { val payGroupRetrieveResponse = PayGroupRetrieveResponse.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .individualIds(listOf("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")) + .addIndividualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") - .payFrequencies(listOf(PayGroupRetrieveResponse.PayFrequency.ANNUALLY)) + .addPayFrequency(PayGroupRetrieveResponse.PayFrequency.ANNUALLY) .build() assertThat(payGroupRetrieveResponse).isNotNull assertThat(payGroupRetrieveResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") 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 e4f2f3f5..f6bfeaa6 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 @@ -12,70 +12,9 @@ class PayStatementResponseBodyTest { val payStatementResponseBody = PayStatementResponseBody.builder() .paging(Paging.builder().count(0L).offset(0L).build()) - .payStatements( - listOf( - PayStatement.builder() - .earnings( - listOf( - PayStatement.Earning.builder() - .amount(0L) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .build() - ) - ) - .employeeDeductions( - listOf( - PayStatement.EmployeeDeduction.builder() - .amount(0L) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) - .build() - ) - ) - .employerContributions( - listOf( - PayStatement.EmployerContribution.builder() - .amount(0L) - .currency("currency") - .name("name") - .type(BenefitType._401K) - .build() - ) - ) - .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(PayStatement.PaymentMethod.CHECK) - .taxes( - listOf( - PayStatement.Tax.builder() - .amount(0L) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) - .build() - ) - ) - .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) - .build() - ) - ) - .build() - assertThat(payStatementResponseBody).isNotNull - assertThat(payStatementResponseBody.paging()) - .contains(Paging.builder().count(0L).offset(0L).build()) - assertThat(payStatementResponseBody.payStatements().get()) - .containsExactly( - PayStatement.builder() - .earnings( - listOf( + .addPayStatement( + PayStatement.builder() + .addEarning( PayStatement.Earning.builder() .amount(0L) .currency("currency") @@ -84,9 +23,7 @@ class PayStatementResponseBodyTest { .type(PayStatement.Earning.Type.SALARY) .build() ) - ) - .employeeDeductions( - listOf( + .addEmployeeDeduction( PayStatement.EmployeeDeduction.builder() .amount(0L) .currency("currency") @@ -95,9 +32,7 @@ class PayStatementResponseBodyTest { .type(BenefitType._401K) .build() ) - ) - .employerContributions( - listOf( + .addEmployerContribution( PayStatement.EmployerContribution.builder() .amount(0L) .currency("currency") @@ -105,13 +40,11 @@ class PayStatementResponseBodyTest { .type(BenefitType._401K) .build() ) - ) - .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(PayStatement.PaymentMethod.CHECK) - .taxes( - listOf( + .grossPay(Money.builder().amount(0L).currency("currency").build()) + .individualId("individual_id") + .netPay(Money.builder().amount(0L).currency("currency").build()) + .paymentMethod(PayStatement.PaymentMethod.CHECK) + .addTax( PayStatement.Tax.builder() .amount(0L) .currency("currency") @@ -120,6 +53,55 @@ class PayStatementResponseBodyTest { .type(PayStatement.Tax.Type.STATE) .build() ) + .totalHours(0.0) + .type(PayStatement.Type.REGULAR_PAYROLL) + .build() + ) + .build() + assertThat(payStatementResponseBody).isNotNull + assertThat(payStatementResponseBody.paging()) + .contains(Paging.builder().count(0L).offset(0L).build()) + assertThat(payStatementResponseBody.payStatements().get()) + .containsExactly( + PayStatement.builder() + .addEarning( + PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) + .build() + ) + .addEmployeeDeduction( + PayStatement.EmployeeDeduction.builder() + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._401K) + .build() + ) + .addEmployerContribution( + PayStatement.EmployerContribution.builder() + .amount(0L) + .currency("currency") + .name("name") + .type(BenefitType._401K) + .build() + ) + .grossPay(Money.builder().amount(0L).currency("currency").build()) + .individualId("individual_id") + .netPay(Money.builder().amount(0L).currency("currency").build()) + .paymentMethod(PayStatement.PaymentMethod.CHECK) + .addTax( + PayStatement.Tax.builder() + .amount(0L) + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) + .build() ) .totalHours(0.0) .type(PayStatement.Type.REGULAR_PAYROLL) 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 d86ad139..6b944e36 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 @@ -14,127 +14,105 @@ class PayStatementResponseTest { .body( PayStatementResponseBody.builder() .paging(Paging.builder().count(0L).offset(0L).build()) - .payStatements( - listOf( - PayStatement.builder() - .earnings( - listOf( - PayStatement.Earning.builder() - .amount(0L) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .build() - ) - ) - .employeeDeductions( - listOf( - PayStatement.EmployeeDeduction.builder() - .amount(0L) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) - .build() - ) - ) - .employerContributions( - listOf( - PayStatement.EmployerContribution.builder() - .amount(0L) - .currency("currency") - .name("name") - .type(BenefitType._401K) - .build() - ) - ) - .grossPay( - Money.builder().amount(0L).currency("currency").build() - ) - .individualId("individual_id") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(PayStatement.PaymentMethod.CHECK) - .taxes( - listOf( - PayStatement.Tax.builder() - .amount(0L) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) - .build() - ) - ) - .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) - .build() - ) - ) - .build() - ) - .code(0L) - .paymentId("payment_id") - .build() - assertThat(payStatementResponse).isNotNull - assertThat(payStatementResponse.body()) - .contains( - PayStatementResponseBody.builder() - .paging(Paging.builder().count(0L).offset(0L).build()) - .payStatements( - listOf( + .addPayStatement( PayStatement.builder() - .earnings( - listOf( - PayStatement.Earning.builder() - .amount(0L) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .build() - ) + .addEarning( + PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) + .build() ) - .employeeDeductions( - listOf( - PayStatement.EmployeeDeduction.builder() - .amount(0L) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) - .build() - ) + .addEmployeeDeduction( + PayStatement.EmployeeDeduction.builder() + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._401K) + .build() ) - .employerContributions( - listOf( - PayStatement.EmployerContribution.builder() - .amount(0L) - .currency("currency") - .name("name") - .type(BenefitType._401K) - .build() - ) + .addEmployerContribution( + PayStatement.EmployerContribution.builder() + .amount(0L) + .currency("currency") + .name("name") + .type(BenefitType._401K) + .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod(PayStatement.PaymentMethod.CHECK) - .taxes( - listOf( - PayStatement.Tax.builder() - .amount(0L) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) - .build() - ) + .addTax( + PayStatement.Tax.builder() + .amount(0L) + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) + .build() ) .totalHours(0.0) .type(PayStatement.Type.REGULAR_PAYROLL) .build() ) + .build() + ) + .code(0L) + .paymentId("payment_id") + .build() + assertThat(payStatementResponse).isNotNull + assertThat(payStatementResponse.body()) + .contains( + PayStatementResponseBody.builder() + .paging(Paging.builder().count(0L).offset(0L).build()) + .addPayStatement( + PayStatement.builder() + .addEarning( + PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) + .build() + ) + .addEmployeeDeduction( + PayStatement.EmployeeDeduction.builder() + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._401K) + .build() + ) + .addEmployerContribution( + PayStatement.EmployerContribution.builder() + .amount(0L) + .currency("currency") + .name("name") + .type(BenefitType._401K) + .build() + ) + .grossPay(Money.builder().amount(0L).currency("currency").build()) + .individualId("individual_id") + .netPay(Money.builder().amount(0L).currency("currency").build()) + .paymentMethod(PayStatement.PaymentMethod.CHECK) + .addTax( + PayStatement.Tax.builder() + .amount(0L) + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) + .build() + ) + .totalHours(0.0) + .type(PayStatement.Type.REGULAR_PAYROLL) + .build() ) .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 3432b7c7..f6a928ec 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 @@ -11,52 +11,44 @@ class PayStatementTest { fun createPayStatement() { val payStatement = PayStatement.builder() - .earnings( - listOf( - PayStatement.Earning.builder() - .amount(0L) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .build() - ) + .addEarning( + PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) + .build() ) - .employeeDeductions( - listOf( - PayStatement.EmployeeDeduction.builder() - .amount(0L) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) - .build() - ) + .addEmployeeDeduction( + PayStatement.EmployeeDeduction.builder() + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._401K) + .build() ) - .employerContributions( - listOf( - PayStatement.EmployerContribution.builder() - .amount(0L) - .currency("currency") - .name("name") - .type(BenefitType._401K) - .build() - ) + .addEmployerContribution( + PayStatement.EmployerContribution.builder() + .amount(0L) + .currency("currency") + .name("name") + .type(BenefitType._401K) + .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod(PayStatement.PaymentMethod.CHECK) - .taxes( - listOf( - PayStatement.Tax.builder() - .amount(0L) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) - .build() - ) + .addTax( + PayStatement.Tax.builder() + .amount(0L) + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) + .build() ) .totalHours(0.0) .type(PayStatement.Type.REGULAR_PAYROLL) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PaymentTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PaymentTest.kt index 8f12e7a9..42235e2a 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PaymentTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PaymentTest.kt @@ -17,11 +17,11 @@ class PaymentTest { .employeeTaxes(Money.builder().amount(0L).currency("currency").build()) .employerTaxes(Money.builder().amount(0L).currency("currency").build()) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualIds(listOf("string")) + .addIndividualId("string") .netPay(Money.builder().amount(0L).currency("currency").build()) .payDate("pay_date") - .payFrequencies(listOf(Payment.PayFrequency.ANNUALLY)) - .payGroupIds(listOf("string")) + .addPayFrequency(Payment.PayFrequency.ANNUALLY) + .addPayGroupId("string") .payPeriod( Payment.PayPeriod.builder().endDate("end_date").startDate("start_date").build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayrollPayGroupListParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayrollPayGroupListParamsTest.kt index 041f8109..45029bf7 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayrollPayGroupListParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayrollPayGroupListParamsTest.kt @@ -9,30 +9,30 @@ import org.junit.jupiter.api.Test class PayrollPayGroupListParamsTest { @Test - fun createPayrollPayGroupListParams() { + fun create() { PayrollPayGroupListParams.builder() .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .payFrequencies(listOf("string")) + .addPayFrequency("string") .build() } @Test - fun getQueryParams() { + fun queryParams() { val params = PayrollPayGroupListParams.builder() .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .payFrequencies(listOf("string")) + .addPayFrequency("string") .build() val expected = QueryParams.builder() expected.put("individual_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") expected.put("pay_frequencies[]", "string") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = PayrollPayGroupListParams.builder().build() val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + assertThat(params._queryParams()).isEqualTo(expected.build()) } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayrollPayGroupRetrieveParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayrollPayGroupRetrieveParamsTest.kt index 306dc8fc..657b7fd2 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayrollPayGroupRetrieveParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayrollPayGroupRetrieveParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class PayrollPayGroupRetrieveParamsTest { @Test - fun createPayrollPayGroupRetrieveParams() { + fun create() { PayrollPayGroupRetrieveParams.builder().payGroupId("pay_group_id").build() } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderListParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderListParamsTest.kt index 01b1f155..a3b71dac 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderListParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderListParamsTest.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test class ProviderListParamsTest { @Test - fun createProviderListParams() { + fun create() { ProviderListParams.builder().build() } } 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 56d8dcc5..e16e32ae 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 @@ -12,1035 +12,907 @@ class ProviderTest { val provider = Provider.builder() .id("id") - .authenticationMethods( - listOf( - Provider.AuthenticationMethod.builder() - .benefitsSupport( - BenefitsSupport.builder() - .commuter( - BenefitFeaturesAndOperations.builder() - .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() - .annualMaximum(true) - .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution - .FIXED - ) - ) - .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED - ) - ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) - ) - .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( - BenefitFeaturesAndOperations.BenefitFeature - .builder() - .annualMaximum(true) - .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution - .FIXED - ) - ) - .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED - ) - ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) - ) - .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( - BenefitFeaturesAndOperations.BenefitFeature - .builder() - .annualMaximum(true) - .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution - .FIXED - ) - ) - .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED - ) - ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) - ) - .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( - BenefitFeaturesAndOperations.BenefitFeature - .builder() - .annualMaximum(true) - .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution - .FIXED - ) - ) - .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED - ) - ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) - ) - .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( - BenefitFeaturesAndOperations.BenefitFeature - .builder() - .annualMaximum(true) - .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution - .FIXED - ) - ) - .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED - ) - ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) - ) - .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( - BenefitFeaturesAndOperations.BenefitFeature - .builder() - .annualMaximum(true) - .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution - .FIXED - ) - ) - .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED - ) - ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) - ) - .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( - BenefitFeaturesAndOperations.BenefitFeature - .builder() - .annualMaximum(true) - .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution - .FIXED - ) - ) - .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED - ) - ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) - ) - .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( - BenefitFeaturesAndOperations.BenefitFeature - .builder() - .annualMaximum(true) - .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution - .FIXED - ) - ) - .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED - ) - ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) - ) - .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( - BenefitFeaturesAndOperations.BenefitFeature - .builder() - .annualMaximum(true) - .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution - .FIXED - ) - ) - .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED - ) - ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) - ) - .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( - BenefitFeaturesAndOperations.BenefitFeature - .builder() - .annualMaximum(true) - .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution - .FIXED - ) - ) - .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED - ) - ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) - ) - .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( - BenefitFeaturesAndOperations.BenefitFeature - .builder() - .annualMaximum(true) - .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution - .FIXED - ) - ) - .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED - ) - ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) - ) - .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( - BenefitFeaturesAndOperations.BenefitFeature - .builder() - .annualMaximum(true) - .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution - .FIXED - ) - ) - .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED - ) - ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) - ) - .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() - ) - .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() - ) - .build() - ) - .type(Provider.AuthenticationMethod.Type.ASSISTED) - .build() - ) + .addAuthenticationMethod( + Provider.AuthenticationMethod.builder() + .benefitsSupport( + BenefitsSupport.builder() + .commuter( + BenefitFeaturesAndOperations.builder() + .supportedFeatures( + BenefitFeaturesAndOperations.BenefitFeature.builder() + .annualMaximum(true) + .catchUp(true) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED + ) + .description("description") + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED + ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL + ) + .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( + BenefitFeaturesAndOperations.BenefitFeature.builder() + .annualMaximum(true) + .catchUp(true) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED + ) + .description("description") + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED + ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL + ) + .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( + BenefitFeaturesAndOperations.BenefitFeature.builder() + .annualMaximum(true) + .catchUp(true) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED + ) + .description("description") + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED + ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL + ) + .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( + BenefitFeaturesAndOperations.BenefitFeature.builder() + .annualMaximum(true) + .catchUp(true) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED + ) + .description("description") + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED + ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL + ) + .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( + BenefitFeaturesAndOperations.BenefitFeature.builder() + .annualMaximum(true) + .catchUp(true) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED + ) + .description("description") + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED + ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL + ) + .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( + BenefitFeaturesAndOperations.BenefitFeature.builder() + .annualMaximum(true) + .catchUp(true) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED + ) + .description("description") + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED + ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL + ) + .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( + BenefitFeaturesAndOperations.BenefitFeature.builder() + .annualMaximum(true) + .catchUp(true) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED + ) + .description("description") + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED + ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL + ) + .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( + BenefitFeaturesAndOperations.BenefitFeature.builder() + .annualMaximum(true) + .catchUp(true) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED + ) + .description("description") + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED + ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL + ) + .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( + BenefitFeaturesAndOperations.BenefitFeature.builder() + .annualMaximum(true) + .catchUp(true) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED + ) + .description("description") + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED + ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL + ) + .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( + BenefitFeaturesAndOperations.BenefitFeature.builder() + .annualMaximum(true) + .catchUp(true) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED + ) + .description("description") + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED + ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL + ) + .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( + BenefitFeaturesAndOperations.BenefitFeature.builder() + .annualMaximum(true) + .catchUp(true) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED + ) + .description("description") + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED + ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL + ) + .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( + BenefitFeaturesAndOperations.BenefitFeature.builder() + .annualMaximum(true) + .catchUp(true) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED + ) + .description("description") + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED + ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL + ) + .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() + ) + .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() + ) + .build() + ) + .type(Provider.AuthenticationMethod.Type.ASSISTED) + .build() ) .beta(true) .displayName("display_name") @@ -1049,7 +921,7 @@ class ProviderTest { .manual(true) .mfaRequired(true) .primaryColor("primary_color") - .products(listOf("string")) + .addProduct("string") .build() assertThat(provider).isNotNull assertThat(provider.id()).contains("id") @@ -1064,28 +936,22 @@ class ProviderTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1117,28 +983,22 @@ class ProviderTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1170,28 +1030,22 @@ class ProviderTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1223,28 +1077,22 @@ class ProviderTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1276,28 +1124,22 @@ class ProviderTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1329,28 +1171,22 @@ class ProviderTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1382,28 +1218,22 @@ class ProviderTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1435,28 +1265,22 @@ class ProviderTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1488,28 +1312,22 @@ class ProviderTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1541,28 +1359,22 @@ class ProviderTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1594,28 +1406,22 @@ class ProviderTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL ) .build() ) @@ -1647,28 +1453,22 @@ class ProviderTest { BenefitFeaturesAndOperations.BenefitFeature.builder() .annualMaximum(true) .catchUp(true) - .companyContribution( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED - ) + .addCompanyContribution( + BenefitFeaturesAndOperations.BenefitFeature + .CompanyContribution + .FIXED ) .description("description") - .employeeDeduction( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction( + BenefitFeaturesAndOperations.BenefitFeature + .EmployeeDeduction + .FIXED ) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit( - listOf( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL - ) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit( + BenefitFeaturesAndOperations.BenefitFeature + .HsaContributionLimit + .INDIVIDUAL ) .build() ) 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 7cf03bd5..ed881128 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 @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test class RequestForwardingForwardParamsTest { @Test - fun createRequestForwardingForwardParams() { + fun create() { RequestForwardingForwardParams.builder() .method("POST") .route("/people/search") @@ -20,7 +20,7 @@ class RequestForwardingForwardParamsTest { } @Test - fun getBody() { + fun body() { val params = RequestForwardingForwardParams.builder() .method("POST") @@ -29,22 +29,22 @@ class RequestForwardingForwardParamsTest { .headers(JsonValue.from(mapOf("content-type" to "application/json"))) .params(JsonValue.from(mapOf("showInactive" to true, "humanReadable" to true))) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.method()).isEqualTo("POST") assertThat(body.route()).isEqualTo("/people/search") assertThat(body.data()).isEmpty - assertThat(body._headers()) + 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))) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = RequestForwardingForwardParams.builder().method("POST").route("/people/search").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.method()).isEqualTo("POST") assertThat(body.route()).isEqualTo("/people/search") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParamsTest.kt index 451fe763..81875a2c 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParamsTest.kt @@ -8,30 +8,24 @@ import org.junit.jupiter.api.Test class SandboxCompanyUpdateParamsTest { @Test - fun createSandboxCompanyUpdateParams() { + fun create() { SandboxCompanyUpdateParams.builder() - .accounts( - listOf( - SandboxCompanyUpdateParams.Account.builder() - .accountName("account_name") - .accountNumber("account_number") - .accountType(SandboxCompanyUpdateParams.Account.AccountType.CHECKING) - .institutionName("institution_name") - .routingNumber("routing_number") - .build() - ) + .addAccount( + SandboxCompanyUpdateParams.Account.builder() + .accountName("account_name") + .accountNumber("account_number") + .accountType(SandboxCompanyUpdateParams.Account.AccountType.CHECKING) + .institutionName("institution_name") + .routingNumber("routing_number") + .build() ) - .departments( - listOf( - SandboxCompanyUpdateParams.Department.builder() - .name("name") - .parent( - SandboxCompanyUpdateParams.Department.Parent.builder() - .name("name") - .build() - ) - .build() - ) + .addDepartment( + SandboxCompanyUpdateParams.Department.builder() + .name("name") + .parent( + SandboxCompanyUpdateParams.Department.Parent.builder().name("name").build() + ) + .build() ) .ein("ein") .entity( @@ -41,19 +35,17 @@ class SandboxCompanyUpdateParamsTest { .build() ) .legalName("legal_name") - .locations( - listOf( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .name("name") - .postalCode("postal_code") - .sourceId("source_id") - .state("state") - .build() - ) + .addLocation( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() ) .primaryEmail("primary_email") .primaryPhoneNumber("primary_phone_number") @@ -61,31 +53,27 @@ class SandboxCompanyUpdateParamsTest { } @Test - fun getBody() { + fun body() { val params = SandboxCompanyUpdateParams.builder() - .accounts( - listOf( - SandboxCompanyUpdateParams.Account.builder() - .accountName("account_name") - .accountNumber("account_number") - .accountType(SandboxCompanyUpdateParams.Account.AccountType.CHECKING) - .institutionName("institution_name") - .routingNumber("routing_number") - .build() - ) + .addAccount( + SandboxCompanyUpdateParams.Account.builder() + .accountName("account_name") + .accountNumber("account_number") + .accountType(SandboxCompanyUpdateParams.Account.AccountType.CHECKING) + .institutionName("institution_name") + .routingNumber("routing_number") + .build() ) - .departments( - listOf( - SandboxCompanyUpdateParams.Department.builder() - .name("name") - .parent( - SandboxCompanyUpdateParams.Department.Parent.builder() - .name("name") - .build() - ) - .build() - ) + .addDepartment( + SandboxCompanyUpdateParams.Department.builder() + .name("name") + .parent( + SandboxCompanyUpdateParams.Department.Parent.builder() + .name("name") + .build() + ) + .build() ) .ein("ein") .entity( @@ -95,24 +83,22 @@ class SandboxCompanyUpdateParamsTest { .build() ) .legalName("legal_name") - .locations( - listOf( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .name("name") - .postalCode("postal_code") - .sourceId("source_id") - .state("state") - .build() - ) + .addLocation( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() ) .primaryEmail("primary_email") .primaryPhoneNumber("primary_phone_number") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.accounts()) .contains( @@ -168,19 +154,19 @@ class SandboxCompanyUpdateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = SandboxCompanyUpdateParams.builder() - .accounts(listOf(SandboxCompanyUpdateParams.Account.builder().build())) - .departments(listOf(SandboxCompanyUpdateParams.Department.builder().build())) + .addAccount(SandboxCompanyUpdateParams.Account.builder().build()) + .addDepartment(SandboxCompanyUpdateParams.Department.builder().build()) .ein("ein") .entity(SandboxCompanyUpdateParams.Entity.builder().build()) .legalName("legal_name") - .locations(listOf(Location.builder().build())) + .addLocation(Location.builder().build()) .primaryEmail("primary_email") .primaryPhoneNumber("primary_phone_number") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.accounts()) .contains(listOf(SandboxCompanyUpdateParams.Account.builder().build())) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxConnectionAccountCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxConnectionAccountCreateParamsTest.kt index e3edeb1f..c45fc37e 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxConnectionAccountCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxConnectionAccountCreateParamsTest.kt @@ -8,17 +8,17 @@ import org.junit.jupiter.api.Test class SandboxConnectionAccountCreateParamsTest { @Test - fun createSandboxConnectionAccountCreateParams() { + fun create() { SandboxConnectionAccountCreateParams.builder() .companyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .providerId("provider_id") .authenticationType(SandboxConnectionAccountCreateParams.AuthenticationType.CREDENTIAL) - .products(listOf("string")) + .addProduct("string") .build() } @Test - fun getBody() { + fun body() { val params = SandboxConnectionAccountCreateParams.builder() .companyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -26,9 +26,9 @@ class SandboxConnectionAccountCreateParamsTest { .authenticationType( SandboxConnectionAccountCreateParams.AuthenticationType.CREDENTIAL ) - .products(listOf("string")) + .addProduct("string") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.companyId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.providerId()).isEqualTo("provider_id") @@ -38,13 +38,13 @@ class SandboxConnectionAccountCreateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = SandboxConnectionAccountCreateParams.builder() .companyId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .providerId("provider_id") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.companyId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.providerId()).isEqualTo("provider_id") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxConnectionAccountUpdateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxConnectionAccountUpdateParamsTest.kt index 1e5682f5..c1631000 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxConnectionAccountUpdateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxConnectionAccountUpdateParamsTest.kt @@ -8,27 +8,27 @@ import org.junit.jupiter.api.Test class SandboxConnectionAccountUpdateParamsTest { @Test - fun createSandboxConnectionAccountUpdateParams() { + fun create() { SandboxConnectionAccountUpdateParams.builder() .connectionStatus(ConnectionStatusType.PENDING) .build() } @Test - fun getBody() { + fun body() { val params = SandboxConnectionAccountUpdateParams.builder() .connectionStatus(ConnectionStatusType.PENDING) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.connectionStatus()).contains(ConnectionStatusType.PENDING) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = SandboxConnectionAccountUpdateParams.builder().build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxConnectionCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxConnectionCreateParamsTest.kt index b1ab1137..bee27d5e 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxConnectionCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxConnectionCreateParamsTest.kt @@ -8,25 +8,25 @@ import org.junit.jupiter.api.Test class SandboxConnectionCreateParamsTest { @Test - fun createSandboxConnectionCreateParams() { + fun create() { SandboxConnectionCreateParams.builder() .providerId("provider_id") .authenticationType(SandboxConnectionCreateParams.AuthenticationType.CREDENTIAL) .employeeSize(0L) - .products(listOf("string")) + .addProduct("string") .build() } @Test - fun getBody() { + fun body() { val params = SandboxConnectionCreateParams.builder() .providerId("provider_id") .authenticationType(SandboxConnectionCreateParams.AuthenticationType.CREDENTIAL) .employeeSize(0L) - .products(listOf("string")) + .addProduct("string") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.providerId()).isEqualTo("provider_id") assertThat(body.authenticationType()) @@ -36,9 +36,9 @@ class SandboxConnectionCreateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = SandboxConnectionCreateParams.builder().providerId("provider_id").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.providerId()).isEqualTo("provider_id") } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParamsTest.kt index 7097786b..fe0ec6a6 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParamsTest.kt @@ -9,20 +9,133 @@ import org.junit.jupiter.api.Test class SandboxDirectoryCreateParamsTest { @Test - fun createSandboxDirectoryCreateParams() { + fun create() { SandboxDirectoryCreateParams.builder() - .body( - listOf( + .addBody( + SandboxDirectoryCreateParams.IndividualOrEmployment.builder() + .classCode("class_code") + .addCustomField( + SandboxDirectoryCreateParams.IndividualOrEmployment.CustomField.builder() + .name("name") + .value(JsonValue.from(mapOf())) + .build() + ) + .department( + SandboxDirectoryCreateParams.IndividualOrEmployment.Department.builder() + .name("name") + .build() + ) + .dob("01/01/2000") + .addEmail( + SandboxDirectoryCreateParams.IndividualOrEmployment.Email.builder() + .data("data") + .type( + SandboxDirectoryCreateParams.IndividualOrEmployment.Email.Type.WORK + ) + .build() + ) + .employment( + SandboxDirectoryCreateParams.IndividualOrEmployment.Employment.builder() + .subtype( + SandboxDirectoryCreateParams.IndividualOrEmployment.Employment + .Subtype + .FULL_TIME + ) + .type( + SandboxDirectoryCreateParams.IndividualOrEmployment.Employment.Type + .EMPLOYEE + ) + .build() + ) + .employmentStatus( + SandboxDirectoryCreateParams.IndividualOrEmployment.EmploymentStatus.ACTIVE + ) + .encryptedSsn("encrypted_ssn") + .endDate("end_date") + .ethnicity(SandboxDirectoryCreateParams.IndividualOrEmployment.Ethnicity.ASIAN) + .firstName("John") + .gender(SandboxDirectoryCreateParams.IndividualOrEmployment.Gender.FEMALE) + .income( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .isActive(true) + .lastName("Smith") + .latestRehireDate("latest_rehire_date") + .location( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() + ) + .manager( + SandboxDirectoryCreateParams.IndividualOrEmployment.Manager.builder() + .id("id") + .build() + ) + .middleName("middle_name") + .addPhoneNumber( + SandboxDirectoryCreateParams.IndividualOrEmployment.PhoneNumber.builder() + .data("data") + .type( + SandboxDirectoryCreateParams.IndividualOrEmployment.PhoneNumber.Type + .WORK + ) + .build() + ) + .preferredName("preferred_name") + .residence( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() + ) + .sourceId("source_id") + .ssn("ssn") + .startDate("start_date") + .title("title") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + SandboxDirectoryCreateParams.builder() + .addBody( SandboxDirectoryCreateParams.IndividualOrEmployment.builder() .classCode("class_code") - .customFields( - listOf( - SandboxDirectoryCreateParams.IndividualOrEmployment.CustomField - .builder() - .name("name") - .value(JsonValue.from(mapOf())) - .build() - ) + .addCustomField( + SandboxDirectoryCreateParams.IndividualOrEmployment.CustomField + .builder() + .name("name") + .value(JsonValue.from(mapOf())) + .build() ) .department( SandboxDirectoryCreateParams.IndividualOrEmployment.Department.builder() @@ -30,17 +143,14 @@ class SandboxDirectoryCreateParamsTest { .build() ) .dob("01/01/2000") - .emails( - listOf( - SandboxDirectoryCreateParams.IndividualOrEmployment.Email.builder() - .data("data") - .type( - SandboxDirectoryCreateParams.IndividualOrEmployment.Email - .Type - .WORK - ) - .build() - ) + .addEmail( + SandboxDirectoryCreateParams.IndividualOrEmployment.Email.builder() + .data("data") + .type( + SandboxDirectoryCreateParams.IndividualOrEmployment.Email.Type + .WORK + ) + .build() ) .employment( SandboxDirectoryCreateParams.IndividualOrEmployment.Employment.builder() @@ -75,15 +185,13 @@ class SandboxDirectoryCreateParamsTest { .unit(Income.Unit.YEARLY) .build() ) - .incomeHistory( - listOf( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() ) .isActive(true) .lastName("Smith") @@ -106,19 +214,16 @@ class SandboxDirectoryCreateParamsTest { .build() ) .middleName("middle_name") - .phoneNumbers( - listOf( - SandboxDirectoryCreateParams.IndividualOrEmployment.PhoneNumber - .builder() - .data("data") - .type( - SandboxDirectoryCreateParams.IndividualOrEmployment - .PhoneNumber - .Type - .WORK - ) - .build() - ) + .addPhoneNumber( + SandboxDirectoryCreateParams.IndividualOrEmployment.PhoneNumber + .builder() + .data("data") + .type( + SandboxDirectoryCreateParams.IndividualOrEmployment.PhoneNumber + .Type + .WORK + ) + .build() ) .preferredName("preferred_name") .residence( @@ -139,168 +244,20 @@ class SandboxDirectoryCreateParamsTest { .title("title") .build() ) - ) - .build() - } - - @Test - fun getBody() { - val params = - SandboxDirectoryCreateParams.builder() - .body( - listOf( - SandboxDirectoryCreateParams.IndividualOrEmployment.builder() - .classCode("class_code") - .customFields( - listOf( - SandboxDirectoryCreateParams.IndividualOrEmployment.CustomField - .builder() - .name("name") - .value(JsonValue.from(mapOf())) - .build() - ) - ) - .department( - SandboxDirectoryCreateParams.IndividualOrEmployment.Department - .builder() - .name("name") - .build() - ) - .dob("01/01/2000") - .emails( - listOf( - SandboxDirectoryCreateParams.IndividualOrEmployment.Email - .builder() - .data("data") - .type( - SandboxDirectoryCreateParams.IndividualOrEmployment - .Email - .Type - .WORK - ) - .build() - ) - ) - .employment( - SandboxDirectoryCreateParams.IndividualOrEmployment.Employment - .builder() - .subtype( - SandboxDirectoryCreateParams.IndividualOrEmployment - .Employment - .Subtype - .FULL_TIME - ) - .type( - SandboxDirectoryCreateParams.IndividualOrEmployment - .Employment - .Type - .EMPLOYEE - ) - .build() - ) - .employmentStatus( - SandboxDirectoryCreateParams.IndividualOrEmployment.EmploymentStatus - .ACTIVE - ) - .encryptedSsn("encrypted_ssn") - .endDate("end_date") - .ethnicity( - SandboxDirectoryCreateParams.IndividualOrEmployment.Ethnicity.ASIAN - ) - .firstName("John") - .gender( - SandboxDirectoryCreateParams.IndividualOrEmployment.Gender.FEMALE - ) - .income( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) - .incomeHistory( - listOf( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) - ) - .isActive(true) - .lastName("Smith") - .latestRehireDate("latest_rehire_date") - .location( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .name("name") - .postalCode("postal_code") - .sourceId("source_id") - .state("state") - .build() - ) - .manager( - SandboxDirectoryCreateParams.IndividualOrEmployment.Manager - .builder() - .id("id") - .build() - ) - .middleName("middle_name") - .phoneNumbers( - listOf( - SandboxDirectoryCreateParams.IndividualOrEmployment.PhoneNumber - .builder() - .data("data") - .type( - SandboxDirectoryCreateParams.IndividualOrEmployment - .PhoneNumber - .Type - .WORK - ) - .build() - ) - ) - .preferredName("preferred_name") - .residence( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .name("name") - .postalCode("postal_code") - .sourceId("source_id") - .state("state") - .build() - ) - .sourceId("source_id") - .ssn("ssn") - .startDate("start_date") - .title("title") - .build() - ) - ) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body) .isEqualTo( listOf( SandboxDirectoryCreateParams.IndividualOrEmployment.builder() .classCode("class_code") - .customFields( - listOf( - SandboxDirectoryCreateParams.IndividualOrEmployment.CustomField - .builder() - .name("name") - .value(JsonValue.from(mapOf())) - .build() - ) + .addCustomField( + SandboxDirectoryCreateParams.IndividualOrEmployment.CustomField + .builder() + .name("name") + .value(JsonValue.from(mapOf())) + .build() ) .department( SandboxDirectoryCreateParams.IndividualOrEmployment.Department.builder() @@ -308,17 +265,14 @@ class SandboxDirectoryCreateParamsTest { .build() ) .dob("01/01/2000") - .emails( - listOf( - SandboxDirectoryCreateParams.IndividualOrEmployment.Email.builder() - .data("data") - .type( - SandboxDirectoryCreateParams.IndividualOrEmployment.Email - .Type - .WORK - ) - .build() - ) + .addEmail( + SandboxDirectoryCreateParams.IndividualOrEmployment.Email.builder() + .data("data") + .type( + SandboxDirectoryCreateParams.IndividualOrEmployment.Email.Type + .WORK + ) + .build() ) .employment( SandboxDirectoryCreateParams.IndividualOrEmployment.Employment.builder() @@ -353,15 +307,13 @@ class SandboxDirectoryCreateParamsTest { .unit(Income.Unit.YEARLY) .build() ) - .incomeHistory( - listOf( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() ) .isActive(true) .lastName("Smith") @@ -384,19 +336,16 @@ class SandboxDirectoryCreateParamsTest { .build() ) .middleName("middle_name") - .phoneNumbers( - listOf( - SandboxDirectoryCreateParams.IndividualOrEmployment.PhoneNumber - .builder() - .data("data") - .type( - SandboxDirectoryCreateParams.IndividualOrEmployment - .PhoneNumber - .Type - .WORK - ) - .build() - ) + .addPhoneNumber( + SandboxDirectoryCreateParams.IndividualOrEmployment.PhoneNumber + .builder() + .data("data") + .type( + SandboxDirectoryCreateParams.IndividualOrEmployment.PhoneNumber + .Type + .WORK + ) + .build() ) .preferredName("preferred_name") .residence( @@ -421,12 +370,12 @@ class SandboxDirectoryCreateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = SandboxDirectoryCreateParams.builder() - .body(listOf(SandboxDirectoryCreateParams.IndividualOrEmployment.builder().build())) + .addBody(SandboxDirectoryCreateParams.IndividualOrEmployment.builder().build()) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body) .isEqualTo( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParamsTest.kt index 92630138..1ea5c35c 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParamsTest.kt @@ -9,17 +9,15 @@ import org.junit.jupiter.api.Test class SandboxEmploymentUpdateParamsTest { @Test - fun createSandboxEmploymentUpdateParams() { + fun create() { SandboxEmploymentUpdateParams.builder() .individualId("individual_id") .classCode("class_code") - .customFields( - listOf( - SandboxEmploymentUpdateParams.CustomField.builder() - .name("name") - .value(JsonValue.from(mapOf())) - .build() - ) + .addCustomField( + SandboxEmploymentUpdateParams.CustomField.builder() + .name("name") + .value(JsonValue.from(mapOf())) + .build() ) .department(SandboxEmploymentUpdateParams.Department.builder().name("name").build()) .employment( @@ -39,15 +37,13 @@ class SandboxEmploymentUpdateParamsTest { .unit(Income.Unit.YEARLY) .build() ) - .incomeHistory( - listOf( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() ) .isActive(true) .lastName("last_name") @@ -73,18 +69,16 @@ class SandboxEmploymentUpdateParamsTest { } @Test - fun getBody() { + fun body() { val params = SandboxEmploymentUpdateParams.builder() .individualId("individual_id") .classCode("class_code") - .customFields( - listOf( - SandboxEmploymentUpdateParams.CustomField.builder() - .name("name") - .value(JsonValue.from(mapOf())) - .build() - ) + .addCustomField( + SandboxEmploymentUpdateParams.CustomField.builder() + .name("name") + .value(JsonValue.from(mapOf())) + .build() ) .department(SandboxEmploymentUpdateParams.Department.builder().name("name").build()) .employment( @@ -104,15 +98,13 @@ class SandboxEmploymentUpdateParamsTest { .unit(Income.Unit.YEARLY) .build() ) - .incomeHistory( - listOf( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() ) .isActive(true) .lastName("last_name") @@ -135,7 +127,7 @@ class SandboxEmploymentUpdateParamsTest { .startDate("3/4/2020") .title("title") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.classCode()).contains("class_code") assertThat(body.customFields()) @@ -205,9 +197,9 @@ class SandboxEmploymentUpdateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = SandboxEmploymentUpdateParams.builder().individualId("individual_id").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParamsTest.kt index 464cec4e..48d7af5d 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParamsTest.kt @@ -8,17 +8,15 @@ import org.junit.jupiter.api.Test class SandboxIndividualUpdateParamsTest { @Test - fun createSandboxIndividualUpdateParams() { + fun create() { SandboxIndividualUpdateParams.builder() .individualId("individual_id") .dob("12/20/1989") - .emails( - listOf( - SandboxIndividualUpdateParams.Email.builder() - .data("data") - .type(SandboxIndividualUpdateParams.Email.Type.WORK) - .build() - ) + .addEmail( + SandboxIndividualUpdateParams.Email.builder() + .data("data") + .type(SandboxIndividualUpdateParams.Email.Type.WORK) + .build() ) .encryptedSsn("encrypted_ssn") .ethnicity(SandboxIndividualUpdateParams.Ethnicity.ASIAN) @@ -26,13 +24,11 @@ class SandboxIndividualUpdateParamsTest { .gender(SandboxIndividualUpdateParams.Gender.FEMALE) .lastName("last_name") .middleName("middle_name") - .phoneNumbers( - listOf( - SandboxIndividualUpdateParams.PhoneNumber.builder() - .data("data") - .type(SandboxIndividualUpdateParams.PhoneNumber.Type.WORK) - .build() - ) + .addPhoneNumber( + SandboxIndividualUpdateParams.PhoneNumber.builder() + .data("data") + .type(SandboxIndividualUpdateParams.PhoneNumber.Type.WORK) + .build() ) .preferredName("preferred_name") .residence( @@ -52,18 +48,16 @@ class SandboxIndividualUpdateParamsTest { } @Test - fun getBody() { + fun body() { val params = SandboxIndividualUpdateParams.builder() .individualId("individual_id") .dob("12/20/1989") - .emails( - listOf( - SandboxIndividualUpdateParams.Email.builder() - .data("data") - .type(SandboxIndividualUpdateParams.Email.Type.WORK) - .build() - ) + .addEmail( + SandboxIndividualUpdateParams.Email.builder() + .data("data") + .type(SandboxIndividualUpdateParams.Email.Type.WORK) + .build() ) .encryptedSsn("encrypted_ssn") .ethnicity(SandboxIndividualUpdateParams.Ethnicity.ASIAN) @@ -71,13 +65,11 @@ class SandboxIndividualUpdateParamsTest { .gender(SandboxIndividualUpdateParams.Gender.FEMALE) .lastName("last_name") .middleName("middle_name") - .phoneNumbers( - listOf( - SandboxIndividualUpdateParams.PhoneNumber.builder() - .data("data") - .type(SandboxIndividualUpdateParams.PhoneNumber.Type.WORK) - .build() - ) + .addPhoneNumber( + SandboxIndividualUpdateParams.PhoneNumber.builder() + .data("data") + .type(SandboxIndividualUpdateParams.PhoneNumber.Type.WORK) + .build() ) .preferredName("preferred_name") .residence( @@ -94,7 +86,7 @@ class SandboxIndividualUpdateParamsTest { ) .ssn("ssn") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.dob()).contains("12/20/1989") assertThat(body.emails()) @@ -139,9 +131,9 @@ class SandboxIndividualUpdateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = SandboxIndividualUpdateParams.builder().individualId("individual_id").build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxJobConfigurationRetrieveParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxJobConfigurationRetrieveParamsTest.kt index fcb649d8..297979f1 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxJobConfigurationRetrieveParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxJobConfigurationRetrieveParamsTest.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test class SandboxJobConfigurationRetrieveParamsTest { @Test - fun createSandboxJobConfigurationRetrieveParams() { + fun create() { SandboxJobConfigurationRetrieveParams.builder().build() } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxJobConfigurationUpdateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxJobConfigurationUpdateParamsTest.kt index 0396c389..3c59ffb1 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxJobConfigurationUpdateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxJobConfigurationUpdateParamsTest.kt @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test class SandboxJobConfigurationUpdateParamsTest { @Test - fun createSandboxJobConfigurationUpdateParams() { + fun create() { SandboxJobConfigurationUpdateParams.builder() .completionStatus(SandboxJobConfigurationUpdateParams.CompletionStatus.COMPLETE) .type(SandboxJobConfigurationUpdateParams.Type.DATA_SYNC_ALL) @@ -16,13 +16,13 @@ class SandboxJobConfigurationUpdateParamsTest { } @Test - fun getBody() { + fun body() { val params = SandboxJobConfigurationUpdateParams.builder() .completionStatus(SandboxJobConfigurationUpdateParams.CompletionStatus.COMPLETE) .type(SandboxJobConfigurationUpdateParams.Type.DATA_SYNC_ALL) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.completionStatus()) .isEqualTo(SandboxJobConfigurationUpdateParams.CompletionStatus.COMPLETE) @@ -30,13 +30,13 @@ class SandboxJobConfigurationUpdateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = SandboxJobConfigurationUpdateParams.builder() .completionStatus(SandboxJobConfigurationUpdateParams.CompletionStatus.COMPLETE) .type(SandboxJobConfigurationUpdateParams.Type.DATA_SYNC_ALL) .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.completionStatus()) .isEqualTo(SandboxJobConfigurationUpdateParams.CompletionStatus.COMPLETE) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxJobCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxJobCreateParamsTest.kt index dadcf231..8ff44be2 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxJobCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxJobCreateParamsTest.kt @@ -8,24 +8,24 @@ import org.junit.jupiter.api.Test class SandboxJobCreateParamsTest { @Test - fun createSandboxJobCreateParams() { + fun create() { SandboxJobCreateParams.builder().type(SandboxJobCreateParams.Type.DATA_SYNC_ALL).build() } @Test - fun getBody() { + fun body() { val params = SandboxJobCreateParams.builder().type(SandboxJobCreateParams.Type.DATA_SYNC_ALL).build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.type()).isEqualTo(SandboxJobCreateParams.Type.DATA_SYNC_ALL) } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = SandboxJobCreateParams.builder().type(SandboxJobCreateParams.Type.DATA_SYNC_ALL).build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.type()).isEqualTo(SandboxJobCreateParams.Type.DATA_SYNC_ALL) } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt index 85c3dc8c..dbc9d664 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt @@ -8,198 +8,155 @@ import org.junit.jupiter.api.Test class SandboxPaymentCreateParamsTest { @Test - fun createSandboxPaymentCreateParams() { + fun create() { SandboxPaymentCreateParams.builder() .endDate("end_date") - .payStatements( - listOf( + .addPayStatement( + SandboxPaymentCreateParams.PayStatement.builder() + .addEarning( + SandboxPaymentCreateParams.PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) + .build() + ) + .addEmployeeDeduction( + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() + .amount(2000L) + .currency("usd") + .name("401k test") + .preTax(true) + .type(BenefitType._401K) + .build() + ) + .addEmployerContribution( + SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() + .amount(0L) + .currency("currency") + .name("name") + .type(BenefitType._401K) + .build() + ) + .grossPay(Money.builder().amount(0L).currency("currency").build()) + .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") + .netPay(Money.builder().amount(0L).currency("currency").build()) + .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) + .addTax( + SandboxPaymentCreateParams.PayStatement.Tax.builder() + .amount(0L) + .currency("currency") + .employer(true) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) + .build() + ) + .totalHours(0.0) + .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) + .build() + ) + .startDate("start_date") + .build() + } + + @Test + fun body() { + val params = + SandboxPaymentCreateParams.builder() + .endDate("end_date") + .addPayStatement( SandboxPaymentCreateParams.PayStatement.builder() - .earnings( - listOf( - SandboxPaymentCreateParams.PayStatement.Earning.builder() - .amount(0L) - .currency("currency") - .hours(0.0) - .name("name") - .type( - SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY - ) - .build() - ) + .addEarning( + SandboxPaymentCreateParams.PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) + .build() ) - .employeeDeductions( - listOf( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) - .currency("usd") - .name("401k test") - .preTax(true) - .type(BenefitType._401K) - .build() - ) + .addEmployeeDeduction( + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() + .amount(2000L) + .currency("usd") + .name("401k test") + .preTax(true) + .type(BenefitType._401K) + .build() ) - .employerContributions( - listOf( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .builder() - .amount(0L) - .currency("currency") - .name("name") - .type(BenefitType._401K) - .build() - ) + .addEmployerContribution( + SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() + .amount(0L) + .currency("currency") + .name("name") + .type(BenefitType._401K) + .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) - .taxes( - listOf( - SandboxPaymentCreateParams.PayStatement.Tax.builder() - .amount(0L) - .currency("currency") - .employer(true) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) - .build() - ) + .addTax( + SandboxPaymentCreateParams.PayStatement.Tax.builder() + .amount(0L) + .currency("currency") + .employer(true) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) + .build() ) .totalHours(0.0) .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) .build() ) - ) - .startDate("start_date") - .build() - } - - @Test - fun getBody() { - val params = - SandboxPaymentCreateParams.builder() - .endDate("end_date") - .payStatements( - listOf( - SandboxPaymentCreateParams.PayStatement.builder() - .earnings( - listOf( - SandboxPaymentCreateParams.PayStatement.Earning.builder() - .amount(0L) - .currency("currency") - .hours(0.0) - .name("name") - .type( - SandboxPaymentCreateParams.PayStatement.Earning.Type - .SALARY - ) - .build() - ) - ) - .employeeDeductions( - listOf( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction - .builder() - .amount(2000L) - .currency("usd") - .name("401k test") - .preTax(true) - .type(BenefitType._401K) - .build() - ) - ) - .employerContributions( - listOf( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .builder() - .amount(0L) - .currency("currency") - .name("name") - .type(BenefitType._401K) - .build() - ) - ) - .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod( - SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK - ) - .taxes( - listOf( - SandboxPaymentCreateParams.PayStatement.Tax.builder() - .amount(0L) - .currency("currency") - .employer(true) - .name("name") - .type( - SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE - ) - .build() - ) - ) - .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) - .build() - ) - ) .startDate("start_date") .build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull assertThat(body.endDate()).contains("end_date") assertThat(body.payStatements()) .contains( listOf( SandboxPaymentCreateParams.PayStatement.builder() - .earnings( - listOf( - SandboxPaymentCreateParams.PayStatement.Earning.builder() - .amount(0L) - .currency("currency") - .hours(0.0) - .name("name") - .type( - SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY - ) - .build() - ) + .addEarning( + SandboxPaymentCreateParams.PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) + .build() ) - .employeeDeductions( - listOf( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) - .currency("usd") - .name("401k test") - .preTax(true) - .type(BenefitType._401K) - .build() - ) + .addEmployeeDeduction( + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() + .amount(2000L) + .currency("usd") + .name("401k test") + .preTax(true) + .type(BenefitType._401K) + .build() ) - .employerContributions( - listOf( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .builder() - .amount(0L) - .currency("currency") - .name("name") - .type(BenefitType._401K) - .build() - ) + .addEmployerContribution( + SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() + .amount(0L) + .currency("currency") + .name("name") + .type(BenefitType._401K) + .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) - .taxes( - listOf( - SandboxPaymentCreateParams.PayStatement.Tax.builder() - .amount(0L) - .currency("currency") - .employer(true) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) - .build() - ) + .addTax( + SandboxPaymentCreateParams.PayStatement.Tax.builder() + .amount(0L) + .currency("currency") + .employer(true) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) + .build() ) .totalHours(0.0) .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) @@ -210,9 +167,9 @@ class SandboxPaymentCreateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = SandboxPaymentCreateParams.builder().build() - val body = params.getBody() + val body = params._body() assertThat(body).isNotNull } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SupportedBenefitTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SupportedBenefitTest.kt index 02a58a61..56ad5909 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SupportedBenefitTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SupportedBenefitTest.kt @@ -13,11 +13,11 @@ class SupportedBenefitTest { SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .companyContribution(listOf(SupportedBenefit.CompanyContribution.FIXED)) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .employeeDeduction(listOf(SupportedBenefit.EmployeeDeduction.FIXED)) - .frequencies(listOf(BenefitFrequency.ONE_TIME)) - .hsaContributionLimit(listOf(SupportedBenefit.HsaContributionLimit.INDIVIDUAL)) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) + .addFrequency(BenefitFrequency.ONE_TIME) + .addHsaContributionLimit(SupportedBenefit.HsaContributionLimit.INDIVIDUAL) .type(BenefitType._401K) .build() assertThat(supportedBenefit).isNotNull diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/ErrorHandlingTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/ErrorHandlingTest.kt index 7e131b2d..c76df6e8 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/ErrorHandlingTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/ErrorHandlingTest.kt @@ -63,24 +63,20 @@ class ErrorHandlingTest { val expected = Company.builder() .id("id") - .accounts( - listOf( - Company.Account.builder() - .accountName("account_name") - .accountNumber("account_number") - .accountType(Company.Account.AccountType.CHECKING) - .institutionName("institution_name") - .routingNumber("routing_number") - .build() - ) + .addAccount( + Company.Account.builder() + .accountName("account_name") + .accountNumber("account_number") + .accountType(Company.Account.AccountType.CHECKING) + .institutionName("institution_name") + .routingNumber("routing_number") + .build() ) - .departments( - listOf( - Company.Department.builder() - .name("name") - .parent(Company.Department.Parent.builder().name("name").build()) - .build() - ) + .addDepartment( + Company.Department.builder() + .name("name") + .parent(Company.Department.Parent.builder().name("name").build()) + .build() ) .ein("ein") .entity( @@ -90,19 +86,17 @@ class ErrorHandlingTest { .build() ) .legalName("legal_name") - .locations( - listOf( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .name("name") - .postalCode("postal_code") - .sourceId("source_id") - .state("state") - .build() - ) + .addLocation( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() ) .primaryEmail("primary_email") .primaryPhoneNumber("primary_phone_number") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceTest.kt index 1e47f3b5..d6a8f6d5 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceTest.kt @@ -25,7 +25,7 @@ class SessionServiceTest { ConnectSessionNewParams.builder() .customerId("x") .customerName("x") - .products(listOf(ConnectSessionNewParams.ConnectProducts.COMPANY)) + .addProduct(ConnectSessionNewParams.ConnectProducts.COMPANY) .customerEmail("dev@stainlessapi.com") .integration( ConnectSessionNewParams.Integration.builder() @@ -56,7 +56,7 @@ class SessionServiceTest { ConnectSessionReauthenticateParams.builder() .connectionId("connection_id") .minutesToExpire(0L) - .products(listOf(ConnectSessionReauthenticateParams.ConnectProducts.COMPANY)) + .addProduct(ConnectSessionReauthenticateParams.ConnectProducts.COMPANY) .redirectUri("https://example.com") .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceTest.kt index 8ab41102..0fb92f37 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceTest.kt @@ -33,7 +33,6 @@ class DirectoryServiceTest { .accessToken("My Access Token") .build() val directoryService = client.hris().directory() - @Suppress("DEPRECATION") val getDirectoryResponse = directoryService.listIndividuals(HrisDirectoryListIndividualsParams.builder().build()) println(getDirectoryResponse) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceTest.kt index aa7fdf33..09f54c0e 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceTest.kt @@ -23,10 +23,10 @@ class DocumentServiceTest { val documentListResponse = documentService.list( HrisDocumentListParams.builder() - .individualIds(listOf("string")) + .addIndividualId("string") .limit(0L) .offset(0L) - .types(listOf(HrisDocumentListParams.Type.W4_2020)) + .addType(HrisDocumentListParams.Type.W4_2020) .build() ) println(documentListResponse) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentServiceTest.kt index 72c101cf..9eba85be 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentServiceTest.kt @@ -22,12 +22,10 @@ class EmploymentServiceTest { val getEmploymentResponse = employmentService.retrieveMany( HrisEmploymentRetrieveManyParams.builder() - .requests( - listOf( - HrisEmploymentRetrieveManyParams.Request.builder() - .individualId("individual_id") - .build() - ) + .addRequest( + HrisEmploymentRetrieveManyParams.Request.builder() + .individualId("individual_id") + .build() ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementServiceTest.kt index b46fe04e..6d52ab44 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementServiceTest.kt @@ -22,12 +22,10 @@ class PayStatementServiceTest { val getPayStatementsResponse = payStatementService.retrieveMany( HrisPayStatementRetrieveManyParams.builder() - .requests( - listOf( - HrisPayStatementRetrieveManyParams.Request.builder() - .paymentId("string") - .build() - ) + .addRequest( + HrisPayStatementRetrieveManyParams.Request.builder() + .paymentId("string") + .build() ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceTest.kt index 1ecbae71..e6a6da70 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceTest.kt @@ -23,30 +23,24 @@ class CompanyServiceTest { val companyUpdateResponse = companyService.update( SandboxCompanyUpdateParams.builder() - .accounts( - listOf( - SandboxCompanyUpdateParams.Account.builder() - .accountName("account_name") - .accountNumber("account_number") - .accountType( - SandboxCompanyUpdateParams.Account.AccountType.CHECKING - ) - .institutionName("institution_name") - .routingNumber("routing_number") - .build() - ) + .addAccount( + SandboxCompanyUpdateParams.Account.builder() + .accountName("account_name") + .accountNumber("account_number") + .accountType(SandboxCompanyUpdateParams.Account.AccountType.CHECKING) + .institutionName("institution_name") + .routingNumber("routing_number") + .build() ) - .departments( - listOf( - SandboxCompanyUpdateParams.Department.builder() - .name("name") - .parent( - SandboxCompanyUpdateParams.Department.Parent.builder() - .name("name") - .build() - ) - .build() - ) + .addDepartment( + SandboxCompanyUpdateParams.Department.builder() + .name("name") + .parent( + SandboxCompanyUpdateParams.Department.Parent.builder() + .name("name") + .build() + ) + .build() ) .ein("ein") .entity( @@ -56,19 +50,17 @@ class CompanyServiceTest { .build() ) .legalName("legal_name") - .locations( - listOf( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .name("name") - .postalCode("postal_code") - .sourceId("source_id") - .state("state") - .build() - ) + .addLocation( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() ) .primaryEmail("primary_email") .primaryPhoneNumber("primary_phone_number") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceTest.kt index b8834168..7c74ddb7 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceTest.kt @@ -25,7 +25,7 @@ class ConnectionServiceTest { .providerId("provider_id") .authenticationType(SandboxConnectionCreateParams.AuthenticationType.CREDENTIAL) .employeeSize(0L) - .products(listOf("string")) + .addProduct("string") .build() ) println(connectionCreateResponse) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceTest.kt index dad8dab1..013e7140 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceTest.kt @@ -25,148 +25,131 @@ class DirectoryServiceTest { val directoryCreateResponse = directoryService.create( SandboxDirectoryCreateParams.builder() - .body( - listOf( - SandboxDirectoryCreateParams.IndividualOrEmployment.builder() - .classCode("class_code") - .customFields( - listOf( - SandboxDirectoryCreateParams.IndividualOrEmployment - .CustomField - .builder() - .name("name") - .value(JsonValue.from(mapOf())) - .build() - ) - ) - .department( - SandboxDirectoryCreateParams.IndividualOrEmployment.Department - .builder() - .name("name") - .build() - ) - .dob("01/01/2000") - .emails( - listOf( + .addBody( + SandboxDirectoryCreateParams.IndividualOrEmployment.builder() + .classCode("class_code") + .addCustomField( + SandboxDirectoryCreateParams.IndividualOrEmployment.CustomField + .builder() + .name("name") + .value(JsonValue.from(mapOf())) + .build() + ) + .department( + SandboxDirectoryCreateParams.IndividualOrEmployment.Department + .builder() + .name("name") + .build() + ) + .dob("01/01/2000") + .addEmail( + SandboxDirectoryCreateParams.IndividualOrEmployment.Email.builder() + .data("data") + .type( SandboxDirectoryCreateParams.IndividualOrEmployment.Email - .builder() - .data("data") - .type( - SandboxDirectoryCreateParams.IndividualOrEmployment - .Email - .Type - .WORK - ) - .build() + .Type + .WORK ) - ) - .employment( - SandboxDirectoryCreateParams.IndividualOrEmployment.Employment - .builder() - .subtype( - SandboxDirectoryCreateParams.IndividualOrEmployment - .Employment - .Subtype - .FULL_TIME - ) - .type( - SandboxDirectoryCreateParams.IndividualOrEmployment - .Employment - .Type - .EMPLOYEE - ) - .build() - ) - .employmentStatus( - SandboxDirectoryCreateParams.IndividualOrEmployment - .EmploymentStatus - .ACTIVE - ) - .encryptedSsn("encrypted_ssn") - .endDate("end_date") - .ethnicity( - SandboxDirectoryCreateParams.IndividualOrEmployment.Ethnicity - .ASIAN - ) - .firstName("John") - .gender( - SandboxDirectoryCreateParams.IndividualOrEmployment.Gender - .FEMALE - ) - .income( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) - .incomeHistory( - listOf( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() + .build() + ) + .employment( + SandboxDirectoryCreateParams.IndividualOrEmployment.Employment + .builder() + .subtype( + SandboxDirectoryCreateParams.IndividualOrEmployment + .Employment + .Subtype + .FULL_TIME + ) + .type( + SandboxDirectoryCreateParams.IndividualOrEmployment + .Employment + .Type + .EMPLOYEE ) - ) - .isActive(true) - .lastName("Smith") - .latestRehireDate("latest_rehire_date") - .location( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .name("name") - .postalCode("postal_code") - .sourceId("source_id") - .state("state") - .build() - ) - .manager( - SandboxDirectoryCreateParams.IndividualOrEmployment.Manager - .builder() - .id("id") - .build() - ) - .middleName("middle_name") - .phoneNumbers( - listOf( + .build() + ) + .employmentStatus( + SandboxDirectoryCreateParams.IndividualOrEmployment.EmploymentStatus + .ACTIVE + ) + .encryptedSsn("encrypted_ssn") + .endDate("end_date") + .ethnicity( + SandboxDirectoryCreateParams.IndividualOrEmployment.Ethnicity.ASIAN + ) + .firstName("John") + .gender( + SandboxDirectoryCreateParams.IndividualOrEmployment.Gender.FEMALE + ) + .income( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .isActive(true) + .lastName("Smith") + .latestRehireDate("latest_rehire_date") + .location( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() + ) + .manager( + SandboxDirectoryCreateParams.IndividualOrEmployment.Manager + .builder() + .id("id") + .build() + ) + .middleName("middle_name") + .addPhoneNumber( + SandboxDirectoryCreateParams.IndividualOrEmployment.PhoneNumber + .builder() + .data("data") + .type( SandboxDirectoryCreateParams.IndividualOrEmployment .PhoneNumber - .builder() - .data("data") - .type( - SandboxDirectoryCreateParams.IndividualOrEmployment - .PhoneNumber - .Type - .WORK - ) - .build() + .Type + .WORK ) - ) - .preferredName("preferred_name") - .residence( - Location.builder() - .city("city") - .country("country") - .line1("line1") - .line2("line2") - .name("name") - .postalCode("postal_code") - .sourceId("source_id") - .state("state") - .build() - ) - .sourceId("source_id") - .ssn("ssn") - .startDate("start_date") - .title("title") - .build() - ) + .build() + ) + .preferredName("preferred_name") + .residence( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() + ) + .sourceId("source_id") + .ssn("ssn") + .startDate("start_date") + .title("title") + .build() ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceTest.kt index c6842b48..aaeef4d7 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceTest.kt @@ -27,13 +27,11 @@ class EmploymentServiceTest { SandboxEmploymentUpdateParams.builder() .individualId("individual_id") .classCode("class_code") - .customFields( - listOf( - SandboxEmploymentUpdateParams.CustomField.builder() - .name("name") - .value(JsonValue.from(mapOf())) - .build() - ) + .addCustomField( + SandboxEmploymentUpdateParams.CustomField.builder() + .name("name") + .value(JsonValue.from(mapOf())) + .build() ) .department( SandboxEmploymentUpdateParams.Department.builder().name("name").build() @@ -55,15 +53,13 @@ class EmploymentServiceTest { .unit(Income.Unit.YEARLY) .build() ) - .incomeHistory( - listOf( - Income.builder() - .amount(0L) - .currency("currency") - .effectiveDate("effective_date") - .unit(Income.Unit.YEARLY) - .build() - ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() ) .isActive(true) .lastName("last_name") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceTest.kt index 46747df2..5e6c4be6 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceTest.kt @@ -25,13 +25,11 @@ class IndividualServiceTest { SandboxIndividualUpdateParams.builder() .individualId("individual_id") .dob("12/20/1989") - .emails( - listOf( - SandboxIndividualUpdateParams.Email.builder() - .data("data") - .type(SandboxIndividualUpdateParams.Email.Type.WORK) - .build() - ) + .addEmail( + SandboxIndividualUpdateParams.Email.builder() + .data("data") + .type(SandboxIndividualUpdateParams.Email.Type.WORK) + .build() ) .encryptedSsn("encrypted_ssn") .ethnicity(SandboxIndividualUpdateParams.Ethnicity.ASIAN) @@ -39,13 +37,11 @@ class IndividualServiceTest { .gender(SandboxIndividualUpdateParams.Gender.FEMALE) .lastName("last_name") .middleName("middle_name") - .phoneNumbers( - listOf( - SandboxIndividualUpdateParams.PhoneNumber.builder() - .data("data") - .type(SandboxIndividualUpdateParams.PhoneNumber.Type.WORK) - .build() - ) + .addPhoneNumber( + SandboxIndividualUpdateParams.PhoneNumber.builder() + .data("data") + .type(SandboxIndividualUpdateParams.PhoneNumber.Type.WORK) + .build() ) .preferredName("preferred_name") .residence( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt index 45615a60..bbdc3623 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt @@ -25,70 +25,55 @@ class PaymentServiceTest { paymentService.create( SandboxPaymentCreateParams.builder() .endDate("end_date") - .payStatements( - listOf( - SandboxPaymentCreateParams.PayStatement.builder() - .earnings( - listOf( - SandboxPaymentCreateParams.PayStatement.Earning.builder() - .amount(0L) - .currency("currency") - .hours(0.0) - .name("name") - .type( - SandboxPaymentCreateParams.PayStatement.Earning.Type - .SALARY - ) - .build() + .addPayStatement( + SandboxPaymentCreateParams.PayStatement.builder() + .addEarning( + SandboxPaymentCreateParams.PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type( + SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY ) - ) - .employeeDeductions( - listOf( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction - .builder() - .amount(2000L) - .currency("usd") - .name("401k test") - .preTax(true) - .type(BenefitType._401K) - .build() - ) - ) - .employerContributions( - listOf( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .builder() - .amount(0L) - .currency("currency") - .name("name") - .type(BenefitType._401K) - .build() - ) - ) - .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod( - SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK - ) - .taxes( - listOf( - SandboxPaymentCreateParams.PayStatement.Tax.builder() - .amount(0L) - .currency("currency") - .employer(true) - .name("name") - .type( - SandboxPaymentCreateParams.PayStatement.Tax.Type - .STATE - ) - .build() - ) - ) - .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) - .build() - ) + .build() + ) + .addEmployeeDeduction( + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() + .amount(2000L) + .currency("usd") + .name("401k test") + .preTax(true) + .type(BenefitType._401K) + .build() + ) + .addEmployerContribution( + SandboxPaymentCreateParams.PayStatement.EmployerContribution + .builder() + .amount(0L) + .currency("currency") + .name("name") + .type(BenefitType._401K) + .build() + ) + .grossPay(Money.builder().amount(0L).currency("currency").build()) + .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") + .netPay(Money.builder().amount(0L).currency("currency").build()) + .paymentMethod( + SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK + ) + .addTax( + SandboxPaymentCreateParams.PayStatement.Tax.builder() + .amount(0L) + .currency("currency") + .employer(true) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) + .build() + ) + .totalHours(0.0) + .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) + .build() ) .startDate("start_date") .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceTest.kt index ba50d5ed..9b1b064d 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceTest.kt @@ -29,7 +29,7 @@ class AccountServiceTest { .authenticationType( SandboxConnectionAccountCreateParams.AuthenticationType.CREDENTIAL ) - .products(listOf("string")) + .addProduct("string") .build() ) println(accountCreateResponse) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136..a4b76b95 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23a..cea7a793 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a42..f3b75f3b 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 25da30db..9d21a218 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ##########################################################################